Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: net/url_request/url_request_job_manager.cc

Issue 12217095: Remove unused pieces of URLRequestJobFactory API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 request, network_delegate, ERR_UNKNOWN_URL_SCHEME); 72 request, network_delegate, ERR_UNKNOWN_URL_SCHEME);
73 } 73 }
74 74
75 // THREAD-SAFETY NOTICE: 75 // THREAD-SAFETY NOTICE:
76 // We do not need to acquire the lock here since we are only reading our 76 // We do not need to acquire the lock here since we are only reading our
77 // data structures. They should only be modified on the current thread. 77 // data structures. They should only be modified on the current thread.
78 78
79 // See if the request should be intercepted. 79 // See if the request should be intercepted.
80 // 80 //
81 81
82 if (job_factory) { 82 // TODO(pauljensen): Remove this when AppCacheInterceptor is a
83 URLRequestJob* job = job_factory->MaybeCreateJobWithInterceptor( 83 // ProtocolHandler, see crbug.com/161547.
84 request, network_delegate);
85 if (job)
86 return job;
87 }
88
89 // TODO(willchan): Remove this in favor of URLRequestJobFactory::Interceptor.
90 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { 84 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) {
91 InterceptorList::const_iterator i; 85 InterceptorList::const_iterator i;
92 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { 86 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) {
93 URLRequestJob* job = (*i)->MaybeIntercept(request, network_delegate); 87 URLRequestJob* job = (*i)->MaybeIntercept(request, network_delegate);
94 if (job) 88 if (job)
95 return job; 89 return job;
96 } 90 }
97 } 91 }
98 92
99 if (job_factory) { 93 if (job_factory) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 142
149 const std::string& scheme = request->url().scheme(); // already lowercase 143 const std::string& scheme = request->url().scheme(); // already lowercase
150 if (job_factory) { 144 if (job_factory) {
151 if (!job_factory->IsHandledProtocol(scheme)) { 145 if (!job_factory->IsHandledProtocol(scheme)) {
152 return NULL; 146 return NULL;
153 } 147 }
154 } else if (!SupportsScheme(scheme)) { 148 } else if (!SupportsScheme(scheme)) {
155 return NULL; 149 return NULL;
156 } 150 }
157 151
158 URLRequestJob* job = NULL;
159 if (job_factory)
160 job = job_factory->MaybeInterceptRedirect(
161 location, request, network_delegate);
162 if (job)
163 return job;
164
165 InterceptorList::const_iterator i; 152 InterceptorList::const_iterator i;
166 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { 153 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) {
167 job = (*i)->MaybeInterceptRedirect(request, network_delegate, location); 154 URLRequestJob* job = (*i)->MaybeInterceptRedirect(request,
155 network_delegate,
156 location);
168 if (job) 157 if (job)
169 return job; 158 return job;
170 } 159 }
171 return NULL; 160 return NULL;
172 } 161 }
173 162
174 URLRequestJob* URLRequestJobManager::MaybeInterceptResponse( 163 URLRequestJob* URLRequestJobManager::MaybeInterceptResponse(
175 URLRequest* request, NetworkDelegate* network_delegate) const { 164 URLRequest* request, NetworkDelegate* network_delegate) const {
176 DCHECK(IsAllowedThread()); 165 DCHECK(IsAllowedThread());
177 if (!request->url().is_valid() || 166 if (!request->url().is_valid() ||
178 request->load_flags() & LOAD_DISABLE_INTERCEPT || 167 request->load_flags() & LOAD_DISABLE_INTERCEPT ||
179 request->status().status() == URLRequestStatus::CANCELED) { 168 request->status().status() == URLRequestStatus::CANCELED) {
180 return NULL; 169 return NULL;
181 } 170 }
182 171
183 const URLRequestJobFactory* job_factory = NULL; 172 const URLRequestJobFactory* job_factory = NULL;
184 job_factory = request->context()->job_factory(); 173 job_factory = request->context()->job_factory();
185 174
186 const std::string& scheme = request->url().scheme(); // already lowercase 175 const std::string& scheme = request->url().scheme(); // already lowercase
187 if (job_factory) { 176 if (job_factory) {
188 if (!job_factory->IsHandledProtocol(scheme)) { 177 if (!job_factory->IsHandledProtocol(scheme)) {
189 return NULL; 178 return NULL;
190 } 179 }
191 } else if (!SupportsScheme(scheme)) { 180 } else if (!SupportsScheme(scheme)) {
192 return NULL; 181 return NULL;
193 } 182 }
194 183
195 URLRequestJob* job = NULL;
196 if (job_factory)
197 job = job_factory->MaybeInterceptResponse(request, network_delegate);
198 if (job)
199 return job;
200
201 InterceptorList::const_iterator i; 184 InterceptorList::const_iterator i;
202 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { 185 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) {
203 job = (*i)->MaybeInterceptResponse(request, network_delegate); 186 URLRequestJob* job = (*i)->MaybeInterceptResponse(request,
187 network_delegate);
204 if (job) 188 if (job)
205 return job; 189 return job;
206 } 190 }
207 return NULL; 191 return NULL;
208 } 192 }
209 193
210 bool URLRequestJobManager::SupportsScheme(const std::string& scheme) const { 194 bool URLRequestJobManager::SupportsScheme(const std::string& scheme) const {
211 // The set of registered factories may change on another thread. 195 // The set of registered factories may change on another thread.
212 { 196 {
213 base::AutoLock locked(lock_); 197 base::AutoLock locked(lock_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 252 }
269 253
270 URLRequestJobManager::URLRequestJobManager() 254 URLRequestJobManager::URLRequestJobManager()
271 : allowed_thread_(0), 255 : allowed_thread_(0),
272 allowed_thread_initialized_(false) { 256 allowed_thread_initialized_(false) {
273 } 257 }
274 258
275 URLRequestJobManager::~URLRequestJobManager() {} 259 URLRequestJobManager::~URLRequestJobManager() {}
276 260
277 } // namespace net 261 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698