| Index: chrome/browser/extensions/autoupdate_interceptor.cc
|
| diff --git a/chrome/browser/extensions/autoupdate_interceptor.cc b/chrome/browser/extensions/autoupdate_interceptor.cc
|
| index febc9cf5f19b458cc14ef626fbdf11a75472bc91..37d1237a4eaab84c9e9a28ca7bdecb3520f1837e 100644
|
| --- a/chrome/browser/extensions/autoupdate_interceptor.cc
|
| +++ b/chrome/browser/extensions/autoupdate_interceptor.cc
|
| @@ -9,6 +9,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"
|
|
|
| @@ -39,19 +40,35 @@ class AutoUpdateTestRequestJob : public net::URLRequestTestJob {
|
|
|
|
|
| AutoUpdateInterceptor::AutoUpdateInterceptor() {
|
| - net::URLRequest::Deprecated::RegisterRequestInterceptor(this);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&AutoUpdateInterceptor::Register, this));
|
| }
|
|
|
| AutoUpdateInterceptor::~AutoUpdateInterceptor() {
|
| - net::URLRequest::Deprecated::UnregisterRequestInterceptor(this);
|
| + BrowserThread::PostTask(BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(Unregister));
|
| +}
|
| +
|
| +void AutoUpdateInterceptor::Register() {
|
| + net::URLRequestFilter::GetInstance()->AddHostnameProtocolHandler("http",
|
| + "localhost",
|
| + this);
|
| }
|
|
|
| -net::URLRequestJob* AutoUpdateInterceptor::MaybeIntercept(
|
| - net::URLRequest* request, net::NetworkDelegate* network_delegate) {
|
| +// static
|
| +void AutoUpdateInterceptor::Unregister() {
|
| + net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http",
|
| + "localhost");
|
| +}
|
| +
|
| +net::URLRequestJob* AutoUpdateInterceptor::MaybeCreateJob(
|
| + net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
|
| EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| if (request->url().scheme() != "http" ||
|
| request->url().host() != "localhost") {
|
| - return NULL;
|
| + return NULL;
|
| }
|
|
|
| // It's ok to do a blocking disk access on this thread; this class
|
| @@ -65,7 +82,7 @@ net::URLRequestJob* AutoUpdateInterceptor::MaybeIntercept(
|
| replacements.ClearQuery();
|
| url = url.ReplaceComponents(replacements);
|
| }
|
| - std::map<GURL, FilePath>::iterator i = responses_.find(url);
|
| + std::map<GURL, FilePath>::const_iterator i = responses_.find(url);
|
| if (i == responses_.end()) {
|
| return NULL;
|
| }
|
|
|