1 // Copyright 2014 The Chromium Authors 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 "components/cronet/android/test/url_request_intercepting_job_factory.h" 6 7 #include <utility> 8 9 #include "base/check_op.h" 10 #include "base/memory/ptr_util.h" 11 #include "net/url_request/url_request_interceptor.h" 12 #include "net/url_request/url_request_job.h" 13 14 namespace cronet { 15 URLRequestInterceptingJobFactory(net::URLRequestJobFactory * job_factory,net::URLRequestInterceptor * interceptor)16URLRequestInterceptingJobFactory::URLRequestInterceptingJobFactory( 17 net::URLRequestJobFactory* job_factory, 18 net::URLRequestInterceptor* interceptor) 19 : job_factory_(job_factory), interceptor_(interceptor) {} 20 21 URLRequestInterceptingJobFactory::~URLRequestInterceptingJobFactory() = default; 22 CreateJob(net::URLRequest * request) const23std::unique_ptr<net::URLRequestJob> URLRequestInterceptingJobFactory::CreateJob( 24 net::URLRequest* request) const { 25 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 26 std::unique_ptr<net::URLRequestJob> job = 27 interceptor_->MaybeInterceptRequest(request); 28 if (job) 29 return job; 30 return job_factory_->CreateJob(request); 31 } 32 IsSafeRedirectTarget(const GURL & location) const33bool URLRequestInterceptingJobFactory::IsSafeRedirectTarget( 34 const GURL& location) const { 35 return job_factory_->IsSafeRedirectTarget(location); 36 } 37 38 } // namespace cronet 39