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 NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <string> | 8 #include <string> |
| 10 #include <vector> | |
| 11 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | |
| 12 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 13 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 14 | 13 |
| 15 class GURL; | 14 class GURL; |
| 16 | 15 |
| 17 namespace net { | 16 namespace net { |
| 18 | 17 |
| 19 class URLRequest; | 18 class URLRequest; |
| 20 class URLRequestJob; | 19 class URLRequestJob; |
| 21 | 20 |
| 22 class NET_EXPORT URLRequestJobFactory | 21 class NET_EXPORT URLRequestJobFactory |
| 23 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 22 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 24 public: | 23 public: |
| 25 class NET_EXPORT ProtocolHandler { | 24 class NET_EXPORT ProtocolHandler { |
|
willchan no longer on Chromium
2012/08/16 20:35:37
Mark these (ProtocolHandler & Interceptor) with TO
erikwright (departed)
2012/08/21 18:02:13
Agreed.
shalev
2012/08/22 19:10:11
Done.
| |
| 26 public: | 25 public: |
| 27 virtual ~ProtocolHandler(); | 26 virtual ~ProtocolHandler(); |
| 28 | 27 |
| 29 virtual URLRequestJob* MaybeCreateJob(URLRequest* request) const = 0; | 28 virtual URLRequestJob* MaybeCreateJob(URLRequest* request) const = 0; |
| 30 }; | 29 }; |
| 31 | 30 |
| 32 class NET_EXPORT Interceptor { | 31 class NET_EXPORT Interceptor { |
| 33 public: | 32 public: |
| 34 virtual ~Interceptor(); | 33 virtual ~Interceptor(); |
| 35 | 34 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 59 virtual URLRequestJob* MaybeInterceptResponse( | 58 virtual URLRequestJob* MaybeInterceptResponse( |
| 60 URLRequest* request) const = 0; | 59 URLRequest* request) const = 0; |
| 61 | 60 |
| 62 // Returns true if this interceptor handles requests for URLs with the | 61 // Returns true if this interceptor handles requests for URLs with the |
| 63 // given protocol. Returning false does not imply that this interceptor | 62 // given protocol. Returning false does not imply that this interceptor |
| 64 // can't or won't handle requests with the given protocol. | 63 // can't or won't handle requests with the given protocol. |
| 65 virtual bool WillHandleProtocol(const std::string& protocol) const; | 64 virtual bool WillHandleProtocol(const std::string& protocol) const; |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 URLRequestJobFactory(); | 67 URLRequestJobFactory(); |
| 69 ~URLRequestJobFactory(); | 68 virtual ~URLRequestJobFactory(); |
| 70 | 69 |
| 70 // TODO(shalev): Remove this from the interface. | |
| 71 // Sets the ProtocolHandler for a scheme. Returns true on success, false on | 71 // Sets the ProtocolHandler for a scheme. Returns true on success, false on |
| 72 // failure (a ProtocolHandler already exists for |scheme|). On success, | 72 // failure (a ProtocolHandler already exists for |scheme|). On success, |
| 73 // URLRequestJobFactory takes ownership of |protocol_handler|. | 73 // URLRequestJobFactory takes ownership of |protocol_handler|. |
| 74 bool SetProtocolHandler(const std::string& scheme, | 74 virtual bool SetProtocolHandler(const std::string& scheme, |
| 75 ProtocolHandler* protocol_handler); | 75 ProtocolHandler* protocol_handler) = 0; |
| 76 | 76 |
| 77 // TODO(shalev): Remove this from the interface. | |
| 77 // Takes ownership of |interceptor|. Adds it to the end of the Interceptor | 78 // Takes ownership of |interceptor|. Adds it to the end of the Interceptor |
| 78 // list. | 79 // list. |
| 79 void AddInterceptor(Interceptor* interceptor); | 80 virtual void AddInterceptor(Interceptor* interceptor) = 0; |
| 80 | 81 |
| 81 URLRequestJob* MaybeCreateJobWithInterceptor(URLRequest* request) const; | 82 virtual URLRequestJob* MaybeCreateJobWithInterceptor( |
|
willchan no longer on Chromium
2012/08/16 20:35:37
Shouldn't there be a TODO here to kill this too?
erikwright (departed)
2012/08/21 17:43:32
The two TODOs added are in reference to the mutato
willchan no longer on Chromium
2012/08/21 17:58:01
Not sure if I understand your comments. What I was
erikwright (departed)
2012/08/21 18:02:13
Great. We are in agreement.
A single TODO should
shalev
2012/08/22 19:10:11
Done.
| |
| 83 URLRequest* request) const = 0; | |
| 82 | 84 |
| 83 URLRequestJob* MaybeCreateJobWithProtocolHandler(const std::string& scheme, | 85 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler( |
|
willchan no longer on Chromium
2012/08/16 20:35:37
Ditto
| |
| 84 URLRequest* request) const; | 86 const std::string& scheme, URLRequest* request) const = 0; |
| 85 | 87 |
| 86 URLRequestJob* MaybeInterceptRedirect(const GURL& location, | 88 virtual URLRequestJob* MaybeInterceptRedirect( |
| 87 URLRequest* request) const; | 89 const GURL& location, URLRequest* request) const = 0; |
| 88 | 90 |
| 89 URLRequestJob* MaybeInterceptResponse(URLRequest* request) const; | 91 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request) const = 0; |
| 90 | 92 |
| 91 bool IsHandledProtocol(const std::string& scheme) const; | 93 virtual bool IsHandledProtocol(const std::string& scheme) const = 0; |
| 92 | 94 |
| 93 bool IsHandledURL(const GURL& url) const; | 95 virtual bool IsHandledURL(const GURL& url) const = 0; |
| 94 | 96 |
| 95 private: | 97 private: |
| 96 typedef std::map<std::string, ProtocolHandler*> ProtocolHandlerMap; | |
| 97 typedef std::vector<Interceptor*> InterceptorList; | |
| 98 | |
| 99 ProtocolHandlerMap protocol_handler_map_; | |
| 100 InterceptorList interceptors_; | |
| 101 | |
| 102 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory); | 98 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory); |
| 103 }; | 99 }; |
| 104 | 100 |
| 105 } // namespace net | 101 } // namespace net |
| 106 | 102 |
| 107 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ | 103 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ |
| OLD | NEW |