| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/debug/leak_tracker.h" | 13 #include "base/debug/leak_tracker.h" |
| 14 #include "base/linked_ptr.h" | 14 #include "base/linked_ptr.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "net/base/load_states.h" | 20 #include "net/base/load_states.h" |
| 21 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
| 22 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
| 23 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
| 24 #include "net/http/http_response_info.h" | 24 #include "net/http/http_response_info.h" |
| 25 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class Time; | 28 class Time; |
| 29 } // namespace base | 29 } // namespace base |
| 30 | 30 |
| 31 namespace net { | |
| 32 class CookieOptions; | |
| 33 class IOBuffer; | |
| 34 class SSLCertRequestInfo; | |
| 35 class UploadData; | |
| 36 class URLRequestJob; | |
| 37 class X509Certificate; | |
| 38 } // namespace net | |
| 39 | |
| 40 class FilePath; | 31 class FilePath; |
| 41 class URLRequestContext; | |
| 42 | 32 |
| 43 // This stores the values of the Set-Cookie headers received during the request. | 33 // This stores the values of the Set-Cookie headers received during the request. |
| 44 // Each item in the vector corresponds to a Set-Cookie: line received, | 34 // Each item in the vector corresponds to a Set-Cookie: line received, |
| 45 // excluding the "Set-Cookie:" part. | 35 // excluding the "Set-Cookie:" part. |
| 46 typedef std::vector<std::string> ResponseCookies; | 36 typedef std::vector<std::string> ResponseCookies; |
| 47 | 37 |
| 48 namespace net { | 38 namespace net { |
| 39 |
| 40 class CookieOptions; |
| 41 class IOBuffer; |
| 42 class SSLCertRequestInfo; |
| 43 class UploadData; |
| 44 class URLRequestContext; |
| 45 class URLRequestJob; |
| 46 class X509Certificate; |
| 47 |
| 49 //----------------------------------------------------------------------------- | 48 //----------------------------------------------------------------------------- |
| 50 // A class representing the asynchronous load of a data stream from an URL. | 49 // A class representing the asynchronous load of a data stream from an URL. |
| 51 // | 50 // |
| 52 // The lifetime of an instance of this class is completely controlled by the | 51 // The lifetime of an instance of this class is completely controlled by the |
| 53 // consumer, and the instance is not required to live on the heap or be | 52 // consumer, and the instance is not required to live on the heap or be |
| 54 // allocated in any special way. It is also valid to delete an URLRequest | 53 // allocated in any special way. It is also valid to delete an URLRequest |
| 55 // object during the handling of a callback to its delegate. Of course, once | 54 // object during the handling of a callback to its delegate. Of course, once |
| 56 // the URLRequest is deleted, no further callbacks to its delegate will occur. | 55 // the URLRequest is deleted, no further callbacks to its delegate will occur. |
| 57 // | 56 // |
| 58 // NOTE: All usage of all instances of this class should be on the same thread. | 57 // NOTE: All usage of all instances of this class should be on the same thread. |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 427 |
| 429 // Access the net::LOAD_* flags modifying this request (see load_flags.h). | 428 // Access the net::LOAD_* flags modifying this request (see load_flags.h). |
| 430 int load_flags() const { return load_flags_; } | 429 int load_flags() const { return load_flags_; } |
| 431 void set_load_flags(int flags) { load_flags_ = flags; } | 430 void set_load_flags(int flags) { load_flags_ = flags; } |
| 432 | 431 |
| 433 // Returns true if the request is "pending" (i.e., if Start() has been called, | 432 // Returns true if the request is "pending" (i.e., if Start() has been called, |
| 434 // and the response has not yet been called). | 433 // and the response has not yet been called). |
| 435 bool is_pending() const { return is_pending_; } | 434 bool is_pending() const { return is_pending_; } |
| 436 | 435 |
| 437 // Returns the error status of the request. | 436 // Returns the error status of the request. |
| 438 const URLRequestStatus& status() const { return status_; } | 437 const net::URLRequestStatus& status() const { return status_; } |
| 439 | 438 |
| 440 // This method is called to start the request. The delegate will receive | 439 // This method is called to start the request. The delegate will receive |
| 441 // a OnResponseStarted callback when the request is started. | 440 // a OnResponseStarted callback when the request is started. |
| 442 void Start(); | 441 void Start(); |
| 443 | 442 |
| 444 // This method may be called at any time after Start() has been called to | 443 // This method may be called at any time after Start() has been called to |
| 445 // cancel the request. This method may be called many times, and it has | 444 // cancel the request. This method may be called many times, and it has |
| 446 // no effect once the response has completed. It is guaranteed that no | 445 // no effect once the response has completed. It is guaranteed that no |
| 447 // methods of the delegate will be called after the request has been | 446 // methods of the delegate will be called after the request has been |
| 448 // cancelled, including during the call to Cancel itself. | 447 // cancelled, including during the call to Cancel itself. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 542 |
| 544 #ifdef UNIT_TEST | 543 #ifdef UNIT_TEST |
| 545 URLRequestJob* job() { return job_; } | 544 URLRequestJob* job() { return job_; } |
| 546 #endif | 545 #endif |
| 547 | 546 |
| 548 protected: | 547 protected: |
| 549 // Allow the URLRequestJob class to control the is_pending() flag. | 548 // Allow the URLRequestJob class to control the is_pending() flag. |
| 550 void set_is_pending(bool value) { is_pending_ = value; } | 549 void set_is_pending(bool value) { is_pending_ = value; } |
| 551 | 550 |
| 552 // Allow the URLRequestJob class to set our status too | 551 // Allow the URLRequestJob class to set our status too |
| 553 void set_status(const URLRequestStatus& value) { status_ = value; } | 552 void set_status(const net::URLRequestStatus& value) { status_ = value; } |
| 554 | 553 |
| 555 // Allow the URLRequestJob to redirect this request. Returns net::OK if | 554 // Allow the URLRequestJob to redirect this request. Returns net::OK if |
| 556 // successful, otherwise an error code is returned. | 555 // successful, otherwise an error code is returned. |
| 557 int Redirect(const GURL& location, int http_status_code); | 556 int Redirect(const GURL& location, int http_status_code); |
| 558 | 557 |
| 559 // Called by URLRequestJob to allow interception when a redirect occurs. | 558 // Called by URLRequestJob to allow interception when a redirect occurs. |
| 560 void ReceivedRedirect(const GURL& location, bool* defer_redirect); | 559 void ReceivedRedirect(const GURL& location, bool* defer_redirect); |
| 561 | 560 |
| 562 // Called by URLRequestJob to allow interception when the final response | 561 // Called by URLRequestJob to allow interception when the final response |
| 563 // occurs. | 562 // occurs. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 std::string referrer_; | 602 std::string referrer_; |
| 604 net::HttpRequestHeaders extra_request_headers_; | 603 net::HttpRequestHeaders extra_request_headers_; |
| 605 int load_flags_; // Flags indicating the request type for the load; | 604 int load_flags_; // Flags indicating the request type for the load; |
| 606 // expected values are LOAD_* enums above. | 605 // expected values are LOAD_* enums above. |
| 607 | 606 |
| 608 Delegate* delegate_; | 607 Delegate* delegate_; |
| 609 | 608 |
| 610 // Current error status of the job. When no error has been encountered, this | 609 // Current error status of the job. When no error has been encountered, this |
| 611 // will be SUCCESS. If multiple errors have been encountered, this will be | 610 // will be SUCCESS. If multiple errors have been encountered, this will be |
| 612 // the first non-SUCCESS status seen. | 611 // the first non-SUCCESS status seen. |
| 613 URLRequestStatus status_; | 612 net::URLRequestStatus status_; |
| 614 | 613 |
| 615 // The HTTP response info, lazily initialized. | 614 // The HTTP response info, lazily initialized. |
| 616 net::HttpResponseInfo response_info_; | 615 net::HttpResponseInfo response_info_; |
| 617 | 616 |
| 618 // Tells us whether the job is outstanding. This is true from the time | 617 // Tells us whether the job is outstanding. This is true from the time |
| 619 // Start() is called to the time we dispatch RequestComplete and indicates | 618 // Start() is called to the time we dispatch RequestComplete and indicates |
| 620 // whether the job is active. | 619 // whether the job is active. |
| 621 bool is_pending_; | 620 bool is_pending_; |
| 622 | 621 |
| 623 // Externally-defined data accessible by key | 622 // Externally-defined data accessible by key |
| (...skipping 16 matching lines...) Expand all Loading... |
| 640 net::RequestPriority priority_; | 639 net::RequestPriority priority_; |
| 641 | 640 |
| 642 base::debug::LeakTracker<URLRequest> leak_tracker_; | 641 base::debug::LeakTracker<URLRequest> leak_tracker_; |
| 643 | 642 |
| 644 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 643 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
| 645 }; | 644 }; |
| 646 | 645 |
| 647 } // namespace net | 646 } // namespace net |
| 648 | 647 |
| 649 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 648 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
| OLD | NEW |