OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "net/base/network_delegate.h" | 11 #include "net/base/network_delegate.h" |
12 | 12 |
13 class CookieSettings; | 13 class CookieSettings; |
14 class ExtensionInfoMap; | 14 class ExtensionInfoMap; |
15 class PrefService; | 15 class PrefService; |
16 template<class T> class PrefMember; | 16 template<class T> class PrefMember; |
17 | 17 |
18 typedef PrefMember<bool> BooleanPrefMember; | 18 typedef PrefMember<bool> BooleanPrefMember; |
19 | 19 |
| 20 namespace chrome_browser_net { |
| 21 class CacheStats; |
| 22 } |
| 23 |
20 namespace extensions { | 24 namespace extensions { |
21 class EventRouterForwarder; | 25 class EventRouterForwarder; |
22 } | 26 } |
23 | 27 |
24 namespace policy { | 28 namespace policy { |
25 class URLBlacklistManager; | 29 class URLBlacklistManager; |
26 } | 30 } |
27 | 31 |
28 // ChromeNetworkDelegate is the central point from within the chrome code to | 32 // ChromeNetworkDelegate is the central point from within the chrome code to |
29 // add hooks into the network stack. | 33 // add hooks into the network stack. |
30 class ChromeNetworkDelegate : public net::NetworkDelegate { | 34 class ChromeNetworkDelegate : public net::NetworkDelegate { |
31 public: | 35 public: |
32 // If |profile| is NULL, events will be broadcasted to all profiles, | 36 // If |profile| is NULL, events will be broadcasted to all profiles, |
33 // otherwise they will only be sent to the specified profile. | 37 // otherwise they will only be sent to the specified profile. |
34 // |enable_referrers| should be initialized on the UI thread (see below) | 38 // |enable_referrers| should be initialized on the UI thread (see below) |
35 // beforehand. This object's owner is responsible for cleaning it up at | 39 // beforehand. This object's owner is responsible for cleaning it up at |
36 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, | 40 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, |
37 // otherwise, the settings are enforced on all observed network requests. | 41 // otherwise, the settings are enforced on all observed network requests. |
38 ChromeNetworkDelegate( | 42 ChromeNetworkDelegate( |
39 extensions::EventRouterForwarder* event_router, | 43 extensions::EventRouterForwarder* event_router, |
40 ExtensionInfoMap* extension_info_map, | 44 ExtensionInfoMap* extension_info_map, |
41 const policy::URLBlacklistManager* url_blacklist_manager, | 45 const policy::URLBlacklistManager* url_blacklist_manager, |
42 void* profile, | 46 void* profile, |
43 CookieSettings* cookie_settings, | 47 CookieSettings* cookie_settings, |
44 BooleanPrefMember* enable_referrers); | 48 BooleanPrefMember* enable_referrers, |
| 49 chrome_browser_net::CacheStats* cache_stats); |
45 virtual ~ChromeNetworkDelegate(); | 50 virtual ~ChromeNetworkDelegate(); |
46 | 51 |
47 // Causes |OnCanThrottleRequest| to never return true. | 52 // Causes |OnCanThrottleRequest| to never return true. |
48 void NeverThrottleRequests(); | 53 void NeverThrottleRequests(); |
49 | 54 |
50 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. | 55 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. |
51 // This method should be called on the UI thread. | 56 // This method should be called on the UI thread. |
52 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, | 57 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, |
53 PrefService* pref_service); | 58 PrefService* pref_service); |
54 | 59 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 virtual bool OnCanSetCookie(const net::URLRequest& request, | 96 virtual bool OnCanSetCookie(const net::URLRequest& request, |
92 const std::string& cookie_line, | 97 const std::string& cookie_line, |
93 net::CookieOptions* options) OVERRIDE; | 98 net::CookieOptions* options) OVERRIDE; |
94 virtual bool OnCanAccessFile(const net::URLRequest& request, | 99 virtual bool OnCanAccessFile(const net::URLRequest& request, |
95 const FilePath& path) const OVERRIDE; | 100 const FilePath& path) const OVERRIDE; |
96 virtual bool OnCanThrottleRequest( | 101 virtual bool OnCanThrottleRequest( |
97 const net::URLRequest& request) const OVERRIDE; | 102 const net::URLRequest& request) const OVERRIDE; |
98 virtual int OnBeforeSocketStreamConnect( | 103 virtual int OnBeforeSocketStreamConnect( |
99 net::SocketStream* stream, | 104 net::SocketStream* stream, |
100 const net::CompletionCallback& callback) OVERRIDE; | 105 const net::CompletionCallback& callback) OVERRIDE; |
| 106 virtual void OnCacheWaitStateChange(const net::URLRequest& request, |
| 107 CacheWaitState state) OVERRIDE; |
101 | 108 |
102 scoped_refptr<extensions::EventRouterForwarder> event_router_; | 109 scoped_refptr<extensions::EventRouterForwarder> event_router_; |
103 void* profile_; | 110 void* profile_; |
104 scoped_refptr<CookieSettings> cookie_settings_; | 111 scoped_refptr<CookieSettings> cookie_settings_; |
105 | 112 |
106 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 113 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
107 | 114 |
108 // Weak, owned by our owner. | 115 // Weak, owned by our owner. |
109 BooleanPrefMember* enable_referrers_; | 116 BooleanPrefMember* enable_referrers_; |
110 | 117 |
111 // True if OnCanThrottleRequest should always return false. | 118 // True if OnCanThrottleRequest should always return false. |
112 bool never_throttle_requests_; | 119 bool never_throttle_requests_; |
113 | 120 |
114 // Weak, owned by our owner. | 121 // Weak, owned by our owner. |
115 const policy::URLBlacklistManager* url_blacklist_manager_; | 122 const policy::URLBlacklistManager* url_blacklist_manager_; |
116 | 123 |
117 // When true, allow access to all file:// URLs. | 124 // When true, allow access to all file:// URLs. |
118 static bool g_allow_file_access_; | 125 static bool g_allow_file_access_; |
119 | 126 |
| 127 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. |
| 128 chrome_browser_net::CacheStats* cache_stats_; |
| 129 |
120 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 130 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
121 }; | 131 }; |
122 | 132 |
123 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 133 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |