Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/url_request/http_intercept_job_factory.h" | |
| 6 | |
| 7 #include "base/stl_util.h" | |
| 8 #include "googleurl/src/gurl.h" | |
| 9 #include "net/base/load_flags.h" | |
| 10 #include "net/url_request/url_request_job_manager.h" | |
| 11 | |
| 12 class GURL; | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 const char* kHttpScheme = "http"; | |
| 17 const char* kHttpsScheme = "https"; | |
| 18 | |
| 19 HttpInterceptJobFactory::HttpInterceptJobFactory( | |
| 20 const URLRequestJobFactory* job_factory, | |
| 21 ProtocolHandler* protocol_handler) | |
| 22 : job_factory_(job_factory), | |
| 23 protocol_handler_(protocol_handler) { | |
| 24 } | |
| 25 | |
| 26 HttpInterceptJobFactory::~HttpInterceptJobFactory() {} | |
| 27 | |
| 28 bool HttpInterceptJobFactory::SetProtocolHandler( | |
| 29 const std::string& scheme, ProtocolHandler* protocol_handler) { | |
|
mmenke
2012/08/16 19:12:11
NOTREACHED()?
shalev
2012/08/22 19:10:11
Done.
| |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 void HttpInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { | |
| 34 // Interceptor addition is not allowed. | |
| 35 NOTREACHED(); | |
| 36 } | |
| 37 | |
| 38 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithInterceptor( | |
| 39 URLRequest* request) const { | |
| 40 return job_factory_->MaybeCreateJobWithInterceptor(request); | |
| 41 } | |
| 42 | |
| 43 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithProtocolHandler( | |
| 44 const std::string& scheme, URLRequest* request) const { | |
| 45 DCHECK(CalledOnValidThread()); | |
| 46 if (scheme == kHttpScheme || scheme == kHttpsScheme) | |
| 47 return protocol_handler_->MaybeCreateJob(request); | |
| 48 return job_factory_->MaybeCreateJobWithProtocolHandler(scheme, request); | |
| 49 } | |
| 50 | |
| 51 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( | |
| 52 const GURL& location, URLRequest* request) const { | |
| 53 return job_factory_->MaybeInterceptRedirect(location, request); | |
| 54 } | |
| 55 | |
| 56 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptResponse( | |
| 57 URLRequest* request) const { | |
| 58 return job_factory_->MaybeInterceptResponse(request); | |
| 59 } | |
| 60 | |
| 61 bool HttpInterceptJobFactory::IsHandledProtocol( | |
| 62 const std::string& scheme) const { | |
| 63 DCHECK(CalledOnValidThread()); | |
| 64 if (scheme == kHttpScheme || scheme == kHttpsScheme) | |
| 65 return true; | |
| 66 return job_factory_->IsHandledProtocol(scheme); | |
| 67 } | |
| 68 | |
| 69 bool HttpInterceptJobFactory::IsHandledURL(const GURL& url) const { | |
| 70 if (url.scheme() == kHttpScheme || url.scheme() == kHttpsScheme) | |
| 71 return true; | |
| 72 return job_factory_->IsHandledURL(url); | |
| 73 } | |
| 74 | |
| 75 } // namespace net | |
| OLD | NEW |