| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ | |
| 6 #define NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "net/base/net_export.h" | |
| 14 #include "net/url_request/url_request_job_factory.h" | |
| 15 | |
| 16 class GURL; | |
| 17 | |
| 18 namespace net { | |
| 19 | |
| 20 class URLRequest; | |
| 21 class URLRequestJob; | |
| 22 class URLRequestInterceptor; | |
| 23 | |
| 24 // This class acts as a wrapper for URLRequestJobFactory. The | |
| 25 // URLRequestInteceptor is given the option of creating a URLRequestJob for each | |
| 26 // URLRequest. If the interceptor does not create a job, the URLRequest is | |
| 27 // forwarded to the wrapped URLRequestJobFactory instead. | |
| 28 // | |
| 29 // This class is only intended for use in intercepting requests before they | |
| 30 // are passed on to their default ProtocolHandler. Each supported scheme should | |
| 31 // have its own ProtocolHandler. | |
| 32 class NET_EXPORT URLRequestInterceptingJobFactory | |
| 33 : public URLRequestJobFactory { | |
| 34 public: | |
| 35 URLRequestInterceptingJobFactory( | |
| 36 scoped_ptr<URLRequestJobFactory> job_factory, | |
| 37 scoped_ptr<URLRequestInterceptor> interceptor); | |
| 38 ~URLRequestInterceptingJobFactory() override; | |
| 39 | |
| 40 // URLRequestJobFactory implementation | |
| 41 URLRequestJob* MaybeCreateJobWithProtocolHandler( | |
| 42 const std::string& scheme, | |
| 43 URLRequest* request, | |
| 44 NetworkDelegate* network_delegate) const override; | |
| 45 | |
| 46 URLRequestJob* MaybeInterceptRedirect( | |
| 47 URLRequest* request, | |
| 48 NetworkDelegate* network_delegate, | |
| 49 const GURL& location) const override; | |
| 50 | |
| 51 URLRequestJob* MaybeInterceptResponse( | |
| 52 URLRequest* request, | |
| 53 NetworkDelegate* network_delegate) const override; | |
| 54 | |
| 55 bool IsHandledProtocol(const std::string& scheme) const override; | |
| 56 bool IsHandledURL(const GURL& url) const override; | |
| 57 bool IsSafeRedirectTarget(const GURL& location) const override; | |
| 58 | |
| 59 private: | |
| 60 scoped_ptr<URLRequestJobFactory> job_factory_; | |
| 61 scoped_ptr<URLRequestInterceptor> interceptor_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptingJobFactory); | |
| 64 }; | |
| 65 | |
| 66 } // namespace net | |
| 67 | |
| 68 #endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ | |
| OLD | NEW |