Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/browser/net/aw_url_request_job_factory.h" | 5 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 6 | 6 |
| 7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
| 8 #include "net/url_request/url_request_error_job.h" | 8 #include "net/url_request/url_request_error_job.h" |
| 9 #include "net/url_request/url_request_job_factory_impl.h" | 9 #include "net/url_request/url_request_job_factory_impl.h" |
| 10 #include "net/url_request/url_request_job_manager.h" | 10 #include "net/url_request/url_request_job_manager.h" |
| 11 | 11 |
| 12 using net::NetworkDelegate; | 12 using net::NetworkDelegate; |
| 13 using net::URLRequest; | 13 using net::URLRequest; |
| 14 using net::URLRequestJob; | 14 using net::URLRequestJob; |
| 15 | 15 |
| 16 namespace android_webview { | 16 namespace android_webview { |
| 17 | 17 |
| 18 AwURLRequestJobFactory::AwURLRequestJobFactory() | 18 AwURLRequestJobFactory::AwURLRequestJobFactory() |
| 19 : next_factory_(new net::URLRequestJobFactoryImpl()) { | 19 : next_factory_(new net::URLRequestJobFactoryImpl()) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 AwURLRequestJobFactory::~AwURLRequestJobFactory() { | 22 AwURLRequestJobFactory::~AwURLRequestJobFactory() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool AwURLRequestJobFactory::IsHandledProtocol( | 25 bool AwURLRequestJobFactory::IsHandledProtocol( |
| 26 const std::string& scheme) const { | 26 const std::string& scheme) const { |
| 27 // This introduces a dependency on the URLRequestJobManager | 27 // This introduces a dependency on the URLRequestJobManager |
|
joth
2013/03/27 20:33:19
Making the change you have below means this commen
Yaron
2013/03/27 21:18:53
Indeed.
| |
| 28 // implementation. The assumption is that if true is returned from this | 28 // implementation. The assumption is that if true is returned from this |
| 29 // method it is still valid to return NULL from the | 29 // method it is still valid to return NULL from the |
| 30 // MaybeCreateJobWithProtocolHandler method and in that case the | 30 // MaybeCreateJobWithProtocolHandler method and in that case the |
| 31 // URLRequestJobManager will try and create the URLRequestJob by using the | 31 // URLRequestJobManager will try and create the URLRequestJob by using the |
| 32 // set of built in handlers. | 32 // set of built in handlers. |
| 33 return true; | 33 return true; |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool AwURLRequestJobFactory::IsHandledURL(const GURL& url) const { | 36 bool AwURLRequestJobFactory::IsHandledURL(const GURL& url) const { |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 URLRequestJob* AwURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( | 40 URLRequestJob* AwURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( |
| 41 const std::string& scheme, | 41 const std::string& scheme, |
| 42 URLRequest* request, | 42 URLRequest* request, |
| 43 NetworkDelegate* network_delegate) const { | 43 NetworkDelegate* network_delegate) const { |
| 44 URLRequestJob* job = next_factory_->MaybeCreateJobWithProtocolHandler( | 44 URLRequestJob* job = next_factory_->MaybeCreateJobWithProtocolHandler( |
| 45 scheme, request, network_delegate); | 45 scheme, request, network_delegate); |
| 46 | 46 |
| 47 if (job) | 47 if (job) |
| 48 return job; | 48 return job; |
| 49 | 49 |
| 50 // If the URLRequestJobManager supports the scheme NULL should be returned | 50 // If URLRequest supports the scheme NULL should be returned from this method. |
| 51 // from this method. In that case the built in handlers in | 51 // In that case the built in handlers will then be used to create the job. |
|
joth
2013/03/27 20:33:19
this comment add "see the ASSUMPTION in IsHandledP
Yaron
2013/03/27 21:18:53
Done.
| |
| 52 // URLRequestJobManager will then be used to create the job. | 52 if (net::URLRequest::IsHandledProtocol(scheme)) |
| 53 if (net::URLRequestJobManager::GetInstance()->SupportsScheme(scheme)) | |
| 54 return NULL; | 53 return NULL; |
| 55 | 54 |
| 56 return new net::URLRequestErrorJob( | 55 return new net::URLRequestErrorJob( |
| 57 request, network_delegate, net::ERR_UNKNOWN_URL_SCHEME); | 56 request, network_delegate, net::ERR_UNKNOWN_URL_SCHEME); |
| 58 } | 57 } |
| 59 | 58 |
| 60 bool AwURLRequestJobFactory::SetProtocolHandler( | 59 bool AwURLRequestJobFactory::SetProtocolHandler( |
| 61 const std::string& scheme, | 60 const std::string& scheme, |
| 62 ProtocolHandler* protocol_handler) { | 61 ProtocolHandler* protocol_handler) { |
| 63 return next_factory_->SetProtocolHandler(scheme, protocol_handler); | 62 return next_factory_->SetProtocolHandler(scheme, protocol_handler); |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace android_webview | 65 } // namespace android_webview |
| OLD | NEW |