OLD | NEW |
---|---|
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 // - OnReadCompleted* (zero or more calls until all data is read) | 228 // - OnReadCompleted* (zero or more calls until all data is read) |
229 // | 229 // |
230 // Read() must be called at least once. Read() returns true when it completed | 230 // Read() must be called at least once. Read() returns true when it completed |
231 // immediately, and false if an IO is pending or if there is an error. When | 231 // immediately, and false if an IO is pending or if there is an error. When |
232 // Read() returns false, the caller can check the Request's status() to see | 232 // Read() returns false, the caller can check the Request's status() to see |
233 // if an error occurred, or if the IO is just pending. When Read() returns | 233 // if an error occurred, or if the IO is just pending. When Read() returns |
234 // true with zero bytes read, it indicates the end of the response. | 234 // true with zero bytes read, it indicates the end of the response. |
235 // | 235 // |
236 class NET_EXPORT Delegate { | 236 class NET_EXPORT Delegate { |
237 public: | 237 public: |
238 // Called when the request body (upload data) is initialized. | |
239 virtual void OnRequestBodyInitialized(URLRequest* request, uint64 size); | |
darin (slow to review)
2012/08/14 18:24:27
Does this really need to be an event? Why not jus
| |
240 | |
238 // Called upon a server-initiated redirect. The delegate may call the | 241 // Called upon a server-initiated redirect. The delegate may call the |
239 // request's Cancel method to prevent the redirect from being followed. | 242 // request's Cancel method to prevent the redirect from being followed. |
240 // Since there may be multiple chained redirects, there may also be more | 243 // Since there may be multiple chained redirects, there may also be more |
241 // than one redirect call. | 244 // than one redirect call. |
242 // | 245 // |
243 // When this function is called, the request will still contain the | 246 // When this function is called, the request will still contain the |
244 // original URL, the destination of the redirect is provided in 'new_url'. | 247 // original URL, the destination of the redirect is provided in 'new_url'. |
245 // If the delegate does not cancel the request and |*defer_redirect| is | 248 // If the delegate does not cancel the request and |*defer_redirect| is |
246 // false, then the redirect will be followed, and the request's URL will be | 249 // false, then the redirect will be followed, and the request's URL will be |
247 // changed to the new URL. Otherwise if the delegate does not cancel the | 250 // changed to the new URL. Otherwise if the delegate does not cancel the |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 | 634 |
632 // TODO(willchan): Undo this. Only temporarily public. | 635 // TODO(willchan): Undo this. Only temporarily public. |
633 bool has_delegate() const { return delegate_ != NULL; } | 636 bool has_delegate() const { return delegate_ != NULL; } |
634 | 637 |
635 // NOTE(willchan): This is just temporary for debugging | 638 // NOTE(willchan): This is just temporary for debugging |
636 // http://crbug.com/90971. | 639 // http://crbug.com/90971. |
637 // Allows to setting debug info into the URLRequest. | 640 // Allows to setting debug info into the URLRequest. |
638 void set_stack_trace(const base::debug::StackTrace& stack_trace); | 641 void set_stack_trace(const base::debug::StackTrace& stack_trace); |
639 const base::debug::StackTrace* stack_trace() const; | 642 const base::debug::StackTrace* stack_trace() const; |
640 | 643 |
644 // Called by HttpNetworkTransaction when the request body is initialized. | |
645 void NotifyRequestBodyInitialized(uint64 size); | |
646 | |
641 protected: | 647 protected: |
642 // Allow the URLRequestJob class to control the is_pending() flag. | 648 // Allow the URLRequestJob class to control the is_pending() flag. |
643 void set_is_pending(bool value) { is_pending_ = value; } | 649 void set_is_pending(bool value) { is_pending_ = value; } |
644 | 650 |
645 // Allow the URLRequestJob class to set our status too | 651 // Allow the URLRequestJob class to set our status too |
646 void set_status(const URLRequestStatus& value) { status_ = value; } | 652 void set_status(const URLRequestStatus& value) { status_ = value; } |
647 | 653 |
648 // Allow the URLRequestJob to redirect this request. Returns OK if | 654 // Allow the URLRequestJob to redirect this request. Returns OK if |
649 // successful, otherwise an error code is returned. | 655 // successful, otherwise an error code is returned. |
650 int Redirect(const GURL& location, int http_status_code); | 656 int Redirect(const GURL& location, int http_status_code); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 base::TimeTicks creation_time_; | 822 base::TimeTicks creation_time_; |
817 | 823 |
818 scoped_ptr<const base::debug::StackTrace> stack_trace_; | 824 scoped_ptr<const base::debug::StackTrace> stack_trace_; |
819 | 825 |
820 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 826 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
821 }; | 827 }; |
822 | 828 |
823 } // namespace net | 829 } // namespace net |
824 | 830 |
825 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 831 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |