| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_intercepting_job_factory.h" | 5 #include "net/url_request/url_request_intercepting_job_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/url_request/url_request_interceptor.h" | 10 #include "net/url_request/url_request_interceptor.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 URLRequestInterceptingJobFactory::URLRequestInterceptingJobFactory( | 14 URLRequestInterceptingJobFactory::URLRequestInterceptingJobFactory( |
| 15 std::unique_ptr<URLRequestJobFactory> job_factory, | 15 std::unique_ptr<URLRequestJobFactory> job_factory, |
| 16 std::unique_ptr<URLRequestInterceptor> interceptor) | 16 std::unique_ptr<URLRequestInterceptor> interceptor) |
| 17 : job_factory_(std::move(job_factory)), | 17 : owning_(true), |
| 18 interceptor_(std::move(interceptor)) {} | 18 job_factory_(job_factory.release()), |
| 19 interceptor_(interceptor.release()) {} |
| 19 | 20 |
| 20 URLRequestInterceptingJobFactory::~URLRequestInterceptingJobFactory() {} | 21 URLRequestInterceptingJobFactory::URLRequestInterceptingJobFactory( |
| 22 URLRequestJobFactory* job_factory, |
| 23 URLRequestInterceptor* interceptor) |
| 24 : owning_(false), job_factory_(job_factory), interceptor_(interceptor) {} |
| 25 |
| 26 URLRequestInterceptingJobFactory::~URLRequestInterceptingJobFactory() { |
| 27 if (owning_) { |
| 28 delete job_factory_; |
| 29 delete interceptor_; |
| 30 } |
| 31 } |
| 21 | 32 |
| 22 URLRequestJob* URLRequestInterceptingJobFactory:: | 33 URLRequestJob* URLRequestInterceptingJobFactory:: |
| 23 MaybeCreateJobWithProtocolHandler( | 34 MaybeCreateJobWithProtocolHandler( |
| 24 const std::string& scheme, | 35 const std::string& scheme, |
| 25 URLRequest* request, | 36 URLRequest* request, |
| 26 NetworkDelegate* network_delegate) const { | 37 NetworkDelegate* network_delegate) const { |
| 27 DCHECK(CalledOnValidThread()); | 38 DCHECK(CalledOnValidThread()); |
| 28 URLRequestJob* job = interceptor_->MaybeInterceptRequest(request, | 39 URLRequestJob* job = interceptor_->MaybeInterceptRequest(request, |
| 29 network_delegate); | 40 network_delegate); |
| 30 if (job) | 41 if (job) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 bool URLRequestInterceptingJobFactory::IsHandledURL(const GURL& url) const { | 79 bool URLRequestInterceptingJobFactory::IsHandledURL(const GURL& url) const { |
| 69 return job_factory_->IsHandledURL(url); | 80 return job_factory_->IsHandledURL(url); |
| 70 } | 81 } |
| 71 | 82 |
| 72 bool URLRequestInterceptingJobFactory::IsSafeRedirectTarget( | 83 bool URLRequestInterceptingJobFactory::IsSafeRedirectTarget( |
| 73 const GURL& location) const { | 84 const GURL& location) const { |
| 74 return job_factory_->IsSafeRedirectTarget(location); | 85 return job_factory_->IsSafeRedirectTarget(location); |
| 75 } | 86 } |
| 76 | 87 |
| 77 } // namespace net | 88 } // namespace net |
| OLD | NEW |