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

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

Issue 7397008: Deprecate RegisterProtocolFactory/(Un)RegisterInterceptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent. Created 9 years, 5 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_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_
6 #define NET_URL_REQUEST_URL_REQUEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/debug/leak_tracker.h" 13 #include "base/debug/leak_tracker.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/string16.h" 17 #include "base/string16.h"
18 #include "base/threading/non_thread_safe.h" 18 #include "base/threading/non_thread_safe.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
21 #include "net/base/load_states.h" 21 #include "net/base/load_states.h"
22 #include "net/base/net_api.h" 22 #include "net/base/net_api.h"
23 #include "net/base/net_log.h" 23 #include "net/base/net_log.h"
24 #include "net/base/request_priority.h" 24 #include "net/base/request_priority.h"
25 #include "net/http/http_request_headers.h" 25 #include "net/http/http_request_headers.h"
26 #include "net/http/http_response_info.h" 26 #include "net/http/http_response_info.h"
27 #include "net/url_request/url_request_status.h" 27 #include "net/url_request/url_request_status.h"
28 28
29 class FilePath;
30 // Temporary layering violation to allow existing users of a deprecated
31 // interface.
32 class AutoUpdateInterceptor;
33 class ChildProcessSecurityPolicyTest;
34 class ComponentUpdateInterceptor;
35 class ResourceDispatcherHostTest;
36 class TestAutomationProvider;
37 class URLRequestAutomationJob;
38 class UserScriptListenerTest;
39
40 // Temporary layering violation to allow existing users of a deprecated
41 // interface.
42 namespace appcache {
43 class AppCacheInterceptor;
44 class AppCacheRequestHandlerTest;
45 class AppCacheURLRequestJobTest;
46 }
47
29 namespace base { 48 namespace base {
30 class Time; 49 class Time;
31 } // namespace base 50 } // namespace base
32 51
33 class FilePath; 52 // Temporary layering violation to allow existing users of a deprecated
53 // interface.
54 namespace chrome_browser_net {
55 class ConnectInterceptor;
56 }
57
58 // Temporary layering violation to allow existing users of a deprecated
59 // interface.
60 namespace fileapi {
61 class FileSystemDirURLRequestJobTest;
62 class FileSystemOperationWriteTest;
63 class FileSystemURLRequestJobTest;
64 class FileWriterDelegateTest;
65 }
66
67 // Temporary layering violation to allow existing users of a deprecated
68 // interface.
69 namespace policy {
70 class CannedResponseInterceptor;
71 }
72
73 // Temporary layering violation to allow existing users of a deprecated
74 // interface.
75 namespace webkit_blob {
76 class BlobURLRequestJobTest;
77 }
34 78
35 namespace net { 79 namespace net {
36 80
37 class CookieOptions; 81 class CookieOptions;
38 class HostPortPair; 82 class HostPortPair;
39 class IOBuffer; 83 class IOBuffer;
40 class SSLCertRequestInfo; 84 class SSLCertRequestInfo;
41 class UploadData; 85 class UploadData;
42 class URLRequestContext; 86 class URLRequestContext;
43 class URLRequestJob; 87 class URLRequestJob;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // the request delegate being informed of the response. This is also 152 // the request delegate being informed of the response. This is also
109 // called when there is no server response at all to allow interception 153 // called when there is no server response at all to allow interception
110 // on dns or network errors. Can return a new job to replace the existing 154 // on dns or network errors. Can return a new job to replace the existing
111 // job if it should be intercepted, or NULL to allow the normal handling to 155 // job if it should be intercepted, or NULL to allow the normal handling to
112 // continue. If a new job is provided, the delegate never sees the original 156 // continue. If a new job is provided, the delegate never sees the original
113 // response, instead the response produced by the intercept job will be 157 // response, instead the response produced by the intercept job will be
114 // returned. 158 // returned.
115 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request); 159 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request);
116 }; 160 };
117 161
162 // Deprecated interfaces in net::URLRequest. They have been moved to
163 // URLRequest's private section to prevent new uses. Existing uses are
164 // explicitly friended here and should be removed over time.
165 class NET_API Deprecated {
166 private:
167 // TODO(willchan): Kill off these friend declarations.
168 friend class ::AutoUpdateInterceptor;
169 friend class ::ChildProcessSecurityPolicyTest;
170 friend class ::ComponentUpdateInterceptor;
171 friend class ::ResourceDispatcherHostTest;
172 friend class ::TestAutomationProvider;
173 friend class ::UserScriptListenerTest;
174 friend class ::URLRequestAutomationJob;
175 friend class TestInterceptor;
176 friend class URLRequestFilter;
177 friend class appcache::AppCacheInterceptor;
178 friend class appcache::AppCacheRequestHandlerTest;
179 friend class appcache::AppCacheURLRequestJobTest;
180 friend class chrome_browser_net::ConnectInterceptor;
181 friend class fileapi::FileSystemDirURLRequestJobTest;
182 friend class fileapi::FileSystemOperationWriteTest;
183 friend class fileapi::FileSystemURLRequestJobTest;
184 friend class fileapi::FileWriterDelegateTest;
185 friend class policy::CannedResponseInterceptor;
186 friend class webkit_blob::BlobURLRequestJobTest;
187
188 // Use URLRequestJobFactory::ProtocolHandler instead.
189 static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme,
190 ProtocolFactory* factory);
191
192 // Use URLRequestJobFactory::Interceptor instead.
193 static void RegisterRequestInterceptor(Interceptor* interceptor);
194 static void UnregisterRequestInterceptor(Interceptor* interceptor);
195
196 DISALLOW_IMPLICIT_CONSTRUCTORS(Deprecated);
197 };
198
118 // The delegate's methods are called from the message loop of the thread 199 // The delegate's methods are called from the message loop of the thread
119 // on which the request's Start() method is called. See above for the 200 // on which the request's Start() method is called. See above for the
120 // ordering of callbacks. 201 // ordering of callbacks.
121 // 202 //
122 // The callbacks will be called in the following order: 203 // The callbacks will be called in the following order:
123 // Start() 204 // Start()
124 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or 205 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or
125 // SSL proxy requests a client certificate for authentication) 206 // SSL proxy requests a client certificate for authentication)
126 // - OnSSLCertificateError* (zero or one call, if the SSL server's 207 // - OnSSLCertificateError* (zero or one call, if the SSL server's
127 // certificate has an error) 208 // certificate has an error)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // will not have any more of its methods called. 308 // will not have any more of its methods called.
228 ~URLRequest(); 309 ~URLRequest();
229 310
230 // The user data allows the clients to associate data with this request. 311 // The user data allows the clients to associate data with this request.
231 // Multiple user data values can be stored under different keys. 312 // Multiple user data values can be stored under different keys.
232 // This request will TAKE OWNERSHIP of the given data pointer, and will 313 // This request will TAKE OWNERSHIP of the given data pointer, and will
233 // delete the object if it is changed or the request is destroyed. 314 // delete the object if it is changed or the request is destroyed.
234 UserData* GetUserData(const void* key) const; 315 UserData* GetUserData(const void* key) const;
235 void SetUserData(const void* key, UserData* data); 316 void SetUserData(const void* key, UserData* data);
236 317
237 // Registers a new protocol handler for the given scheme. If the scheme is
238 // already handled, this will overwrite the given factory. To delete the
239 // protocol factory, use NULL for the factory BUT this WILL NOT put back
240 // any previously registered protocol factory. It will have returned
241 // the previously registered factory (or NULL if none is registered) when
242 // the scheme was first registered so that the caller can manually put it
243 // back if desired.
244 //
245 // The scheme must be all-lowercase ASCII. See the ProtocolFactory
246 // declaration for its requirements.
247 //
248 // The registered protocol factory may return NULL, which will cause the
249 // regular "built-in" protocol factory to be used.
250 //
251 static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme,
252 ProtocolFactory* factory);
253
254 // Registers or unregisters a network interception class.
255 static void RegisterRequestInterceptor(Interceptor* interceptor);
256 static void UnregisterRequestInterceptor(Interceptor* interceptor);
257
258 // Returns true if the scheme can be handled by URLRequest. False otherwise. 318 // Returns true if the scheme can be handled by URLRequest. False otherwise.
259 static bool IsHandledProtocol(const std::string& scheme); 319 static bool IsHandledProtocol(const std::string& scheme);
260 320
261 // Returns true if the url can be handled by URLRequest. False otherwise. 321 // Returns true if the url can be handled by URLRequest. False otherwise.
262 // The function returns true for invalid urls because URLRequest knows how 322 // The function returns true for invalid urls because URLRequest knows how
263 // to handle those. 323 // to handle those.
264 // NOTE: This will also return true for URLs that are handled by 324 // NOTE: This will also return true for URLs that are handled by
265 // ProtocolFactories that only work for requests that are scoped to a 325 // ProtocolFactories that only work for requests that are scoped to a
266 // Profile. 326 // Profile.
267 static bool IsHandledURL(const GURL& url); 327 static bool IsHandledURL(const GURL& url);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 640
581 // Allow an interceptor's URLRequestJob to restart this request. 641 // Allow an interceptor's URLRequestJob to restart this request.
582 // Should only be called if the original job has not started a response. 642 // Should only be called if the original job has not started a response.
583 void Restart(); 643 void Restart();
584 644
585 private: 645 private:
586 friend class URLRequestJob; 646 friend class URLRequestJob;
587 647
588 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap; 648 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap;
589 649
650 // Registers a new protocol handler for the given scheme. If the scheme is
651 // already handled, this will overwrite the given factory. To delete the
652 // protocol factory, use NULL for the factory BUT this WILL NOT put back
653 // any previously registered protocol factory. It will have returned
654 // the previously registered factory (or NULL if none is registered) when
655 // the scheme was first registered so that the caller can manually put it
656 // back if desired.
657 //
658 // The scheme must be all-lowercase ASCII. See the ProtocolFactory
659 // declaration for its requirements.
660 //
661 // The registered protocol factory may return NULL, which will cause the
662 // regular "built-in" protocol factory to be used.
663 //
664 static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme,
665 ProtocolFactory* factory);
666
667 // Registers or unregisters a network interception class.
668 static void RegisterRequestInterceptor(Interceptor* interceptor);
669 static void UnregisterRequestInterceptor(Interceptor* interceptor);
670
590 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest 671 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest
591 // handler. If |blocked| is true, the request is blocked and an error page is 672 // handler. If |blocked| is true, the request is blocked and an error page is
592 // returned indicating so. This should only be called after Start is called 673 // returned indicating so. This should only be called after Start is called
593 // and OnBeforeRequest returns true (signalling that the request should be 674 // and OnBeforeRequest returns true (signalling that the request should be
594 // paused). 675 // paused).
595 void BeforeRequestComplete(int error); 676 void BeforeRequestComplete(int error);
596 677
597 void StartJob(URLRequestJob* job); 678 void StartJob(URLRequestJob* job);
598 679
599 // Restarting involves replacing the current job with a new one such as what 680 // Restarting involves replacing the current job with a new one such as what
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 // messages to network delegate. 782 // messages to network delegate.
702 // TODO(battre): Remove this. http://crbug.com/89049 783 // TODO(battre): Remove this. http://crbug.com/89049
703 bool has_notified_completion_; 784 bool has_notified_completion_;
704 785
705 DISALLOW_COPY_AND_ASSIGN(URLRequest); 786 DISALLOW_COPY_AND_ASSIGN(URLRequest);
706 }; 787 };
707 788
708 } // namespace net 789 } // namespace net
709 790
710 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 791 #endif // NET_URL_REQUEST_URL_REQUEST_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host_unittest.cc ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698