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 ExtensionEventRouterForwarder; | 14 class ExtensionEventRouterForwarder; |
15 class ExtensionInfoMap; | 15 class ExtensionInfoMap; |
16 class PrefService; | 16 class PrefService; |
17 template<class T> class PrefMember; | 17 template<class T> class PrefMember; |
18 | 18 |
19 typedef PrefMember<bool> BooleanPrefMember; | 19 typedef PrefMember<bool> BooleanPrefMember; |
20 | 20 |
21 namespace chrome_browser_net { | |
22 class CacheStats; | |
23 } | |
24 | |
21 namespace policy { | 25 namespace policy { |
22 class URLBlacklistManager; | 26 class URLBlacklistManager; |
23 } | 27 } |
24 | 28 |
25 // ChromeNetworkDelegate is the central point from within the chrome code to | 29 // ChromeNetworkDelegate is the central point from within the chrome code to |
26 // add hooks into the network stack. | 30 // add hooks into the network stack. |
27 class ChromeNetworkDelegate : public net::NetworkDelegate { | 31 class ChromeNetworkDelegate : public net::NetworkDelegate { |
28 public: | 32 public: |
29 // If |profile| is NULL, events will be broadcasted to all profiles, | 33 // If |profile| is NULL, events will be broadcasted to all profiles, |
30 // otherwise they will only be sent to the specified profile. | 34 // otherwise they will only be sent to the specified profile. |
31 // |enable_referrers| should be initialized on the UI thread (see below) | 35 // |enable_referrers| should be initialized on the UI thread (see below) |
32 // beforehand. This object's owner is responsible for cleaning it up at | 36 // beforehand. This object's owner is responsible for cleaning it up at |
33 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, | 37 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, |
34 // otherwise, the settings are enforced on all observed network requests. | 38 // otherwise, the settings are enforced on all observed network requests. |
35 ChromeNetworkDelegate( | 39 ChromeNetworkDelegate( |
36 ExtensionEventRouterForwarder* event_router, | 40 ExtensionEventRouterForwarder* event_router, |
37 ExtensionInfoMap* extension_info_map, | 41 ExtensionInfoMap* extension_info_map, |
38 const policy::URLBlacklistManager* url_blacklist_manager, | 42 const policy::URLBlacklistManager* url_blacklist_manager, |
39 void* profile, | 43 void* profile, |
40 CookieSettings* cookie_settings, | 44 CookieSettings* cookie_settings, |
41 BooleanPrefMember* enable_referrers); | 45 BooleanPrefMember* enable_referrers, |
46 chrome_browser_net::CacheStats* cache_stats); | |
42 virtual ~ChromeNetworkDelegate(); | 47 virtual ~ChromeNetworkDelegate(); |
43 | 48 |
44 // Causes |OnCanThrottleRequest| to never return true. | 49 // Causes |OnCanThrottleRequest| to never return true. |
45 void NeverThrottleRequests(); | 50 void NeverThrottleRequests(); |
46 | 51 |
47 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. | 52 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. |
48 // This method should be called on the UI thread. | 53 // This method should be called on the UI thread. |
49 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, | 54 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, |
50 PrefService* pref_service); | 55 PrefService* pref_service); |
51 | 56 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 virtual bool OnCanSetCookie(const net::URLRequest& request, | 93 virtual bool OnCanSetCookie(const net::URLRequest& request, |
89 const std::string& cookie_line, | 94 const std::string& cookie_line, |
90 net::CookieOptions* options) OVERRIDE; | 95 net::CookieOptions* options) OVERRIDE; |
91 virtual bool OnCanAccessFile(const net::URLRequest& request, | 96 virtual bool OnCanAccessFile(const net::URLRequest& request, |
92 const FilePath& path) const OVERRIDE; | 97 const FilePath& path) const OVERRIDE; |
93 virtual bool OnCanThrottleRequest( | 98 virtual bool OnCanThrottleRequest( |
94 const net::URLRequest& request) const OVERRIDE; | 99 const net::URLRequest& request) const OVERRIDE; |
95 virtual int OnBeforeSocketStreamConnect( | 100 virtual int OnBeforeSocketStreamConnect( |
96 net::SocketStream* stream, | 101 net::SocketStream* stream, |
97 const net::CompletionCallback& callback) OVERRIDE; | 102 const net::CompletionCallback& callback) OVERRIDE; |
103 virtual void OnCacheWaitStateChange(const net::URLRequest& request, | |
104 CacheWaitState state) OVERRIDE; | |
98 | 105 |
99 scoped_refptr<ExtensionEventRouterForwarder> event_router_; | 106 scoped_refptr<ExtensionEventRouterForwarder> event_router_; |
100 void* profile_; | 107 void* profile_; |
101 scoped_refptr<CookieSettings> cookie_settings_; | 108 scoped_refptr<CookieSettings> cookie_settings_; |
102 | 109 |
103 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 110 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
104 | 111 |
105 // Weak, owned by our owner. | 112 // Weak, owned by our owner. |
106 BooleanPrefMember* enable_referrers_; | 113 BooleanPrefMember* enable_referrers_; |
107 | 114 |
108 // True if OnCanThrottleRequest should always return false. | 115 // True if OnCanThrottleRequest should always return false. |
109 bool never_throttle_requests_; | 116 bool never_throttle_requests_; |
110 | 117 |
111 // Weak, owned by our owner. | 118 // Weak, owned by our owner. |
112 const policy::URLBlacklistManager* url_blacklist_manager_; | 119 const policy::URLBlacklistManager* url_blacklist_manager_; |
113 | 120 |
114 // When true, allow access to all file:// URLs. | 121 // When true, allow access to all file:// URLs. |
115 static bool g_allow_file_access_; | 122 static bool g_allow_file_access_; |
116 | 123 |
124 chrome_browser_net::CacheStats* cache_stats_; | |
willchan no longer on Chromium
2012/07/26 01:39:37
Document that this an IOThread global, so it shoul
tburkard
2012/07/26 02:10:40
Done.
| |
125 | |
117 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 126 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
118 }; | 127 }; |
119 | 128 |
120 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 129 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |