Chromium Code Reviews| Index: net/url_request/protocol_intercept_job_factory.cc |
| diff --git a/chrome/browser/net/http_intercept_job_factory.cc b/net/url_request/protocol_intercept_job_factory.cc |
| similarity index 54% |
| rename from chrome/browser/net/http_intercept_job_factory.cc |
| rename to net/url_request/protocol_intercept_job_factory.cc |
| index e3f2e77488e505aa0ad5af6386d15db89f3ed3c0..f109f2dcc664ac96835d9ae5967bf67e0b9a8164 100644 |
| --- a/chrome/browser/net/http_intercept_job_factory.cc |
| +++ b/net/url_request/protocol_intercept_job_factory.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/net/http_intercept_job_factory.h" |
| +#include "net/url_request/protocol_intercept_job_factory.h" |
| #include "base/stl_util.h" |
| #include "googleurl/src/gurl.h" |
| @@ -16,43 +16,47 @@ namespace net { |
| const char* kHttpScheme = "http"; |
|
erikwright (departed)
2012/11/27 05:54:05
These are no longer used here, right?
pauljensen
2012/11/30 21:02:34
Done.
|
| const char* kHttpsScheme = "https"; |
| -HttpInterceptJobFactory::HttpInterceptJobFactory( |
| - const URLRequestJobFactory* job_factory, |
| +ProtocolInterceptJobFactory::ProtocolInterceptJobFactory( |
| + scoped_ptr<URLRequestJobFactory> job_factory, |
| + const char* scheme, |
| ProtocolHandler* protocol_handler) |
| - : job_factory_(job_factory), |
| + : scheme_(scheme), |
| + job_factory_(job_factory.Pass()), |
| protocol_handler_(protocol_handler) { |
| } |
| -HttpInterceptJobFactory::~HttpInterceptJobFactory() {} |
| +ProtocolInterceptJobFactory::~ProtocolInterceptJobFactory() {} |
| -bool HttpInterceptJobFactory::SetProtocolHandler( |
| +bool ProtocolInterceptJobFactory::SetProtocolHandler( |
| const std::string& scheme, ProtocolHandler* protocol_handler) { |
| - NOTREACHED(); |
| - return false; |
| + return job_factory_->SetProtocolHandler(scheme, protocol_handler); |
|
erikwright (departed)
2012/11/27 05:54:05
I'm not thrilled about this, although I understand
|
| } |
| -void HttpInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { |
| - // Interceptor addition is not allowed. |
| - NOTREACHED(); |
| +void ProtocolInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { |
| + return job_factory_->AddInterceptor(interceptor); |
| } |
| -URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithInterceptor( |
| +URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithInterceptor( |
| URLRequest* request, NetworkDelegate* network_delegate) const { |
| return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); |
| } |
| -URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithProtocolHandler( |
| +URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithProtocolHandler( |
| const std::string& scheme, |
| URLRequest* request, |
| NetworkDelegate* network_delegate) const { |
| DCHECK(CalledOnValidThread()); |
| - if (scheme == kHttpScheme || scheme == kHttpsScheme) |
| - return protocol_handler_->MaybeCreateJob(request, network_delegate); |
| + if (!scheme_ || scheme == scheme_) { |
| + URLRequestJob* job = protocol_handler_->MaybeCreateJob(request, |
| + network_delegate); |
| + if (job) |
| + return job; |
| + } |
| return job_factory_->MaybeCreateJobWithProtocolHandler( |
| scheme, request, network_delegate); |
| } |
| -URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( |
| +URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptRedirect( |
| const GURL& location, |
| URLRequest* request, |
| NetworkDelegate* network_delegate) const { |
| @@ -60,21 +64,21 @@ URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( |
| location, request, network_delegate); |
| } |
| -URLRequestJob* HttpInterceptJobFactory::MaybeInterceptResponse( |
| +URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptResponse( |
| URLRequest* request, NetworkDelegate* network_delegate) const { |
| return job_factory_->MaybeInterceptResponse(request, network_delegate); |
| } |
| -bool HttpInterceptJobFactory::IsHandledProtocol( |
| +bool ProtocolInterceptJobFactory::IsHandledProtocol( |
| const std::string& scheme) const { |
| DCHECK(CalledOnValidThread()); |
| - if (scheme == kHttpScheme || scheme == kHttpsScheme) |
| + if (scheme_ && scheme == scheme_) |
| return true; |
| return job_factory_->IsHandledProtocol(scheme); |
| } |
| -bool HttpInterceptJobFactory::IsHandledURL(const GURL& url) const { |
| - if (url.scheme() == kHttpScheme || url.scheme() == kHttpsScheme) |
| +bool ProtocolInterceptJobFactory::IsHandledURL(const GURL& url) const { |
| + if (scheme_ && url.scheme() == scheme_) |
| return true; |
| return job_factory_->IsHandledURL(url); |
| } |