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 "net/url_request/url_request_job_manager.h" | 5 #include "net/url_request/url_request_job_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 | 115 |
116 const URLRequestJobFactory* job_factory = NULL; | 116 const URLRequestJobFactory* job_factory = NULL; |
117 job_factory = request->context()->job_factory(); | 117 job_factory = request->context()->job_factory(); |
118 | 118 |
119 const std::string& scheme = request->url().scheme(); // already lowercase | 119 const std::string& scheme = request->url().scheme(); // already lowercase |
120 if (!job_factory->IsHandledProtocol(scheme)) | 120 if (!job_factory->IsHandledProtocol(scheme)) |
121 return NULL; | 121 return NULL; |
122 | 122 |
123 URLRequestJob* job = | |
124 request->context()->job_factory()->MaybeInterceptRedirect( | |
125 request, network_delegate, location); | |
126 if (job) | |
127 return job; | |
128 | |
123 InterceptorList::const_iterator i; | 129 InterceptorList::const_iterator i; |
124 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 130 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
125 URLRequestJob* job = (*i)->MaybeInterceptRedirect(request, | 131 job = (*i)->MaybeInterceptRedirect(request, |
126 network_delegate, | 132 network_delegate, |
127 location); | 133 location); |
128 if (job) | 134 if (job) |
129 return job; | 135 return job; |
130 } | 136 } |
131 return NULL; | 137 return NULL; |
132 } | 138 } |
133 | 139 |
134 URLRequestJob* URLRequestJobManager::MaybeInterceptResponse( | 140 URLRequestJob* URLRequestJobManager::MaybeInterceptResponse( |
135 URLRequest* request, NetworkDelegate* network_delegate) const { | 141 URLRequest* request, NetworkDelegate* network_delegate) const { |
136 DCHECK(IsAllowedThread()); | 142 DCHECK(IsAllowedThread()); |
137 if (!request->url().is_valid() || | 143 if (!request->url().is_valid() || |
138 request->load_flags() & LOAD_DISABLE_INTERCEPT || | 144 request->load_flags() & LOAD_DISABLE_INTERCEPT || |
139 request->status().status() == URLRequestStatus::CANCELED) { | 145 request->status().status() == URLRequestStatus::CANCELED) { |
140 return NULL; | 146 return NULL; |
141 } | 147 } |
142 | 148 |
143 const URLRequestJobFactory* job_factory = NULL; | 149 const URLRequestJobFactory* job_factory = NULL; |
144 job_factory = request->context()->job_factory(); | 150 job_factory = request->context()->job_factory(); |
145 | 151 |
146 const std::string& scheme = request->url().scheme(); // already lowercase | 152 const std::string& scheme = request->url().scheme(); // already lowercase |
147 if (!job_factory->IsHandledProtocol(scheme)) | 153 if (!job_factory->IsHandledProtocol(scheme)) |
148 return NULL; | 154 return NULL; |
149 | 155 |
156 URLRequestJob* job = | |
157 request->context()->job_factory()->MaybeInterceptResponse( | |
158 request, network_delegate); | |
michaeln
2014/11/06 21:07:46
Are you intentionally reversing the order the old
bengr
2014/11/06 23:58:01
Done.
| |
159 if (job) | |
160 return job; | |
161 | |
150 InterceptorList::const_iterator i; | 162 InterceptorList::const_iterator i; |
151 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 163 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
152 URLRequestJob* job = (*i)->MaybeInterceptResponse(request, | 164 job = (*i)->MaybeInterceptResponse(request, |
153 network_delegate); | 165 network_delegate); |
154 if (job) | 166 if (job) |
155 return job; | 167 return job; |
156 } | 168 } |
157 return NULL; | 169 return NULL; |
158 } | 170 } |
159 | 171 |
160 // static | 172 // static |
161 bool URLRequestJobManager::SupportsScheme(const std::string& scheme) { | 173 bool URLRequestJobManager::SupportsScheme(const std::string& scheme) { |
162 for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) { | 174 for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) { |
163 if (LowerCaseEqualsASCII(scheme, kBuiltinFactories[i].scheme)) | 175 if (LowerCaseEqualsASCII(scheme, kBuiltinFactories[i].scheme)) |
(...skipping 27 matching lines...) Expand all Loading... | |
191 } | 203 } |
192 | 204 |
193 URLRequestJobManager::URLRequestJobManager() | 205 URLRequestJobManager::URLRequestJobManager() |
194 : allowed_thread_(0), | 206 : allowed_thread_(0), |
195 allowed_thread_initialized_(false) { | 207 allowed_thread_initialized_(false) { |
196 } | 208 } |
197 | 209 |
198 URLRequestJobManager::~URLRequestJobManager() {} | 210 URLRequestJobManager::~URLRequestJobManager() {} |
199 | 211 |
200 } // namespace net | 212 } // namespace net |
OLD | NEW |