diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-01 12:01:15 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-01 12:01:15 +0000 |
commit | 3ce02419d4f7b3cd1fc062f87fb63a78072b5483 (patch) | |
tree | 6bdbb2cc363827fe8fb6186d5cbf5787f5aaf29d /chrome/browser/net | |
parent | af3f286560a8fadb4eb6cb51c7ba2cb0f8e17a66 (diff) | |
download | chromium_src-3ce02419d4f7b3cd1fc062f87fb63a78072b5483.zip chromium_src-3ce02419d4f7b3cd1fc062f87fb63a78072b5483.tar.gz chromium_src-3ce02419d4f7b3cd1fc062f87fb63a78072b5483.tar.bz2 |
Make the ChromeNetworkDelegate use the ExtensionEventRouterForwarder
BUG=73903
TEST=tests for proxy and webrequest API should still work
Review URL: http://codereview.chromium.org/6598002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.cc | 20 | ||||
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.h | 14 |
2 files changed, 21 insertions, 13 deletions
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc index 5452b96..59fb2e6 100644 --- a/chrome/browser/net/chrome_network_delegate.cc +++ b/chrome/browser/net/chrome_network_delegate.cc @@ -5,9 +5,9 @@ #include "chrome/browser/net/chrome_network_delegate.h" #include "base/logging.h" +#include "chrome/browser/extensions/extension_event_router_forwarder.h" #include "chrome/browser/extensions/extension_proxy_api.h" #include "chrome/browser/extensions/extension_webrequest_api.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "net/base/net_errors.h" #include "net/http/http_request_headers.h" #include "net/url_request/url_request.h" @@ -17,14 +17,15 @@ namespace { // If the |request| failed due to problems with a proxy, forward the error to // the proxy extension API. void ForwardProxyErrors(net::URLRequest* request, - ExtensionIOEventRouter* router) { + ExtensionEventRouterForwarder* event_router, + ProfileId profile_id) { if (request->status().status() == net::URLRequestStatus::FAILED) { switch (request->status().os_error()) { case net::ERR_PROXY_AUTH_UNSUPPORTED: case net::ERR_PROXY_CONNECTION_FAILED: case net::ERR_TUNNEL_CONNECTION_FAILED: ExtensionProxyEventRouter::GetInstance()->OnProxyError( - router, request->status().os_error()); + event_router, profile_id, request->status().os_error()); } } } @@ -32,16 +33,17 @@ void ForwardProxyErrors(net::URLRequest* request, } // namespace ChromeNetworkDelegate::ChromeNetworkDelegate( - ExtensionIOEventRouter* extension_io_event_router) - : extension_io_event_router_(extension_io_event_router) { - DCHECK(extension_io_event_router); + ExtensionEventRouterForwarder* event_router, + ProfileId profile_id) + : event_router_(event_router), + profile_id_(profile_id) { } ChromeNetworkDelegate::~ChromeNetworkDelegate() {} void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) { ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( - extension_io_event_router_, request->url(), request->method()); + event_router_.get(), profile_id_, request->url(), request->method()); } void ChromeNetworkDelegate::OnSendHttpRequest( @@ -50,10 +52,10 @@ void ChromeNetworkDelegate::OnSendHttpRequest( } void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { - ForwardProxyErrors(request, extension_io_event_router_); + ForwardProxyErrors(request, event_router_.get(), profile_id_); } void ChromeNetworkDelegate::OnReadCompleted(net::URLRequest* request, int bytes_read) { - ForwardProxyErrors(request, extension_io_event_router_); + ForwardProxyErrors(request, event_router_.get(), profile_id_); } diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h index fbac036..5b3fb15 100644 --- a/chrome/browser/net/chrome_network_delegate.h +++ b/chrome/browser/net/chrome_network_delegate.h @@ -7,17 +7,22 @@ #pragma once #include "base/basictypes.h" +#include "base/ref_counted.h" +#include "chrome/browser/profiles/profile.h" #include "net/base/network_delegate.h" -class ExtensionIOEventRouter; +class ExtensionEventRouterForwarder; // ChromeNetworkDelegate is the central point from within the chrome code to // add hooks into the network stack. class ChromeNetworkDelegate : public net::NetworkDelegate { public: + // If |profile| is NULL, events will be broadcasted to all profiles, + // otherwise, they will be only send to the specified profile. explicit ChromeNetworkDelegate( - ExtensionIOEventRouter* extension_io_event_router); - ~ChromeNetworkDelegate(); + ExtensionEventRouterForwarder* event_router, + ProfileId profile_id); + virtual ~ChromeNetworkDelegate(); private: // NetworkDelegate methods: @@ -26,7 +31,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { virtual void OnResponseStarted(net::URLRequest* request); virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); - ExtensionIOEventRouter* const extension_io_event_router_; + scoped_refptr<ExtensionEventRouterForwarder> event_router_; + const ProfileId profile_id_; DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); }; |