Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: net/url_request/url_request_job_factory.h

Issue 10836248: Turned job_factory into a pure virtual class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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> 9
11 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.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 NetworkDelegate; 19 class NetworkDelegate;
20 class URLRequest; 20 class URLRequest;
21 class URLRequestJob; 21 class URLRequestJob;
22 22
23 class NET_EXPORT URLRequestJobFactory 23 class NET_EXPORT URLRequestJobFactory
24 : NON_EXPORTED_BASE(public base::NonThreadSafe) { 24 : NON_EXPORTED_BASE(public base::NonThreadSafe) {
25 public: 25 public:
26 // TODO(shalev): Move this to URLRequestJobFactoryImpl.
26 class NET_EXPORT ProtocolHandler { 27 class NET_EXPORT ProtocolHandler {
27 public: 28 public:
28 virtual ~ProtocolHandler(); 29 virtual ~ProtocolHandler();
29 30
30 virtual URLRequestJob* MaybeCreateJob( 31 virtual URLRequestJob* MaybeCreateJob(
31 URLRequest* request, NetworkDelegate* network_delegate) const = 0; 32 URLRequest* request, NetworkDelegate* network_delegate) const = 0;
32 }; 33 };
33 34
35 // TODO(shalev): Move this to URLRequestJobFactoryImpl.
34 class NET_EXPORT Interceptor { 36 class NET_EXPORT Interceptor {
35 public: 37 public:
36 virtual ~Interceptor(); 38 virtual ~Interceptor();
37 39
38 // Called for every request made. Should return a new job to handle the 40 // Called for every request made. Should return a new job to handle the
39 // request if it should be intercepted, or NULL to allow the request to 41 // request if it should be intercepted, or NULL to allow the request to
40 // be handled in the normal manner. 42 // be handled in the normal manner.
41 virtual URLRequestJob* MaybeIntercept( 43 virtual URLRequestJob* MaybeIntercept(
42 URLRequest* request, NetworkDelegate* network_delegate) const = 0; 44 URLRequest* request, NetworkDelegate* network_delegate) const = 0;
43 45
(...skipping 19 matching lines...) Expand all
63 virtual URLRequestJob* MaybeInterceptResponse( 65 virtual URLRequestJob* MaybeInterceptResponse(
64 URLRequest* request, NetworkDelegate* network_delegate) const = 0; 66 URLRequest* request, NetworkDelegate* network_delegate) const = 0;
65 67
66 // Returns true if this interceptor handles requests for URLs with the 68 // Returns true if this interceptor handles requests for URLs with the
67 // given protocol. Returning false does not imply that this interceptor 69 // given protocol. Returning false does not imply that this interceptor
68 // can't or won't handle requests with the given protocol. 70 // can't or won't handle requests with the given protocol.
69 virtual bool WillHandleProtocol(const std::string& protocol) const; 71 virtual bool WillHandleProtocol(const std::string& protocol) const;
70 }; 72 };
71 73
72 URLRequestJobFactory(); 74 URLRequestJobFactory();
73 ~URLRequestJobFactory(); 75 virtual ~URLRequestJobFactory();
74 76
77 // TODO(shalev): Remove this from the interface.
75 // Sets the ProtocolHandler for a scheme. Returns true on success, false on 78 // Sets the ProtocolHandler for a scheme. Returns true on success, false on
76 // failure (a ProtocolHandler already exists for |scheme|). On success, 79 // failure (a ProtocolHandler already exists for |scheme|). On success,
77 // URLRequestJobFactory takes ownership of |protocol_handler|. 80 // URLRequestJobFactory takes ownership of |protocol_handler|.
78 bool SetProtocolHandler(const std::string& scheme, 81 virtual bool SetProtocolHandler(const std::string& scheme,
79 ProtocolHandler* protocol_handler); 82 ProtocolHandler* protocol_handler) = 0;
80 83
84 // TODO(shalev): Remove this from the interface.
81 // Takes ownership of |interceptor|. Adds it to the end of the Interceptor 85 // Takes ownership of |interceptor|. Adds it to the end of the Interceptor
82 // list. 86 // list.
83 void AddInterceptor(Interceptor* interceptor); 87 virtual void AddInterceptor(Interceptor* interceptor) = 0;
84 88
85 URLRequestJob* MaybeCreateJobWithInterceptor( 89 // TODO(shalev): Consolidate MaybeCreateJobWithInterceptor and
86 URLRequest* request, NetworkDelegate* network_delegate) const; 90 // MaybeCreateJobWithProtocolHandler into a single method.
91 virtual URLRequestJob* MaybeCreateJobWithInterceptor(
92 URLRequest* request, NetworkDelegate* network_delegate) const = 0;
87 93
88 URLRequestJob* MaybeCreateJobWithProtocolHandler( 94 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler(
89 const std::string& scheme, 95 const std::string& scheme,
90 URLRequest* request, 96 URLRequest* request,
91 NetworkDelegate* network_delegate) const; 97 NetworkDelegate* network_delegate) const = 0;
92 98
93 URLRequestJob* MaybeInterceptRedirect( 99 virtual URLRequestJob* MaybeInterceptRedirect(
94 const GURL& location, 100 const GURL& location,
95 URLRequest* request, 101 URLRequest* request,
96 NetworkDelegate* network_delegate) const; 102 NetworkDelegate* network_delegate) const = 0;
97 103
98 URLRequestJob* MaybeInterceptResponse( 104 virtual URLRequestJob* MaybeInterceptResponse(
99 URLRequest* request, NetworkDelegate* network_delegate) const; 105 URLRequest* request, NetworkDelegate* network_delegate) const = 0;
100 106
101 bool IsHandledProtocol(const std::string& scheme) const; 107 virtual bool IsHandledProtocol(const std::string& scheme) const = 0;
102 108
103 bool IsHandledURL(const GURL& url) const; 109 virtual bool IsHandledURL(const GURL& url) const = 0;
104 110
105 private: 111 private:
106 typedef std::map<std::string, ProtocolHandler*> ProtocolHandlerMap;
107 typedef std::vector<Interceptor*> InterceptorList;
108
109 ProtocolHandlerMap protocol_handler_map_;
110 InterceptorList interceptors_;
111
112 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory); 112 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory);
113 }; 113 };
114 114
115 } // namespace net 115 } // namespace net
116 116
117 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_ 117 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl_unittest.cc ('k') | net/url_request/url_request_job_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698