Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Unified Diff: chrome/browser/component_updater/component_updater_interceptor.cc

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/component_updater/component_updater_interceptor.cc
diff --git a/chrome/browser/component_updater/component_updater_interceptor.cc b/chrome/browser/component_updater/component_updater_interceptor.cc
index 41d7eaef893ce082bb93cc5007faa4c7e61ef10d..4937c6b2f1e6b660996edcc6cc8ee1a8ac0e14ff 100644
--- a/chrome/browser/component_updater/component_updater_interceptor.cc
+++ b/chrome/browser/component_updater/component_updater_interceptor.cc
@@ -7,6 +7,7 @@
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_filter.h"
#include "net/url_request/url_request_test_job.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,15 +15,31 @@ using content::BrowserThread;
ComponentUpdateInterceptor::ComponentUpdateInterceptor()
: hit_count_(0) {
- net::URLRequest::Deprecated::RegisterRequestInterceptor(this);
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ComponentUpdateInterceptor::Register, this));
}
ComponentUpdateInterceptor::~ComponentUpdateInterceptor() {
- net::URLRequest::Deprecated::UnregisterRequestInterceptor(this);
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(Unregister));
}
-net::URLRequestJob* ComponentUpdateInterceptor::MaybeIntercept(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
+void ComponentUpdateInterceptor::Register() {
+ net::URLRequestFilter::GetInstance()->AddHostnameProtocolHandler("http",
+ "localhost",
+ this);
+}
+
+// static
+void ComponentUpdateInterceptor::Unregister() {
+ net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http",
+ "localhost");
+}
+
+net::URLRequestJob* ComponentUpdateInterceptor::MaybeCreateJob(
+ net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (request->url().scheme() != "http" ||
request->url().host() != "localhost") {
@@ -33,7 +50,7 @@ net::URLRequestJob* ComponentUpdateInterceptor::MaybeIntercept(
// is just used for tests.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- ResponseMap::iterator it = responses_.find(request->url());
+ ResponseMap::const_iterator it = responses_.find(request->url());
if (it == responses_.end()) {
return NULL;
}

Powered by Google App Engine
This is Rietveld 408576698