Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_NET_HTTP_INTERCEPT_JOB_FACTORY_H_ | 5 #ifndef NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_ |
| 6 #define CHROME_BROWSER_NET_HTTP_INTERCEPT_JOB_FACTORY_H_ | 6 #define NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "net/base/net_export.h" | |
| 10 #include "net/url_request/url_request_job_factory.h" | 12 #include "net/url_request/url_request_job_factory.h" |
| 11 | 13 |
| 12 class GURL; | 14 class GURL; |
| 13 | 15 |
| 14 namespace net { | 16 namespace net { |
| 15 | 17 |
| 16 class URLRequest; | 18 class URLRequest; |
| 17 class URLRequestJob; | 19 class URLRequestJob; |
| 18 | 20 |
| 19 // This class acts as a wrapper for URLRequestJobFactory. It handles HTTP and | 21 // This class acts as a wrapper for URLRequestJobFactory. |protocol_handler_| is |
| 20 // HTTPS jobs using |protocol_handler_|, but forwards all other schemes to the | 22 // given the option of creating a URLRequestJob for each potential URLRequest. |
| 21 // old job factory to be handled there. | 23 // If |protocol_handler_| does not create a job (i.e. MaybeCreateJob() returns |
| 22 class HttpInterceptJobFactory : public URLRequestJobFactory { | 24 // NULL) the URLRequest is forwarded to the |job_factory_| to be handled there. |
| 25 class NET_EXPORT ProtocolInterceptJobFactory : public URLRequestJobFactory { | |
| 23 public: | 26 public: |
| 24 HttpInterceptJobFactory(const URLRequestJobFactory* job_factory, | 27 ProtocolInterceptJobFactory(scoped_ptr<URLRequestJobFactory> job_factory, |
| 25 ProtocolHandler* protocol_handler); | 28 ProtocolHandler* protocol_handler); |
|
mmenke
2012/12/11 17:22:38
Since we're taking ownership of protocol_handler j
| |
| 26 virtual ~HttpInterceptJobFactory(); | 29 virtual ~ProtocolInterceptJobFactory(); |
| 27 | 30 |
| 28 // URLRequestJobFactory implementation | 31 // URLRequestJobFactory implementation |
| 29 virtual bool SetProtocolHandler(const std::string& scheme, | 32 virtual bool SetProtocolHandler(const std::string& scheme, |
| 30 ProtocolHandler* protocol_handler) OVERRIDE; | 33 ProtocolHandler* protocol_handler) OVERRIDE; |
| 31 virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE; | 34 virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE; |
| 32 virtual URLRequestJob* MaybeCreateJobWithInterceptor( | 35 virtual URLRequestJob* MaybeCreateJobWithInterceptor( |
| 33 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE; | 36 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE; |
| 34 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler( | 37 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 35 const std::string& scheme, | 38 const std::string& scheme, |
| 36 URLRequest* request, | 39 URLRequest* request, |
| 37 NetworkDelegate* network_delegate) const OVERRIDE; | 40 NetworkDelegate* network_delegate) const OVERRIDE; |
| 38 virtual URLRequestJob* MaybeInterceptRedirect( | 41 virtual URLRequestJob* MaybeInterceptRedirect( |
| 39 const GURL& location, | 42 const GURL& location, |
| 40 URLRequest* request, | 43 URLRequest* request, |
| 41 NetworkDelegate* network_delegate) const OVERRIDE; | 44 NetworkDelegate* network_delegate) const OVERRIDE; |
| 42 virtual URLRequestJob* MaybeInterceptResponse( | 45 virtual URLRequestJob* MaybeInterceptResponse( |
| 43 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE; | 46 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE; |
| 44 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE; | 47 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE; |
| 45 virtual bool IsHandledURL(const GURL& url) const OVERRIDE; | 48 virtual bool IsHandledURL(const GURL& url) const OVERRIDE; |
| 46 | 49 |
| 47 private: | 50 private: |
| 48 const URLRequestJobFactory* job_factory_; | 51 scoped_ptr<URLRequestJobFactory> job_factory_; |
| 49 ProtocolHandler* protocol_handler_; | 52 scoped_ptr<ProtocolHandler> protocol_handler_; |
| 50 | 53 |
| 51 DISALLOW_COPY_AND_ASSIGN(HttpInterceptJobFactory); | 54 DISALLOW_COPY_AND_ASSIGN(ProtocolInterceptJobFactory); |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 } // namespace net | 57 } // namespace net |
| 55 | 58 |
| 56 #endif // CHROME_BROWSER_NET_HTTP_INTERCEPT_JOB_FACTORY_H_ | 59 #endif // NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_ |
| OLD | NEW |