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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "chrome/browser/prefs/pref_member.h" | |
11 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
12 #include "net/base/network_delegate.h" | 14 #include "net/base/network_delegate.h" |
13 | 15 |
14 class ExtensionEventRouterForwarder; | 16 class ExtensionEventRouterForwarder; |
15 class ProtocolHandlerRegistry; | 17 class ProtocolHandlerRegistry; |
16 | 18 |
17 // ChromeNetworkDelegate is the central point from within the chrome code to | 19 // ChromeNetworkDelegate is the central point from within the chrome code to |
18 // add hooks into the network stack. | 20 // add hooks into the network stack. |
19 class ChromeNetworkDelegate : public net::NetworkDelegate { | 21 class ChromeNetworkDelegate : public net::NetworkDelegate { |
20 public: | 22 public: |
21 // If |profile_id| is the invalid profile, events will be broadcasted to all | 23 // If |profile_id| is the invalid profile, events will be broadcasted to all |
22 // profiles, otherwise, they will only be sent to the specified profile. | 24 // profiles, otherwise, they will only be sent to the specified profile. |
25 // |enable_referrers| is a PrefMember which should be bound to the profile's | |
26 // PrefService and moved to the IO thread. It can be NULL. This object will | |
willchan no longer on Chromium
2011/04/05 13:10:41
Why are you allowing it to be NULL? Does it crash
Bernhard Bauer
2011/04/05 14:49:02
Yeah, I thought about adding support for the pref
willchan no longer on Chromium
2011/04/05 15:06:18
I think I'd prefer this, but I don't feel too stro
Bernhard Bauer
2011/04/05 16:12:59
Fair enough. Done.
| |
27 // take ownership of it. | |
23 explicit ChromeNetworkDelegate( | 28 explicit ChromeNetworkDelegate( |
24 ExtensionEventRouterForwarder* event_router, | 29 ExtensionEventRouterForwarder* event_router, |
25 ProfileId profile_id, | 30 ProfileId profile_id, |
31 BooleanPrefMember* enable_referrers, | |
26 ProtocolHandlerRegistry* protocol_handler_registry); | 32 ProtocolHandlerRegistry* protocol_handler_registry); |
27 virtual ~ChromeNetworkDelegate(); | 33 virtual ~ChromeNetworkDelegate(); |
28 | 34 |
29 private: | 35 private: |
30 // NetworkDelegate methods: | 36 // NetworkDelegate methods: |
31 virtual int OnBeforeURLRequest(net::URLRequest* request, | 37 virtual int OnBeforeURLRequest(net::URLRequest* request, |
32 net::CompletionCallback* callback); | 38 net::CompletionCallback* callback); |
33 virtual int OnBeforeSendHeaders(uint64 request_id, | 39 virtual int OnBeforeSendHeaders(uint64 request_id, |
34 net::HttpRequestHeaders* headers, | 40 net::HttpRequestHeaders* headers, |
35 net::CompletionCallback* callback); | 41 net::CompletionCallback* callback); |
36 virtual void OnResponseStarted(net::URLRequest* request); | 42 virtual void OnResponseStarted(net::URLRequest* request); |
37 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); | 43 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); |
38 virtual void OnURLRequestDestroyed(net::URLRequest* request); | 44 virtual void OnURLRequestDestroyed(net::URLRequest* request); |
39 virtual net::URLRequestJob* OnMaybeCreateURLRequestJob( | 45 virtual net::URLRequestJob* OnMaybeCreateURLRequestJob( |
40 net::URLRequest* request); | 46 net::URLRequest* request); |
41 | 47 |
42 scoped_refptr<ExtensionEventRouterForwarder> event_router_; | 48 scoped_refptr<ExtensionEventRouterForwarder> event_router_; |
43 const ProfileId profile_id_; | 49 const ProfileId profile_id_; |
50 scoped_ptr<BooleanPrefMember> enable_referrers_; | |
44 scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; | 51 scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; |
45 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 52 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
46 }; | 53 }; |
47 | 54 |
48 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 55 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |