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

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

Issue 122453002: Allows deferral of a URLRequest just before talking to the network, at (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated content-length in test to actual length Created 6 years, 11 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
« no previous file with comments | « net/http/http_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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // ContinueDespiteLastError(). cert_error is a ERR_* error code 267 // ContinueDespiteLastError(). cert_error is a ERR_* error code
268 // indicating what's wrong with the certificate. 268 // indicating what's wrong with the certificate.
269 // If |fatal| is true then the host in question demands a higher level 269 // If |fatal| is true then the host in question demands a higher level
270 // of security (due e.g. to HTTP Strict Transport Security, user 270 // of security (due e.g. to HTTP Strict Transport Security, user
271 // preference, or built-in policy). In this case, errors must not be 271 // preference, or built-in policy). In this case, errors must not be
272 // bypassable by the user. 272 // bypassable by the user.
273 virtual void OnSSLCertificateError(URLRequest* request, 273 virtual void OnSSLCertificateError(URLRequest* request,
274 const SSLInfo& ssl_info, 274 const SSLInfo& ssl_info,
275 bool fatal); 275 bool fatal);
276 276
277 // Called to notify that the request must use the network to complete the
278 // request and is about to do so. This is called at most once per
279 // URLRequest, and by default does not defer. If deferred, call
280 // ResumeNetworkStart() to continue or Cancel() to cancel.
281 virtual void OnBeforeNetworkStart(URLRequest* request, bool* defer);
282
277 // After calling Start(), the delegate will receive an OnResponseStarted 283 // After calling Start(), the delegate will receive an OnResponseStarted
278 // callback when the request has completed. If an error occurred, the 284 // callback when the request has completed. If an error occurred, the
279 // request->status() will be set. On success, all redirects have been 285 // request->status() will be set. On success, all redirects have been
280 // followed and the final response is beginning to arrive. At this point, 286 // followed and the final response is beginning to arrive. At this point,
281 // meta data about the response is available, including for example HTTP 287 // meta data about the response is available, including for example HTTP
282 // response headers if this is a request for a HTTP resource. 288 // response headers if this is a request for a HTTP resource.
283 virtual void OnResponseStarted(URLRequest* request) = 0; 289 virtual void OnResponseStarted(URLRequest* request) = 0;
284 290
285 // Called when the a Read of the response body is completed after an 291 // Called when the a Read of the response body is completed after an
286 // IO_PENDING status from a Read() call. 292 // IO_PENDING status from a Read() call.
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // Note that this method has no effect on other (simultaneous or not) requests 621 // Note that this method has no effect on other (simultaneous or not) requests
616 // for the same resource. The typical example is a request that results in 622 // for the same resource. The typical example is a request that results in
617 // the data being stored to disk (downloaded instead of rendered) so we don't 623 // the data being stored to disk (downloaded instead of rendered) so we don't
618 // want to store it twice. 624 // want to store it twice.
619 void StopCaching(); 625 void StopCaching();
620 626
621 // This method may be called to follow a redirect that was deferred in 627 // This method may be called to follow a redirect that was deferred in
622 // response to an OnReceivedRedirect call. 628 // response to an OnReceivedRedirect call.
623 void FollowDeferredRedirect(); 629 void FollowDeferredRedirect();
624 630
631 // This method must be called to resume network communications that were
632 // deferred in response to an OnBeforeNetworkStart call.
633 void ResumeNetworkStart();
634
625 // One of the following two methods should be called in response to an 635 // One of the following two methods should be called in response to an
626 // OnAuthRequired() callback (and only then). 636 // OnAuthRequired() callback (and only then).
627 // SetAuth will reissue the request with the given credentials. 637 // SetAuth will reissue the request with the given credentials.
628 // CancelAuth will give up and display the error page. 638 // CancelAuth will give up and display the error page.
629 void SetAuth(const AuthCredentials& credentials); 639 void SetAuth(const AuthCredentials& credentials);
630 void CancelAuth(); 640 void CancelAuth();
631 641
632 // This method can be called after the user selects a client certificate to 642 // This method can be called after the user selects a client certificate to
633 // instruct this URLRequest to continue with the request with the 643 // instruct this URLRequest to continue with the request with the
634 // certificate. Pass NULL if the user doesn't have a client certificate. 644 // certificate. Pass NULL if the user doesn't have a client certificate.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // Allow the URLRequestJob class to set our status too 692 // Allow the URLRequestJob class to set our status too
683 void set_status(const URLRequestStatus& value) { status_ = value; } 693 void set_status(const URLRequestStatus& value) { status_ = value; }
684 694
685 // Allow the URLRequestJob to redirect this request. Returns OK if 695 // Allow the URLRequestJob to redirect this request. Returns OK if
686 // successful, otherwise an error code is returned. 696 // successful, otherwise an error code is returned.
687 int Redirect(const GURL& location, int http_status_code); 697 int Redirect(const GURL& location, int http_status_code);
688 698
689 // Called by URLRequestJob to allow interception when a redirect occurs. 699 // Called by URLRequestJob to allow interception when a redirect occurs.
690 void NotifyReceivedRedirect(const GURL& location, bool* defer_redirect); 700 void NotifyReceivedRedirect(const GURL& location, bool* defer_redirect);
691 701
702 // Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to
703 // allow deferral of network initialization.
704 void NotifyBeforeNetworkStart(bool* defer);
705
692 // Allow an interceptor's URLRequestJob to restart this request. 706 // Allow an interceptor's URLRequestJob to restart this request.
693 // Should only be called if the original job has not started a response. 707 // Should only be called if the original job has not started a response.
694 void Restart(); 708 void Restart();
695 709
696 private: 710 private:
697 friend class URLRequestJob; 711 friend class URLRequestJob;
698 712
699 // Registers a new protocol handler for the given scheme. If the scheme is 713 // Registers a new protocol handler for the given scheme. If the scheme is
700 // already handled, this will overwrite the given factory. To delete the 714 // already handled, this will overwrite the given factory. To delete the
701 // protocol factory, use NULL for the factory BUT this WILL NOT put back 715 // protocol factory, use NULL for the factory BUT this WILL NOT put back
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 int64 received_response_content_length_; 886 int64 received_response_content_length_;
873 887
874 base::TimeTicks creation_time_; 888 base::TimeTicks creation_time_;
875 889
876 // Timing information for the most recent request. Its start times are 890 // Timing information for the most recent request. Its start times are
877 // populated during Start(), and the rest are populated in OnResponseReceived. 891 // populated during Start(), and the rest are populated in OnResponseReceived.
878 LoadTimingInfo load_timing_info_; 892 LoadTimingInfo load_timing_info_;
879 893
880 scoped_ptr<const base::debug::StackTrace> stack_trace_; 894 scoped_ptr<const base::debug::StackTrace> stack_trace_;
881 895
896 // Keeps track of whether or not OnBeforeNetworkStart has been called yet.
897 bool notified_before_network_start_;
898
882 DISALLOW_COPY_AND_ASSIGN(URLRequest); 899 DISALLOW_COPY_AND_ASSIGN(URLRequest);
883 }; 900 };
884 901
885 } // namespace net 902 } // namespace net
886 903
887 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 904 #endif // NET_URL_REQUEST_URL_REQUEST_H_
OLDNEW
« no previous file with comments | « net/http/http_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