| 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 "net/url_request/url_request_job_factory_impl.h" | 5 #include "net/url_request/url_request_job_factory_impl.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
| 9 #include "net/url_request/url_request_interceptor.h" | 9 #include "net/url_request/url_request_interceptor.h" |
| 10 #include "net/url_request/url_request_job_manager.h" | 10 #include "net/url_request/url_request_job_manager.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 if (!protocol_handler) { | 30 if (!protocol_handler) { |
| 31 ProtocolHandlerMap::iterator it = protocol_handler_map_.find(scheme); | 31 ProtocolHandlerMap::iterator it = protocol_handler_map_.find(scheme); |
| 32 if (it == protocol_handler_map_.end()) | 32 if (it == protocol_handler_map_.end()) |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 protocol_handler_map_.erase(it); | 35 protocol_handler_map_.erase(it); |
| 36 return true; | 36 return true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 if (ContainsKey(protocol_handler_map_, scheme)) | 39 if (base::ContainsKey(protocol_handler_map_, scheme)) |
| 40 return false; | 40 return false; |
| 41 protocol_handler_map_[scheme] = std::move(protocol_handler); | 41 protocol_handler_map_[scheme] = std::move(protocol_handler); |
| 42 return true; | 42 return true; |
| 43 } | 43 } |
| 44 | 44 |
| 45 URLRequestJob* URLRequestJobFactoryImpl::MaybeCreateJobWithProtocolHandler( | 45 URLRequestJob* URLRequestJobFactoryImpl::MaybeCreateJobWithProtocolHandler( |
| 46 const std::string& scheme, | 46 const std::string& scheme, |
| 47 URLRequest* request, | 47 URLRequest* request, |
| 48 NetworkDelegate* network_delegate) const { | 48 NetworkDelegate* network_delegate) const { |
| 49 DCHECK(CalledOnValidThread()); | 49 DCHECK(CalledOnValidThread()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 URLRequestJob* URLRequestJobFactoryImpl::MaybeInterceptResponse( | 70 URLRequestJob* URLRequestJobFactoryImpl::MaybeInterceptResponse( |
| 71 URLRequest* request, | 71 URLRequest* request, |
| 72 NetworkDelegate* network_delegate) const { | 72 NetworkDelegate* network_delegate) const { |
| 73 return nullptr; | 73 return nullptr; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool URLRequestJobFactoryImpl::IsHandledProtocol( | 76 bool URLRequestJobFactoryImpl::IsHandledProtocol( |
| 77 const std::string& scheme) const { | 77 const std::string& scheme) const { |
| 78 DCHECK(CalledOnValidThread()); | 78 DCHECK(CalledOnValidThread()); |
| 79 return ContainsKey(protocol_handler_map_, scheme) || | 79 return base::ContainsKey(protocol_handler_map_, scheme) || |
| 80 URLRequestJobManager::GetInstance()->SupportsScheme(scheme); | 80 URLRequestJobManager::GetInstance()->SupportsScheme(scheme); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool URLRequestJobFactoryImpl::IsHandledURL(const GURL& url) const { | 83 bool URLRequestJobFactoryImpl::IsHandledURL(const GURL& url) const { |
| 84 if (!url.is_valid()) { | 84 if (!url.is_valid()) { |
| 85 // We handle error cases. | 85 // We handle error cases. |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 return IsHandledProtocol(url.scheme()); | 88 return IsHandledProtocol(url.scheme()); |
| 89 } | 89 } |
| 90 | 90 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 // static | 107 // static |
| 108 void URLRequestJobFactoryImpl::SetInterceptorForTesting( | 108 void URLRequestJobFactoryImpl::SetInterceptorForTesting( |
| 109 URLRequestInterceptor* interceptor) { | 109 URLRequestInterceptor* interceptor) { |
| 110 DCHECK(!interceptor || !g_interceptor_for_testing); | 110 DCHECK(!interceptor || !g_interceptor_for_testing); |
| 111 | 111 |
| 112 g_interceptor_for_testing = interceptor; | 112 g_interceptor_for_testing = interceptor; |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace net | 115 } // namespace net |
| OLD | NEW |