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

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: some cleanup 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 18 const char* scheme,
19 HttpInterceptJobFactory::HttpInterceptJobFactory(
20 const URLRequestJobFactory* job_factory,
21 ProtocolHandler* protocol_handler) 19 ProtocolHandler* protocol_handler)
22 : job_factory_(job_factory), 20 : scheme_(scheme),
21 job_factory_(job_factory.Pass()),
23 protocol_handler_(protocol_handler) { 22 protocol_handler_(protocol_handler) {
24 } 23 }
25 24
26 HttpInterceptJobFactory::~HttpInterceptJobFactory() {} 25 ProtocolInterceptJobFactory::~ProtocolInterceptJobFactory() {}
27 26
28 bool HttpInterceptJobFactory::SetProtocolHandler( 27 bool ProtocolInterceptJobFactory::SetProtocolHandler(
29 const std::string& scheme, ProtocolHandler* protocol_handler) { 28 const std::string& scheme, ProtocolHandler* protocol_handler) {
30 NOTREACHED(); 29 return job_factory_->SetProtocolHandler(scheme, protocol_handler);
31 return false;
32 } 30 }
33 31
34 void HttpInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { 32 void ProtocolInterceptJobFactory::AddInterceptor(Interceptor* interceptor) {
35 // Interceptor addition is not allowed. 33 return job_factory_->AddInterceptor(interceptor);
36 NOTREACHED();
37 } 34 }
38 35
39 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithInterceptor( 36 URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithInterceptor(
40 URLRequest* request, NetworkDelegate* network_delegate) const { 37 URLRequest* request, NetworkDelegate* network_delegate) const {
41 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); 38 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate);
42 } 39 }
43 40
44 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithProtocolHandler( 41 URLRequestJob* ProtocolInterceptJobFactory::MaybeCreateJobWithProtocolHandler(
45 const std::string& scheme, 42 const std::string& scheme,
46 URLRequest* request, 43 URLRequest* request,
47 NetworkDelegate* network_delegate) const { 44 NetworkDelegate* network_delegate) const {
48 DCHECK(CalledOnValidThread()); 45 DCHECK(CalledOnValidThread());
49 if (scheme == kHttpScheme || scheme == kHttpsScheme) 46 if (!scheme_ || scheme == scheme_) {
50 return protocol_handler_->MaybeCreateJob(request, network_delegate); 47 URLRequestJob* job = protocol_handler_->MaybeCreateJob(request,
48 network_delegate);
49 if (job)
50 return job;
51 }
51 return job_factory_->MaybeCreateJobWithProtocolHandler( 52 return job_factory_->MaybeCreateJobWithProtocolHandler(
52 scheme, request, network_delegate); 53 scheme, request, network_delegate);
53 } 54 }
54 55
55 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( 56 URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptRedirect(
56 const GURL& location, 57 const GURL& location,
57 URLRequest* request, 58 URLRequest* request,
58 NetworkDelegate* network_delegate) const { 59 NetworkDelegate* network_delegate) const {
59 return job_factory_->MaybeInterceptRedirect( 60 return job_factory_->MaybeInterceptRedirect(
60 location, request, network_delegate); 61 location, request, network_delegate);
61 } 62 }
62 63
63 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptResponse( 64 URLRequestJob* ProtocolInterceptJobFactory::MaybeInterceptResponse(
64 URLRequest* request, NetworkDelegate* network_delegate) const { 65 URLRequest* request, NetworkDelegate* network_delegate) const {
65 return job_factory_->MaybeInterceptResponse(request, network_delegate); 66 return job_factory_->MaybeInterceptResponse(request, network_delegate);
66 } 67 }
67 68
68 bool HttpInterceptJobFactory::IsHandledProtocol( 69 bool ProtocolInterceptJobFactory::IsHandledProtocol(
69 const std::string& scheme) const { 70 const std::string& scheme) const {
70 DCHECK(CalledOnValidThread());
71 if (scheme == kHttpScheme || scheme == kHttpsScheme)
72 return true;
73 return job_factory_->IsHandledProtocol(scheme); 71 return job_factory_->IsHandledProtocol(scheme);
74 } 72 }
75 73
76 bool HttpInterceptJobFactory::IsHandledURL(const GURL& url) const { 74 bool ProtocolInterceptJobFactory::IsHandledURL(const GURL& url) const {
77 if (url.scheme() == kHttpScheme || url.scheme() == kHttpsScheme)
78 return true;
79 return job_factory_->IsHandledURL(url); 75 return job_factory_->IsHandledURL(url);
80 } 76 }
81 77
82 } // namespace net 78 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698