diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 21:29:48 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 21:29:48 +0000 |
commit | 05cc4e799b897a440333d3dbe6d18b904a49759f (patch) | |
tree | 28d5c1a1aed5c8d0a9648c7e19e595c96c49c0db /chrome/browser/net | |
parent | b10392939246b06c48eb5debc961839591ebe72a (diff) | |
download | chromium_src-05cc4e799b897a440333d3dbe6d18b904a49759f.zip chromium_src-05cc4e799b897a440333d3dbe6d18b904a49759f.tar.gz chromium_src-05cc4e799b897a440333d3dbe6d18b904a49759f.tar.bz2 |
Implement blocking for webRequest.onBeforeRequest extension event.
I did some measurements with a Release build of chrome, both manually and via the page cycler tests. It seems that a simple empty blocking event listener can add anywhere from a 1 to 30ms delay to request times, largely depending on how many requests are in the queue (when many requests come at once, the last ones to be processed by the extension are delayed the longest).
From page cycler data (on my local machine), the average increase in page load time seems to be around 6ms. This is independent of total page load time (which makes sense).
BUG=60101
TEST=covered by apitests
Review URL: http://codereview.chromium.org/6574049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.cc | 7 | ||||
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.h | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc index 59fb2e6..8fa34b0 100644 --- a/chrome/browser/net/chrome_network_delegate.cc +++ b/chrome/browser/net/chrome_network_delegate.cc @@ -41,9 +41,10 @@ ChromeNetworkDelegate::ChromeNetworkDelegate( ChromeNetworkDelegate::~ChromeNetworkDelegate() {} -void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) { - ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( - event_router_.get(), profile_id_, request->url(), request->method()); +bool ChromeNetworkDelegate::OnBeforeURLRequest( + net::URLRequest* request, net::CompletionCallback* callback) { + return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( + profile_id_, event_router_.get(), request, callback); } void ChromeNetworkDelegate::OnSendHttpRequest( diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h index 5b3fb15..2f2f0ea 100644 --- a/chrome/browser/net/chrome_network_delegate.h +++ b/chrome/browser/net/chrome_network_delegate.h @@ -17,8 +17,8 @@ class ExtensionEventRouterForwarder; // 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. + // If |profile_id| is the invalid profile, events will be broadcasted to all + // profiles, otherwise, they will only be sent to the specified profile. explicit ChromeNetworkDelegate( ExtensionEventRouterForwarder* event_router, ProfileId profile_id); @@ -26,7 +26,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { private: // NetworkDelegate methods: - virtual void OnBeforeURLRequest(net::URLRequest* request); + virtual bool OnBeforeURLRequest(net::URLRequest* request, + net::CompletionCallback* callback); virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers); virtual void OnResponseStarted(net::URLRequest* request); virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); |