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

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

Issue 407093011: Allow URLRequests from one context to have different NetworkDelegates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new tests Created 6 years, 4 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
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // to Read() previously. 266 // to Read() previously.
267 // 267 //
268 // If an error occurred, request->status() will contain the error, 268 // If an error occurred, request->status() will contain the error,
269 // and bytes read will be -1. 269 // and bytes read will be -1.
270 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; 270 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0;
271 271
272 protected: 272 protected:
273 virtual ~Delegate() {} 273 virtual ~Delegate() {}
274 }; 274 };
275 275
276 // TODO(tburkard): we should get rid of this constructor, and have each 276 // URLRequests should almost always be created by calling
277 // creator of a URLRequest specifically list the cookie store to be used. 277 // URLRequestContext::CreateRequest.
278 // For now, this constructor will use the cookie store in |context|. 278 //
279 URLRequest(const GURL& url, 279 // If no cookie store or network delegate are passed in, will use the ones
280 RequestPriority priority, 280 // from the URLRequestContext.
281 Delegate* delegate,
282 const URLRequestContext* context);
283
284 URLRequest(const GURL& url, 281 URLRequest(const GURL& url,
285 RequestPriority priority, 282 RequestPriority priority,
286 Delegate* delegate, 283 Delegate* delegate,
287 const URLRequestContext* context, 284 const URLRequestContext* context,
288 CookieStore* cookie_store); 285 CookieStore* cookie_store,
286 NetworkDelegate* network_delegate);
289 287
290 // If destroyed after Start() has been called but while IO is pending, 288 // If destroyed after Start() has been called but while IO is pending,
291 // then the request will be effectively canceled and the delegate 289 // then the request will be effectively canceled and the delegate
292 // will not have any more of its methods called. 290 // will not have any more of its methods called.
293 virtual ~URLRequest(); 291 virtual ~URLRequest();
294 292
295 // Changes the default cookie policy from allowing all cookies to blocking all 293 // Changes the default cookie policy from allowing all cookies to blocking all
296 // cookies. Embedders that want to implement a more flexible policy should 294 // cookies. Embedders that want to implement a more flexible policy should
297 // change the default to blocking all cookies, and provide a NetworkDelegate 295 // change the default to blocking all cookies, and provide a NetworkDelegate
298 // with the URLRequestContext that maintains the CookieStore. 296 // with the URLRequestContext that maintains the CookieStore.
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // Should only be called if the original job has not started a response. 712 // Should only be called if the original job has not started a response.
715 void Restart(); 713 void Restart();
716 714
717 private: 715 private:
718 friend class URLRequestJob; 716 friend class URLRequestJob;
719 717
720 // Registers or unregisters a network interception class. 718 // Registers or unregisters a network interception class.
721 static void RegisterRequestInterceptor(Interceptor* interceptor); 719 static void RegisterRequestInterceptor(Interceptor* interceptor);
722 static void UnregisterRequestInterceptor(Interceptor* interceptor); 720 static void UnregisterRequestInterceptor(Interceptor* interceptor);
723 721
724 // Initializes the URLRequest. Code shared between the two constructors.
725 // TODO(tburkard): This can ultimately be folded into a single constructor
726 // again.
727 void Init(const GURL& url,
728 RequestPriority priotity,
729 Delegate* delegate,
730 const URLRequestContext* context,
731 CookieStore* cookie_store);
732
733 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest 722 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest
734 // handler. If |blocked| is true, the request is blocked and an error page is 723 // handler. If |blocked| is true, the request is blocked and an error page is
735 // returned indicating so. This should only be called after Start is called 724 // returned indicating so. This should only be called after Start is called
736 // and OnBeforeRequest returns true (signalling that the request should be 725 // and OnBeforeRequest returns true (signalling that the request should be
737 // paused). 726 // paused).
738 void BeforeRequestComplete(int error); 727 void BeforeRequestComplete(int error);
739 728
740 void StartJob(URLRequestJob* job); 729 void StartJob(URLRequestJob* job);
741 730
742 // Restarting involves replacing the current job with a new one such as what 731 // Restarting involves replacing the current job with a new one such as what
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 890
902 // The proxy server used for this request, if any. 891 // The proxy server used for this request, if any.
903 HostPortPair proxy_server_; 892 HostPortPair proxy_server_;
904 893
905 DISALLOW_COPY_AND_ASSIGN(URLRequest); 894 DISALLOW_COPY_AND_ASSIGN(URLRequest);
906 }; 895 };
907 896
908 } // namespace net 897 } // namespace net
909 898
910 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 899 #endif // NET_URL_REQUEST_URL_REQUEST_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698