| 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.h" | 5 #include "net/url_request/url_request_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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 void URLRequestJobFactory::AddInterceptor(Interceptor* interceptor) { | 51 void URLRequestJobFactory::AddInterceptor(Interceptor* interceptor) { |
| 52 DCHECK(CalledOnValidThread()); | 52 DCHECK(CalledOnValidThread()); |
| 53 CHECK(interceptor); | 53 CHECK(interceptor); |
| 54 | 54 |
| 55 interceptors_.push_back(interceptor); | 55 interceptors_.push_back(interceptor); |
| 56 } | 56 } |
| 57 | 57 |
| 58 URLRequestJob* URLRequestJobFactory::MaybeCreateJobWithInterceptor( | 58 URLRequestJob* URLRequestJobFactory::MaybeCreateJobWithInterceptor( |
| 59 URLRequest* request) const { | 59 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 60 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
| 61 URLRequestJob* job = NULL; | 61 URLRequestJob* job = NULL; |
| 62 | 62 |
| 63 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { | 63 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { |
| 64 InterceptorList::const_iterator i; | 64 InterceptorList::const_iterator i; |
| 65 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 65 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
| 66 job = (*i)->MaybeIntercept(request); | 66 job = (*i)->MaybeIntercept(request, network_delegate); |
| 67 if (job) | 67 if (job) |
| 68 return job; | 68 return job; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 return NULL; | 71 return NULL; |
| 72 } | 72 } |
| 73 | 73 |
| 74 URLRequestJob* URLRequestJobFactory::MaybeCreateJobWithProtocolHandler( | 74 URLRequestJob* URLRequestJobFactory::MaybeCreateJobWithProtocolHandler( |
| 75 const std::string& scheme, | 75 const std::string& scheme, |
| 76 URLRequest* request) const { | 76 URLRequest* request, |
| 77 NetworkDelegate* network_delegate) const { |
| 77 DCHECK(CalledOnValidThread()); | 78 DCHECK(CalledOnValidThread()); |
| 78 ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); | 79 ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); |
| 79 if (it == protocol_handler_map_.end()) | 80 if (it == protocol_handler_map_.end()) |
| 80 return NULL; | 81 return NULL; |
| 81 return it->second->MaybeCreateJob(request); | 82 return it->second->MaybeCreateJob(request, network_delegate); |
| 82 } | 83 } |
| 83 | 84 |
| 84 URLRequestJob* URLRequestJobFactory::MaybeInterceptRedirect( | 85 URLRequestJob* URLRequestJobFactory::MaybeInterceptRedirect( |
| 85 const GURL& location, | 86 const GURL& location, |
| 86 URLRequest* request) const { | 87 URLRequest* request) const { |
| 87 DCHECK(CalledOnValidThread()); | 88 DCHECK(CalledOnValidThread()); |
| 88 URLRequestJob* job = NULL; | 89 URLRequestJob* job = NULL; |
| 89 | 90 |
| 90 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { | 91 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { |
| 91 InterceptorList::const_iterator i; | 92 InterceptorList::const_iterator i; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 bool URLRequestJobFactory::IsHandledURL(const GURL& url) const { | 129 bool URLRequestJobFactory::IsHandledURL(const GURL& url) const { |
| 129 if (!url.is_valid()) { | 130 if (!url.is_valid()) { |
| 130 // We handle error cases. | 131 // We handle error cases. |
| 131 return true; | 132 return true; |
| 132 } | 133 } |
| 133 return IsHandledProtocol(url.scheme()); | 134 return IsHandledProtocol(url.scheme()); |
| 134 } | 135 } |
| 135 | 136 |
| 136 } // namespace net | 137 } // namespace net |
| OLD | NEW |