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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "net/base/load_states.h" | 16 #include "net/base/load_states.h" |
17 #include "net/base/ssl_info.h" | 17 #include "net/base/ssl_info.h" |
18 #include "net/base/upload_data.h" | 18 #include "net/base/upload_data.h" |
19 #include "net/base/x509_certificate.h" | 19 #include "net/base/x509_certificate.h" |
20 #include "net/http/http_response_info.h" | 20 #include "net/http/http_response_info.h" |
21 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
23 | 23 |
| 24 namespace net { |
| 25 class IOBuffer; |
| 26 } |
24 class URLRequestJob; | 27 class URLRequestJob; |
25 | 28 |
26 // This stores the values of the Set-Cookie headers received during the request. | 29 // This stores the values of the Set-Cookie headers received during the request. |
27 // Each item in the vector corresponds to a Set-Cookie: line received, | 30 // Each item in the vector corresponds to a Set-Cookie: line received, |
28 // excluding the "Set-Cookie:" part. | 31 // excluding the "Set-Cookie:" part. |
29 typedef std::vector<std::string> ResponseCookies; | 32 typedef std::vector<std::string> ResponseCookies; |
30 | 33 |
31 //----------------------------------------------------------------------------- | 34 //----------------------------------------------------------------------------- |
32 // A class representing the asynchronous load of a data stream from an URL. | 35 // A class representing the asynchronous load of a data stream from an URL. |
33 // | 36 // |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // Similar to Cancel but sets the error to |os_error| (see net_error_list.h | 363 // Similar to Cancel but sets the error to |os_error| (see net_error_list.h |
361 // for values) instead of net::ERR_ABORTED. | 364 // for values) instead of net::ERR_ABORTED. |
362 // Used to attach a reason for canceling a request. | 365 // Used to attach a reason for canceling a request. |
363 void CancelWithError(int os_error); | 366 void CancelWithError(int os_error); |
364 | 367 |
365 // Read initiates an asynchronous read from the response, and must only | 368 // Read initiates an asynchronous read from the response, and must only |
366 // be called after the OnResponseStarted callback is received with a | 369 // be called after the OnResponseStarted callback is received with a |
367 // successful status. | 370 // successful status. |
368 // If data is available, Read will return true, and the data and length will | 371 // If data is available, Read will return true, and the data and length will |
369 // be returned immediately. If data is not available, Read returns false, | 372 // be returned immediately. If data is not available, Read returns false, |
370 // and an asynchronous Read is initiated. The caller guarantees the | 373 // and an asynchronous Read is initiated. The Read is finished when |
371 // buffer provided will be available until the Read is finished. The | 374 // the caller receives the OnReadComplete callback. OnReadComplete will be |
372 // Read is finished when the caller receives the OnReadComplete | 375 // always be called, even if there was a failure. |
373 // callback. OnReadComplete will be always be called, even if there | |
374 // was a failure. | |
375 // | 376 // |
376 // The buf parameter is a buffer to receive the data. Once the read is | 377 // The buf parameter is a buffer to receive the data. If the operation |
377 // initiated, the caller guarantees availability of this buffer until | 378 // completes asynchronously, the implementation will reference the buffer |
378 // the OnReadComplete is received. The buffer must be at least | 379 // until OnReadComplete is called. The buffer must be at least max_bytes in |
379 // max_bytes in length. | 380 // length. |
380 // | 381 // |
381 // The max_bytes parameter is the maximum number of bytes to read. | 382 // The max_bytes parameter is the maximum number of bytes to read. |
382 // | 383 // |
383 // The bytes_read parameter is an output parameter containing the | 384 // The bytes_read parameter is an output parameter containing the |
384 // the number of bytes read. A value of 0 indicates that there is no | 385 // the number of bytes read. A value of 0 indicates that there is no |
385 // more data available to read from the stream. | 386 // more data available to read from the stream. |
386 // | 387 // |
387 // If a read error occurs, Read returns false and the request->status | 388 // If a read error occurs, Read returns false and the request->status |
388 // will be set to an error. | 389 // will be set to an error. |
389 bool Read(char* buf, int max_bytes, int *bytes_read); | 390 bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); |
390 | 391 |
391 // One of the following two methods should be called in response to an | 392 // One of the following two methods should be called in response to an |
392 // OnAuthRequired() callback (and only then). | 393 // OnAuthRequired() callback (and only then). |
393 // SetAuth will reissue the request with the given credentials. | 394 // SetAuth will reissue the request with the given credentials. |
394 // CancelAuth will give up and display the error page. | 395 // CancelAuth will give up and display the error page. |
395 void SetAuth(const std::wstring& username, const std::wstring& password); | 396 void SetAuth(const std::wstring& username, const std::wstring& password); |
396 void CancelAuth(); | 397 void CancelAuth(); |
397 | 398 |
398 // This method can be called after some error notifications to instruct this | 399 // This method can be called after some error notifications to instruct this |
399 // URLRequest to ignore the current error and continue with the request. To | 400 // URLRequest to ignore the current error and continue with the request. To |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 #else // disable leak checking in release builds... | 519 #else // disable leak checking in release builds... |
519 | 520 |
520 #define URLREQUEST_COUNT_CTOR() | 521 #define URLREQUEST_COUNT_CTOR() |
521 #define URLREQUEST_COUNT_DTOR() | 522 #define URLREQUEST_COUNT_DTOR() |
522 | 523 |
523 #endif | 524 #endif |
524 | 525 |
525 | 526 |
526 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 527 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
527 | 528 |
OLD | NEW |