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

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

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address erikwright's third round of comments Created 8 years 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) 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 "chrome/browser/net/http_intercept_job_factory.h" 5 #include "net/url_request/protocol_intercept_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"
11 11
12 class GURL; 12 class GURL;
13 13
14 namespace net { 14 namespace net {
15 15
16 const char* kHttpScheme = "http"; 16 ProtocolInterceptJobFactory::ProtocolInterceptJobFactory(
17 const char* kHttpsScheme = "https"; 17 scoped_ptr<URLRequestJobFactory> job_factory,
18
19 HttpInterceptJobFactory::HttpInterceptJobFactory(
20 const URLRequestJobFactory* job_factory,
21 ProtocolHandler* protocol_handler) 18 ProtocolHandler* protocol_handler)
22 : job_factory_(job_factory), 19 : job_factory_(job_factory.Pass()),
23 protocol_handler_(protocol_handler) { 20 protocol_handler_(protocol_handler) {
24 } 21 }
25 22
26 HttpInterceptJobFactory::~HttpInterceptJobFactory() {} 23 ProtocolInterceptJobFactory::~ProtocolInterceptJobFactory() {}
27 24
28 bool HttpInterceptJobFactory::SetProtocolHandler( 25 bool ProtocolInterceptJobFactory::SetProtocolHandler(
29 const std::string& scheme, ProtocolHandler* protocol_handler) { 26 const std::string& scheme, ProtocolHandler* protocol_handler) {
30 NOTREACHED(); 27 return job_factory_->SetProtocolHandler(scheme, protocol_handler);
31 return false;
32 } 28 }
33 29
34 void HttpInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { 30 void ProtocolInterceptJobFactory::AddInterceptor(Interceptor* interceptor) {
35 // Interceptor addition is not allowed. 31 return job_factory_->AddInterceptor(interceptor);
36 NOTREACHED();
37 } 32 }
38 33
39 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithInterceptor( 34 URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithInterceptor(
40 URLRequest* request, NetworkDelegate* network_delegate) const { 35 URLRequest* request, NetworkDelegate* network_delegate) const {
41 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); 36 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate);
42 } 37 }
43 38
44 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithProtocolHandler( 39 URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithProtocolHandler(
45 const std::string& scheme, 40 const std::string& scheme,
46 URLRequest* request, 41 URLRequest* request,
47 NetworkDelegate* network_delegate) const { 42 NetworkDelegate* network_delegate) const {
48 DCHECK(CalledOnValidThread()); 43 DCHECK(CalledOnValidThread());
49 if (scheme == kHttpScheme || scheme == kHttpsScheme) 44 URLRequestJob* job = protocol_handler_->MaybeCreateJob(request,
50 return protocol_handler_->MaybeCreateJob(request, network_delegate); 45 network_delegate);
46 if (job)
47 return job;
51 return job_factory_->MaybeCreateJobWithProtocolHandler( 48 return job_factory_->MaybeCreateJobWithProtocolHandler(
52 scheme, request, network_delegate); 49 scheme, request, network_delegate);
53 } 50 }
54 51
55 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( 52 URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptRedirect(
56 const GURL& location, 53 const GURL& location,
57 URLRequest* request, 54 URLRequest* request,
58 NetworkDelegate* network_delegate) const { 55 NetworkDelegate* network_delegate) const {
59 return job_factory_->MaybeInterceptRedirect( 56 return job_factory_->MaybeInterceptRedirect(
60 location, request, network_delegate); 57 location, request, network_delegate);
61 } 58 }
62 59
63 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptResponse( 60 URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptResponse(
64 URLRequest* request, NetworkDelegate* network_delegate) const { 61 URLRequest* request, NetworkDelegate* network_delegate) const {
65 return job_factory_->MaybeInterceptResponse(request, network_delegate); 62 return job_factory_->MaybeInterceptResponse(request, network_delegate);
66 } 63 }
67 64
68 bool HttpInterceptJobFactory::IsHandledProtocol( 65 bool ProtocolInterceptJobFactory::IsHandledProtocol(
69 const std::string& scheme) const { 66 const std::string& scheme) const {
70 DCHECK(CalledOnValidThread());
71 if (scheme == kHttpScheme || scheme == kHttpsScheme)
72 return true;
73 return job_factory_->IsHandledProtocol(scheme); 67 return job_factory_->IsHandledProtocol(scheme);
74 } 68 }
75 69
76 bool HttpInterceptJobFactory::IsHandledURL(const GURL& url) const { 70 bool ProtocolInterceptJobFactory::IsHandledURL(const GURL& url) const {
77 if (url.scheme() == kHttpScheme || url.scheme() == kHttpsScheme)
78 return true;
79 return job_factory_->IsHandledURL(url); 71 return job_factory_->IsHandledURL(url);
80 } 72 }
81 73
82 } // namespace net 74 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698