Chromium Code Reviews| 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 #ifndef NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 // URLRequestInteceptor is given the option of creating a URLRequestJob for each | 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 | 26 // URLRequest. If the interceptor does not create a job, the URLRequest is |
| 27 // forwarded to the wrapped URLRequestJobFactory instead. | 27 // forwarded to the wrapped URLRequestJobFactory instead. |
| 28 // | 28 // |
| 29 // This class is only intended for use in intercepting requests before they | 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 | 30 // are passed on to their default ProtocolHandler. Each supported scheme should |
| 31 // have its own ProtocolHandler. | 31 // have its own ProtocolHandler. |
| 32 class NET_EXPORT URLRequestInterceptingJobFactory | 32 class NET_EXPORT URLRequestInterceptingJobFactory |
| 33 : public URLRequestJobFactory { | 33 : public URLRequestJobFactory { |
| 34 public: | 34 public: |
| 35 // Takes ownership of |job_factory| and |interceptor|. | |
| 35 URLRequestInterceptingJobFactory( | 36 URLRequestInterceptingJobFactory( |
| 36 std::unique_ptr<URLRequestJobFactory> job_factory, | 37 std::unique_ptr<URLRequestJobFactory> job_factory, |
| 37 std::unique_ptr<URLRequestInterceptor> interceptor); | 38 std::unique_ptr<URLRequestInterceptor> interceptor); |
| 39 // Does not take ownership of |job_factory| and |interceptor|. | |
| 40 URLRequestInterceptingJobFactory(URLRequestJobFactory* job_factory, | |
|
mef
2016/11/16 18:45:44
This is weird and I think deserves a comment WRT w
pauljensen
2016/11/18 18:12:10
Done.
| |
| 41 URLRequestInterceptor* interceptor); | |
| 38 ~URLRequestInterceptingJobFactory() override; | 42 ~URLRequestInterceptingJobFactory() override; |
| 39 | 43 |
| 40 // URLRequestJobFactory implementation | 44 // URLRequestJobFactory implementation |
| 41 URLRequestJob* MaybeCreateJobWithProtocolHandler( | 45 URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 42 const std::string& scheme, | 46 const std::string& scheme, |
| 43 URLRequest* request, | 47 URLRequest* request, |
| 44 NetworkDelegate* network_delegate) const override; | 48 NetworkDelegate* network_delegate) const override; |
| 45 | 49 |
| 46 URLRequestJob* MaybeInterceptRedirect( | 50 URLRequestJob* MaybeInterceptRedirect( |
| 47 URLRequest* request, | 51 URLRequest* request, |
| 48 NetworkDelegate* network_delegate, | 52 NetworkDelegate* network_delegate, |
| 49 const GURL& location) const override; | 53 const GURL& location) const override; |
| 50 | 54 |
| 51 URLRequestJob* MaybeInterceptResponse( | 55 URLRequestJob* MaybeInterceptResponse( |
| 52 URLRequest* request, | 56 URLRequest* request, |
| 53 NetworkDelegate* network_delegate) const override; | 57 NetworkDelegate* network_delegate) const override; |
| 54 | 58 |
| 55 bool IsHandledProtocol(const std::string& scheme) const override; | 59 bool IsHandledProtocol(const std::string& scheme) const override; |
| 56 bool IsHandledURL(const GURL& url) const override; | 60 bool IsHandledURL(const GURL& url) const override; |
| 57 bool IsSafeRedirectTarget(const GURL& location) const override; | 61 bool IsSafeRedirectTarget(const GURL& location) const override; |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 std::unique_ptr<URLRequestJobFactory> job_factory_; | 64 // |owning_| indicates if this object owns |job_factory_| and |interceptor_|. |
| 61 std::unique_ptr<URLRequestInterceptor> interceptor_; | 65 bool owning_; |
| 66 URLRequestJobFactory* job_factory_; | |
| 67 URLRequestInterceptor* interceptor_; | |
| 62 | 68 |
| 63 DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptingJobFactory); | 69 DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptingJobFactory); |
| 64 }; | 70 }; |
| 65 | 71 |
| 66 } // namespace net | 72 } // namespace net |
| 67 | 73 |
| 68 #endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ | 74 #endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_ |
| OLD | NEW |