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> | 8 #include <map> |
|
erikwright (departed)
2012/08/16 15:49:01
don't need map or vector
shalev
2012/08/16 18:40:39
Done.
| |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 class URLRequest; | 19 class URLRequest; |
| 20 class URLRequestJob; | 20 class URLRequestJob; |
| 21 | 21 |
| 22 class NET_EXPORT URLRequestJobFactory | 22 class NET_EXPORT URLRequestJobFactory |
| 23 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 23 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
|
erikwright (departed)
2012/08/16 15:49:01
#include "base/compiler_specific.h" for NON_EXPORT
shalev
2012/08/16 18:40:39
Done.
| |
| 24 public: | 24 public: |
| 25 class NET_EXPORT ProtocolHandler { | 25 class NET_EXPORT ProtocolHandler { |
| 26 public: | 26 public: |
| 27 virtual ~ProtocolHandler(); | 27 virtual ~ProtocolHandler(); |
| 28 | 28 |
| 29 virtual URLRequestJob* MaybeCreateJob(URLRequest* request) const = 0; | 29 virtual URLRequestJob* MaybeCreateJob(URLRequest* request) const = 0; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class NET_EXPORT Interceptor { | 32 class NET_EXPORT Interceptor { |
| 33 public: | 33 public: |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 59 virtual URLRequestJob* MaybeInterceptResponse( | 59 virtual URLRequestJob* MaybeInterceptResponse( |
| 60 URLRequest* request) const = 0; | 60 URLRequest* request) const = 0; |
| 61 | 61 |
| 62 // Returns true if this interceptor handles requests for URLs with the | 62 // Returns true if this interceptor handles requests for URLs with the |
| 63 // given protocol. Returning false does not imply that this interceptor | 63 // given protocol. Returning false does not imply that this interceptor |
| 64 // can't or won't handle requests with the given protocol. | 64 // can't or won't handle requests with the given protocol. |
| 65 virtual bool WillHandleProtocol(const std::string& protocol) const; | 65 virtual bool WillHandleProtocol(const std::string& protocol) const; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 URLRequestJobFactory(); | 68 URLRequestJobFactory(); |
| 69 ~URLRequestJobFactory(); | 69 ~URLRequestJobFactory(); |
|
erikwright (departed)
2012/08/16 15:49:01
virtual
shalev
2012/08/16 18:40:39
Done.
| |
| 70 | 70 |
| 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 |
|
erikwright (departed)
2012/08/16 15:49:01
TODO remove from the interface.
shalev
2012/08/16 18:40:39
Done.
| |
| 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 // Takes ownership of |interceptor|. Adds it to the end of the Interceptor | 77 // Takes ownership of |interceptor|. Adds it to the end of the Interceptor |
| 78 // list. | 78 // list. |
|
erikwright (departed)
2012/08/16 15:49:01
TODO remove from the interface.
shalev
2012/08/16 18:40:39
Done.
| |
| 79 void AddInterceptor(Interceptor* interceptor); | 79 virtual void AddInterceptor(Interceptor* interceptor) = 0; |
| 80 | 80 |
| 81 URLRequestJob* MaybeCreateJobWithInterceptor(URLRequest* request) const; | 81 virtual URLRequestJob* MaybeCreateJobWithInterceptor( |
| 82 URLRequest* request) const = 0; | |
| 82 | 83 |
| 83 URLRequestJob* MaybeCreateJobWithProtocolHandler(const std::string& scheme, | 84 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 84 URLRequest* request) const; | 85 const std::string& scheme, URLRequest* request) const = 0; |
| 85 | 86 |
| 86 URLRequestJob* MaybeInterceptRedirect(const GURL& location, | 87 virtual URLRequestJob* MaybeInterceptRedirect( |
| 87 URLRequest* request) const; | 88 const GURL& location, URLRequest* request) const = 0; |
| 88 | 89 |
| 89 URLRequestJob* MaybeInterceptResponse(URLRequest* request) const; | 90 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request) const = 0; |
| 90 | 91 |
| 91 bool IsHandledProtocol(const std::string& scheme) const; | 92 virtual bool IsHandledProtocol(const std::string& scheme) const = 0; |
| 92 | 93 |
| 93 bool IsHandledURL(const GURL& url) const; | 94 virtual bool IsHandledURL(const GURL& url) const = 0; |
| 94 | 95 |
| 95 private: | 96 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); | 97 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory); |
| 103 }; | 98 }; |
| 104 | 99 |
| 105 } // namespace net | 100 } // namespace net |
| 106 | 101 |
| 107 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ | 102 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ |
| OLD | NEW |