summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/chrome_network_delegate.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 00:22:50 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 00:22:50 +0000
commit0651b818c7122d319954ff5bc30dff68ba8b9013 (patch)
treed18a681545594c17175a584b7d56a6ee9abd10b6 /chrome/browser/net/chrome_network_delegate.cc
parent26616172ccaeae9842d7e52b556bc49e16751455 (diff)
downloadchromium_src-0651b818c7122d319954ff5bc30dff68ba8b9013.zip
chromium_src-0651b818c7122d319954ff5bc30dff68ba8b9013.tar.gz
chromium_src-0651b818c7122d319954ff5bc30dff68ba8b9013.tar.bz2
Refactor of NetworkDelegate.
* Renames HttpNetworkDelegate to NetworkDelegate, moves to net/base/network_delegate.h. NOTE: this is a layering violation. wtc/eroman/willchan have agreed to this exception because the other solutions are less palatable. * Move the virtuals in NetworkDelegate to the private section. Use non-virtual public interface as the network stack's interface for notifying the delegate. Add sanity checking to the implmentation in NetworkDelegate. The private virtual interface is for consumers to receive notifications. * Remove ExtensionIOEventRouter from ChromeURLRequestContext, it is only used by the ChromeNetworkDelegate. Pass it directly to the ChromeNetworkDelegate's constructor. * Introduce a SystemNetworkDelegate. It does nothing right now. BUG=67232 TEST=none Review URL: http://codereview.chromium.org/6580002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75822 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_network_delegate.cc')
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc30
1 files changed, 12 insertions, 18 deletions
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index ce79045..5452b96 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -14,52 +14,46 @@
namespace {
-// Get the event router from the request context. Currently only
-// ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to
-// work.
-const ExtensionIOEventRouter* GetIOEventRouter(
- net::URLRequestContext* context) {
- return static_cast<ChromeURLRequestContext*>(context)->
- extension_io_event_router();
-}
-
// If the |request| failed due to problems with a proxy, forward the error to
// the proxy extension API.
-void ForwardProxyErrors(net::URLRequest* request) {
+void ForwardProxyErrors(net::URLRequest* request,
+ ExtensionIOEventRouter* router) {
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(
- GetIOEventRouter(request->context()),
- request->status().os_error());
+ router, request->status().os_error());
}
}
}
} // namespace
-ChromeNetworkDelegate::ChromeNetworkDelegate() {}
+ChromeNetworkDelegate::ChromeNetworkDelegate(
+ ExtensionIOEventRouter* extension_io_event_router)
+ : extension_io_event_router_(extension_io_event_router) {
+ DCHECK(extension_io_event_router);
+}
+
ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
- GetIOEventRouter(request->context()), request->url(), request->method());
+ extension_io_event_router_, request->url(), request->method());
}
void ChromeNetworkDelegate::OnSendHttpRequest(
net::HttpRequestHeaders* headers) {
DCHECK(headers);
-
- // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here.
}
void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
- ForwardProxyErrors(request);
+ ForwardProxyErrors(request, extension_io_event_router_);
}
void ChromeNetworkDelegate::OnReadCompleted(net::URLRequest* request,
int bytes_read) {
- ForwardProxyErrors(request);
+ ForwardProxyErrors(request, extension_io_event_router_);
}