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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // - OnReadCompleted* (zero or more calls until all data is read) | 226 // - OnReadCompleted* (zero or more calls until all data is read) |
227 // | 227 // |
228 // Read() must be called at least once. Read() returns true when it completed | 228 // Read() must be called at least once. Read() returns true when it completed |
229 // immediately, and false if an IO is pending or if there is an error. When | 229 // immediately, and false if an IO is pending or if there is an error. When |
230 // Read() returns false, the caller can check the Request's status() to see | 230 // Read() returns false, the caller can check the Request's status() to see |
231 // if an error occurred, or if the IO is just pending. When Read() returns | 231 // if an error occurred, or if the IO is just pending. When Read() returns |
232 // true with zero bytes read, it indicates the end of the response. | 232 // true with zero bytes read, it indicates the end of the response. |
233 // | 233 // |
234 class NET_EXPORT Delegate { | 234 class NET_EXPORT Delegate { |
235 public: | 235 public: |
236 virtual ~Delegate() {} | |
237 | |
238 // Called upon a server-initiated redirect. The delegate may call the | 236 // Called upon a server-initiated redirect. The delegate may call the |
239 // request's Cancel method to prevent the redirect from being followed. | 237 // request's Cancel method to prevent the redirect from being followed. |
240 // Since there may be multiple chained redirects, there may also be more | 238 // Since there may be multiple chained redirects, there may also be more |
241 // than one redirect call. | 239 // than one redirect call. |
242 // | 240 // |
243 // When this function is called, the request will still contain the | 241 // When this function is called, the request will still contain the |
244 // original URL, the destination of the redirect is provided in 'new_url'. | 242 // 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 | 243 // 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 | 244 // 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 | 245 // changed to the new URL. Otherwise if the delegate does not cancel the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 virtual void OnResponseStarted(URLRequest* request) = 0; | 293 virtual void OnResponseStarted(URLRequest* request) = 0; |
296 | 294 |
297 // Called when the a Read of the response body is completed after an | 295 // Called when the a Read of the response body is completed after an |
298 // IO_PENDING status from a Read() call. | 296 // IO_PENDING status from a Read() call. |
299 // The data read is filled into the buffer which the caller passed | 297 // The data read is filled into the buffer which the caller passed |
300 // to Read() previously. | 298 // to Read() previously. |
301 // | 299 // |
302 // If an error occurred, request->status() will contain the error, | 300 // If an error occurred, request->status() will contain the error, |
303 // and bytes read will be -1. | 301 // and bytes read will be -1. |
304 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; | 302 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; |
| 303 |
| 304 protected: |
| 305 virtual ~Delegate() {} |
305 }; | 306 }; |
306 | 307 |
307 // Initialize an URL request. | 308 // Initialize an URL request. |
308 URLRequest(const GURL& url, Delegate* delegate); | 309 URLRequest(const GURL& url, Delegate* delegate); |
309 | 310 |
310 // If destroyed after Start() has been called but while IO is pending, | 311 // If destroyed after Start() has been called but while IO is pending, |
311 // then the request will be effectively canceled and the delegate | 312 // then the request will be effectively canceled and the delegate |
312 // will not have any more of its methods called. | 313 // will not have any more of its methods called. |
313 virtual ~URLRequest(); | 314 virtual ~URLRequest(); |
314 | 315 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 base::TimeTicks creation_time_; | 802 base::TimeTicks creation_time_; |
802 | 803 |
803 scoped_ptr<const base::debug::StackTrace> stack_trace_; | 804 scoped_ptr<const base::debug::StackTrace> stack_trace_; |
804 | 805 |
805 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 806 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
806 }; | 807 }; |
807 | 808 |
808 } // namespace net | 809 } // namespace net |
809 | 810 |
810 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 811 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |