OLD | NEW |
---|---|
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 public: | 128 public: |
129 virtual ~Delegate() {} | 129 virtual ~Delegate() {} |
130 | 130 |
131 // Called upon a server-initiated redirect. The delegate may call the | 131 // Called upon a server-initiated redirect. The delegate may call the |
132 // request's Cancel method to prevent the redirect from being followed. | 132 // request's Cancel method to prevent the redirect from being followed. |
133 // Since there may be multiple chained redirects, there may also be more | 133 // Since there may be multiple chained redirects, there may also be more |
134 // than one redirect call. | 134 // than one redirect call. |
135 // | 135 // |
136 // When this function is called, the request will still contain the | 136 // When this function is called, the request will still contain the |
137 // original URL, the destination of the redirect is provided in 'new_url'. | 137 // original URL, the destination of the redirect is provided in 'new_url'. |
138 // If the request is not canceled the redirect will be followed and the | 138 // If the delegate does not cancel the request and |*defer_redirect| is |
139 // request's URL will be changed to the new URL. | 139 // false, then the redirect will be followed, and the request's URL will be |
140 // changed to the new URL. Otherwise if the delegate does not cancel the | |
141 // request and |*defer_redirect| is true, then the redirect will be | |
142 // followed once FollowDeferredRedirect is called on the URLRequest. | |
143 // | |
144 // The default value for |*defer_redirect| is false, so that consumers do | |
wtc
2009/07/23 00:30:12
I suggest rewriting this sentence as follows:
T
darin (slow to review)
2009/07/23 01:27:29
Done.
wtc
2009/07/23 02:37:48
I agree.
| |
145 // not need to set it if they are happy with the default behavior. | |
140 virtual void OnReceivedRedirect(URLRequest* request, | 146 virtual void OnReceivedRedirect(URLRequest* request, |
141 const GURL& new_url) = 0; | 147 const GURL& new_url, |
148 bool* defer_redirect) { | |
149 } | |
142 | 150 |
143 // Called when we receive an authentication failure. The delegate should | 151 // Called when we receive an authentication failure. The delegate should |
144 // call request->SetAuth() with the user's credentials once it obtains them, | 152 // call request->SetAuth() with the user's credentials once it obtains them, |
145 // or request->CancelAuth() to cancel the login and display the error page. | 153 // or request->CancelAuth() to cancel the login and display the error page. |
146 // When it does so, the request will be reissued, restarting the sequence | 154 // When it does so, the request will be reissued, restarting the sequence |
147 // of On* callbacks. | 155 // of On* callbacks. |
148 virtual void OnAuthRequired(URLRequest* request, | 156 virtual void OnAuthRequired(URLRequest* request, |
149 net::AuthChallengeInfo* auth_info) { | 157 net::AuthChallengeInfo* auth_info) { |
150 request->CancelAuth(); | 158 request->CancelAuth(); |
151 } | 159 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 // The max_bytes parameter is the maximum number of bytes to read. | 437 // The max_bytes parameter is the maximum number of bytes to read. |
430 // | 438 // |
431 // The bytes_read parameter is an output parameter containing the | 439 // The bytes_read parameter is an output parameter containing the |
432 // the number of bytes read. A value of 0 indicates that there is no | 440 // the number of bytes read. A value of 0 indicates that there is no |
433 // more data available to read from the stream. | 441 // more data available to read from the stream. |
434 // | 442 // |
435 // If a read error occurs, Read returns false and the request->status | 443 // If a read error occurs, Read returns false and the request->status |
436 // will be set to an error. | 444 // will be set to an error. |
437 bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); | 445 bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); |
438 | 446 |
447 // This method may be called to follow a redirect that was deferred in | |
448 // response to an OnReceivedRedirect call. | |
449 void FollowDeferredRedirect(); | |
450 | |
439 // One of the following two methods should be called in response to an | 451 // One of the following two methods should be called in response to an |
440 // OnAuthRequired() callback (and only then). | 452 // OnAuthRequired() callback (and only then). |
441 // SetAuth will reissue the request with the given credentials. | 453 // SetAuth will reissue the request with the given credentials. |
442 // CancelAuth will give up and display the error page. | 454 // CancelAuth will give up and display the error page. |
443 void SetAuth(const std::wstring& username, const std::wstring& password); | 455 void SetAuth(const std::wstring& username, const std::wstring& password); |
444 void CancelAuth(); | 456 void CancelAuth(); |
445 | 457 |
446 // This method can be called after the user selects a client certificate to | 458 // This method can be called after the user selects a client certificate to |
447 // instruct this URLRequest to continue with the request with the | 459 // instruct this URLRequest to continue with the request with the |
448 // certificate. Pass NULL if the user doesn't have a client certificate. | 460 // certificate. Pass NULL if the user doesn't have a client certificate. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 void set_is_pending(bool value) { is_pending_ = value; } | 499 void set_is_pending(bool value) { is_pending_ = value; } |
488 | 500 |
489 // Allow the URLRequestJob class to set our status too | 501 // Allow the URLRequestJob class to set our status too |
490 void set_status(const URLRequestStatus& value) { status_ = value; } | 502 void set_status(const URLRequestStatus& value) { status_ = value; } |
491 | 503 |
492 // Allow the URLRequestJob to redirect this request. Returns net::OK if | 504 // Allow the URLRequestJob to redirect this request. Returns net::OK if |
493 // successful, otherwise an error code is returned. | 505 // successful, otherwise an error code is returned. |
494 int Redirect(const GURL& location, int http_status_code); | 506 int Redirect(const GURL& location, int http_status_code); |
495 | 507 |
496 // Called by URLRequestJob to allow interception when a redirect occurs. | 508 // Called by URLRequestJob to allow interception when a redirect occurs. |
497 void ReceivedRedirect(const GURL& location); | 509 void ReceivedRedirect(const GURL& location, bool* defer_redirect); |
498 | 510 |
499 // Called by URLRequestJob to allow interception when the final response | 511 // Called by URLRequestJob to allow interception when the final response |
500 // occurs. | 512 // occurs. |
501 void ResponseStarted(); | 513 void ResponseStarted(); |
502 | 514 |
503 // Allow an interceptor's URLRequestJob to restart this request. | 515 // Allow an interceptor's URLRequestJob to restart this request. |
504 // Should only be called if the original job has not started a resposne. | 516 // Should only be called if the original job has not started a resposne. |
505 void Restart(); | 517 void Restart(); |
506 | 518 |
507 private: | 519 private: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 #define URLREQUEST_COUNT_DTOR() url_request_metrics.object_count-- | 609 #define URLREQUEST_COUNT_DTOR() url_request_metrics.object_count-- |
598 | 610 |
599 #else // disable leak checking in release builds... | 611 #else // disable leak checking in release builds... |
600 | 612 |
601 #define URLREQUEST_COUNT_CTOR() | 613 #define URLREQUEST_COUNT_CTOR() |
602 #define URLREQUEST_COUNT_DTOR() | 614 #define URLREQUEST_COUNT_DTOR() |
603 | 615 |
604 #endif // #ifndef NDEBUG | 616 #endif // #ifndef NDEBUG |
605 | 617 |
606 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 618 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |