| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 public: | 96 public: |
| 97 virtual ~Delegate() {} | 97 virtual ~Delegate() {} |
| 98 | 98 |
| 99 // Called upon a server-initiated redirect. The delegate may call the | 99 // Called upon a server-initiated redirect. The delegate may call the |
| 100 // request's Cancel method to prevent the redirect from being followed. | 100 // request's Cancel method to prevent the redirect from being followed. |
| 101 // Since there may be multiple chained redirects, there may also be more | 101 // Since there may be multiple chained redirects, there may also be more |
| 102 // than one redirect call. | 102 // than one redirect call. |
| 103 // | 103 // |
| 104 // When this function is called, the request will still contain the | 104 // When this function is called, the request will still contain the |
| 105 // original URL, the destination of the redirect is provided in 'new_url'. | 105 // original URL, the destination of the redirect is provided in 'new_url'. |
| 106 // If the delegate does not cancel the request and |*defer_redirect| is | 106 // If the request is not canceled the redirect will be followed and the |
| 107 // false, then the redirect will be followed, and the request's URL will be | 107 // request's URL will be changed to the new URL. |
| 108 // changed to the new URL. Otherwise if the delegate does not cancel the | |
| 109 // request and |*defer_redirect| is true, then the redirect will be | |
| 110 // followed once FollowDeferredRedirect is called on the URLRequest. | |
| 111 // | |
| 112 // The caller must set |*defer_redirect| to false, so that delegates do not | |
| 113 // need to set it if they are happy with the default behavior of not | |
| 114 // deferring redirect. | |
| 115 virtual void OnReceivedRedirect(URLRequest* request, | 108 virtual void OnReceivedRedirect(URLRequest* request, |
| 116 const GURL& new_url, | 109 const GURL& new_url) = 0; |
| 117 bool* defer_redirect) { | |
| 118 } | |
| 119 | 110 |
| 120 // Called when we receive an authentication failure. The delegate should | 111 // Called when we receive an authentication failure. The delegate should |
| 121 // call request->SetAuth() with the user's credentials once it obtains them, | 112 // call request->SetAuth() with the user's credentials once it obtains them, |
| 122 // or request->CancelAuth() to cancel the login and display the error page. | 113 // or request->CancelAuth() to cancel the login and display the error page. |
| 123 // When it does so, the request will be reissued, restarting the sequence | 114 // When it does so, the request will be reissued, restarting the sequence |
| 124 // of On* callbacks. | 115 // of On* callbacks. |
| 125 virtual void OnAuthRequired(URLRequest* request, | 116 virtual void OnAuthRequired(URLRequest* request, |
| 126 net::AuthChallengeInfo* auth_info) { | 117 net::AuthChallengeInfo* auth_info) { |
| 127 request->CancelAuth(); | 118 request->CancelAuth(); |
| 128 } | 119 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // The max_bytes parameter is the maximum number of bytes to read. | 390 // The max_bytes parameter is the maximum number of bytes to read. |
| 400 // | 391 // |
| 401 // The bytes_read parameter is an output parameter containing the | 392 // The bytes_read parameter is an output parameter containing the |
| 402 // the number of bytes read. A value of 0 indicates that there is no | 393 // the number of bytes read. A value of 0 indicates that there is no |
| 403 // more data available to read from the stream. | 394 // more data available to read from the stream. |
| 404 // | 395 // |
| 405 // If a read error occurs, Read returns false and the request->status | 396 // If a read error occurs, Read returns false and the request->status |
| 406 // will be set to an error. | 397 // will be set to an error. |
| 407 bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); | 398 bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); |
| 408 | 399 |
| 409 // This method may be called to follow a redirect that was deferred in | |
| 410 // response to an OnReceivedRedirect call. | |
| 411 void FollowDeferredRedirect(); | |
| 412 | |
| 413 // One of the following two methods should be called in response to an | 400 // One of the following two methods should be called in response to an |
| 414 // OnAuthRequired() callback (and only then). | 401 // OnAuthRequired() callback (and only then). |
| 415 // SetAuth will reissue the request with the given credentials. | 402 // SetAuth will reissue the request with the given credentials. |
| 416 // CancelAuth will give up and display the error page. | 403 // CancelAuth will give up and display the error page. |
| 417 void SetAuth(const std::wstring& username, const std::wstring& password); | 404 void SetAuth(const std::wstring& username, const std::wstring& password); |
| 418 void CancelAuth(); | 405 void CancelAuth(); |
| 419 | 406 |
| 420 // This method can be called after some error notifications to instruct this | 407 // This method can be called after some error notifications to instruct this |
| 421 // URLRequest to ignore the current error and continue with the request. To | 408 // URLRequest to ignore the current error and continue with the request. To |
| 422 // cancel the request instead, call Cancel(). | 409 // cancel the request instead, call Cancel(). |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 #define URLREQUEST_COUNT_DTOR() url_request_metrics.object_count-- | 538 #define URLREQUEST_COUNT_DTOR() url_request_metrics.object_count-- |
| 552 | 539 |
| 553 #else // disable leak checking in release builds... | 540 #else // disable leak checking in release builds... |
| 554 | 541 |
| 555 #define URLREQUEST_COUNT_CTOR() | 542 #define URLREQUEST_COUNT_CTOR() |
| 556 #define URLREQUEST_COUNT_DTOR() | 543 #define URLREQUEST_COUNT_DTOR() |
| 557 | 544 |
| 558 #endif // #ifndef NDEBUG | 545 #endif // #ifndef NDEBUG |
| 559 | 546 |
| 560 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 547 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
| OLD | NEW |