summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc20
-rw-r--r--chrome/browser/net/chrome_network_delegate.h14
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);
};