| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "net/base/network_delegate.h" | 12 #include "net/base/network_delegate.h" |
| 14 | 13 |
| 15 class ExtensionEventRouterForwarder; | 14 class ExtensionEventRouterForwarder; |
| 16 class ExtensionInfoMap; | 15 class ExtensionInfoMap; |
| 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 // ChromeNetworkDelegate is the central point from within the chrome code to | 21 // ChromeNetworkDelegate is the central point from within the chrome code to |
| 22 // add hooks into the network stack. | 22 // add hooks into the network stack. |
| 23 class ChromeNetworkDelegate : public net::NetworkDelegate { | 23 class ChromeNetworkDelegate : public net::NetworkDelegate { |
| 24 public: | 24 public: |
| 25 // If |profile_id| is the invalid profile, events will be broadcasted to all | 25 // If |profile| is NULL, events will be broadcasted to all profiles, otherwise |
| 26 // profiles, otherwise, they will only be sent to the specified profile. | 26 // they will only be sent to the specified profile. |
| 27 // |enable_referrers| should be initialized on the UI thread (see below) | 27 // |enable_referrers| should be initialized on the UI thread (see below) |
| 28 // beforehand. This object's owner is responsible for cleaning it up | 28 // beforehand. This object's owner is responsible for cleaning it up |
| 29 // at shutdown. | 29 // at shutdown. |
| 30 ChromeNetworkDelegate( | 30 ChromeNetworkDelegate( |
| 31 ExtensionEventRouterForwarder* event_router, | 31 ExtensionEventRouterForwarder* event_router, |
| 32 ExtensionInfoMap* extension_info_map, | 32 ExtensionInfoMap* extension_info_map, |
| 33 ProfileId profile_id, | 33 void* profile, |
| 34 BooleanPrefMember* enable_referrers); | 34 BooleanPrefMember* enable_referrers); |
| 35 virtual ~ChromeNetworkDelegate(); | 35 virtual ~ChromeNetworkDelegate(); |
| 36 | 36 |
| 37 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. | 37 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. |
| 38 // This method should be called on the UI thread. | 38 // This method should be called on the UI thread. |
| 39 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, | 39 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, |
| 40 PrefService* pref_service); | 40 PrefService* pref_service); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 // NetworkDelegate methods: | 43 // NetworkDelegate methods: |
| 44 virtual int OnBeforeURLRequest(net::URLRequest* request, | 44 virtual int OnBeforeURLRequest(net::URLRequest* request, |
| 45 net::CompletionCallback* callback, | 45 net::CompletionCallback* callback, |
| 46 GURL* new_url) OVERRIDE; | 46 GURL* new_url) OVERRIDE; |
| 47 virtual int OnBeforeSendHeaders(net::URLRequest* request, | 47 virtual int OnBeforeSendHeaders(net::URLRequest* request, |
| 48 net::CompletionCallback* callback, | 48 net::CompletionCallback* callback, |
| 49 net::HttpRequestHeaders* headers) OVERRIDE; | 49 net::HttpRequestHeaders* headers) OVERRIDE; |
| 50 virtual void OnRequestSent(uint64 request_id, | 50 virtual void OnRequestSent(uint64 request_id, |
| 51 const net::HostPortPair& socket_address, | 51 const net::HostPortPair& socket_address, |
| 52 const net::HttpRequestHeaders& headers); | 52 const net::HttpRequestHeaders& headers); |
| 53 virtual void OnBeforeRedirect(net::URLRequest* request, | 53 virtual void OnBeforeRedirect(net::URLRequest* request, |
| 54 const GURL& new_location); | 54 const GURL& new_location); |
| 55 virtual void OnResponseStarted(net::URLRequest* request); | 55 virtual void OnResponseStarted(net::URLRequest* request); |
| 56 virtual void OnRawBytesRead(const net::URLRequest& request, int bytes_read); | 56 virtual void OnRawBytesRead(const net::URLRequest& request, int bytes_read); |
| 57 virtual void OnCompleted(net::URLRequest* request); | 57 virtual void OnCompleted(net::URLRequest* request); |
| 58 virtual void OnURLRequestDestroyed(net::URLRequest* request); | 58 virtual void OnURLRequestDestroyed(net::URLRequest* request); |
| 59 virtual void OnHttpTransactionDestroyed(uint64 request_id); | 59 virtual void OnHttpTransactionDestroyed(uint64 request_id); |
| 60 virtual void OnPACScriptError(int line_number, const string16& error); | 60 virtual void OnPACScriptError(int line_number, const string16& error); |
| 61 | 61 |
| 62 scoped_refptr<ExtensionEventRouterForwarder> event_router_; | 62 scoped_refptr<ExtensionEventRouterForwarder> event_router_; |
| 63 const ProfileId profile_id_; | 63 void* profile_; |
| 64 | 64 |
| 65 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 65 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 66 | 66 |
| 67 // Weak, owned by our owner. | 67 // Weak, owned by our owner. |
| 68 BooleanPrefMember* enable_referrers_; | 68 BooleanPrefMember* enable_referrers_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 73 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
| OLD | NEW |