Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/net/http_intercept_job_factory.h" | 5 #include "net/url_request/protocol_intercept_job_factory.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
| 10 #include "net/url_request/url_request_job_manager.h" | 10 #include "net/url_request/url_request_job_manager.h" |
| 11 | 11 |
| 12 class GURL; | 12 class GURL; |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 const char* kHttpScheme = "http"; | 16 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.
| |
| 17 const char* kHttpsScheme = "https"; | 17 const char* kHttpsScheme = "https"; |
| 18 | 18 |
| 19 HttpInterceptJobFactory::HttpInterceptJobFactory( | 19 ProtocolInterceptJobFactory::ProtocolInterceptJobFactory( |
| 20 const URLRequestJobFactory* job_factory, | 20 scoped_ptr<URLRequestJobFactory> job_factory, |
| 21 const char* scheme, | |
| 21 ProtocolHandler* protocol_handler) | 22 ProtocolHandler* protocol_handler) |
| 22 : job_factory_(job_factory), | 23 : scheme_(scheme), |
| 24 job_factory_(job_factory.Pass()), | |
| 23 protocol_handler_(protocol_handler) { | 25 protocol_handler_(protocol_handler) { |
| 24 } | 26 } |
| 25 | 27 |
| 26 HttpInterceptJobFactory::~HttpInterceptJobFactory() {} | 28 ProtocolInterceptJobFactory::~ProtocolInterceptJobFactory() {} |
| 27 | 29 |
| 28 bool HttpInterceptJobFactory::SetProtocolHandler( | 30 bool ProtocolInterceptJobFactory::SetProtocolHandler( |
| 29 const std::string& scheme, ProtocolHandler* protocol_handler) { | 31 const std::string& scheme, ProtocolHandler* protocol_handler) { |
| 30 NOTREACHED(); | 32 return job_factory_->SetProtocolHandler(scheme, protocol_handler); |
|
erikwright (departed)
2012/11/27 05:54:05
I'm not thrilled about this, although I understand
| |
| 31 return false; | |
| 32 } | 33 } |
| 33 | 34 |
| 34 void HttpInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { | 35 void ProtocolInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { |
| 35 // Interceptor addition is not allowed. | 36 return job_factory_->AddInterceptor(interceptor); |
| 36 NOTREACHED(); | |
| 37 } | 37 } |
| 38 | 38 |
| 39 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithInterceptor( | 39 URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithInterceptor( |
| 40 URLRequest* request, NetworkDelegate* network_delegate) const { | 40 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 41 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); | 41 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); |
| 42 } | 42 } |
| 43 | 43 |
| 44 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithProtocolHandler( | 44 URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithProtocolHandler( |
| 45 const std::string& scheme, | 45 const std::string& scheme, |
| 46 URLRequest* request, | 46 URLRequest* request, |
| 47 NetworkDelegate* network_delegate) const { | 47 NetworkDelegate* network_delegate) const { |
| 48 DCHECK(CalledOnValidThread()); | 48 DCHECK(CalledOnValidThread()); |
| 49 if (scheme == kHttpScheme || scheme == kHttpsScheme) | 49 if (!scheme_ || scheme == scheme_) { |
| 50 return protocol_handler_->MaybeCreateJob(request, network_delegate); | 50 URLRequestJob* job = protocol_handler_->MaybeCreateJob(request, |
| 51 network_delegate); | |
| 52 if (job) | |
| 53 return job; | |
| 54 } | |
| 51 return job_factory_->MaybeCreateJobWithProtocolHandler( | 55 return job_factory_->MaybeCreateJobWithProtocolHandler( |
| 52 scheme, request, network_delegate); | 56 scheme, request, network_delegate); |
| 53 } | 57 } |
| 54 | 58 |
| 55 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( | 59 URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptRedirect( |
| 56 const GURL& location, | 60 const GURL& location, |
| 57 URLRequest* request, | 61 URLRequest* request, |
| 58 NetworkDelegate* network_delegate) const { | 62 NetworkDelegate* network_delegate) const { |
| 59 return job_factory_->MaybeInterceptRedirect( | 63 return job_factory_->MaybeInterceptRedirect( |
| 60 location, request, network_delegate); | 64 location, request, network_delegate); |
| 61 } | 65 } |
| 62 | 66 |
| 63 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptResponse( | 67 URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptResponse( |
| 64 URLRequest* request, NetworkDelegate* network_delegate) const { | 68 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 65 return job_factory_->MaybeInterceptResponse(request, network_delegate); | 69 return job_factory_->MaybeInterceptResponse(request, network_delegate); |
| 66 } | 70 } |
| 67 | 71 |
| 68 bool HttpInterceptJobFactory::IsHandledProtocol( | 72 bool ProtocolInterceptJobFactory::IsHandledProtocol( |
| 69 const std::string& scheme) const { | 73 const std::string& scheme) const { |
| 70 DCHECK(CalledOnValidThread()); | 74 DCHECK(CalledOnValidThread()); |
| 71 if (scheme == kHttpScheme || scheme == kHttpsScheme) | 75 if (scheme_ && scheme == scheme_) |
| 72 return true; | 76 return true; |
| 73 return job_factory_->IsHandledProtocol(scheme); | 77 return job_factory_->IsHandledProtocol(scheme); |
| 74 } | 78 } |
| 75 | 79 |
| 76 bool HttpInterceptJobFactory::IsHandledURL(const GURL& url) const { | 80 bool ProtocolInterceptJobFactory::IsHandledURL(const GURL& url) const { |
| 77 if (url.scheme() == kHttpScheme || url.scheme() == kHttpsScheme) | 81 if (scheme_ && url.scheme() == scheme_) |
| 78 return true; | 82 return true; |
| 79 return job_factory_->IsHandledURL(url); | 83 return job_factory_->IsHandledURL(url); |
| 80 } | 84 } |
| 81 | 85 |
| 82 } // namespace net | 86 } // namespace net |
| OLD | NEW |