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_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 // |result| >= 0: |*error| == OK, |*count| == |result| | 321 // |result| >= 0: |*error| == OK, |*count| == |result| |
322 // |result| < 0: |*error| = |result|, |*count| == 0 | 322 // |result| < 0: |*error| = |result|, |*count| == 0 |
323 static void ConvertResultToError(int result, Error* error, int* count); | 323 static void ConvertResultToError(int result, Error* error, int* count); |
324 | 324 |
325 // Completion callback for raw reads. See |ReadRawData| for details. | 325 // Completion callback for raw reads. See |ReadRawData| for details. |
326 // |bytes_read| is either >= 0 to indicate a successful read and count of | 326 // |bytes_read| is either >= 0 to indicate a successful read and count of |
327 // bytes read, or < 0 to indicate an error. | 327 // bytes read, or < 0 to indicate an error. |
328 // On return, |this| may be deleted. | 328 // On return, |this| may be deleted. |
329 void ReadRawDataComplete(int bytes_read); | 329 void ReadRawDataComplete(int bytes_read); |
330 | 330 |
| 331 // Computes a new RedirectInfo based on receiving a redirect response of |
| 332 // |location| and |http_status_code|. |
| 333 virtual RedirectInfo ComputeRedirectInfo(const GURL& location, |
| 334 int http_status_code); |
| 335 |
331 // The request that initiated this job. This value will never be nullptr. | 336 // The request that initiated this job. This value will never be nullptr. |
332 URLRequest* const request_; | 337 URLRequest* const request_; |
333 | 338 |
334 private: | 339 private: |
335 class URLRequestJobSourceStream; | 340 class URLRequestJobSourceStream; |
336 | 341 |
337 // Helper method used to perform tasks after reading from |source_stream_| is | 342 // Helper method used to perform tasks after reading from |source_stream_| is |
338 // completed. |synchronous| true if the read completed synchronously. | 343 // completed. |synchronous| true if the read completed synchronously. |
339 // See the documentation for |Read| above for the contract of this method. | 344 // See the documentation for |Read| above for the contract of this method. |
340 void SourceStreamReadComplete(bool synchronous, int result); | 345 void SourceStreamReadComplete(bool synchronous, int result); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 377 |
373 // Takes care of the notification initiated by OnDone() to avoid re-entering | 378 // Takes care of the notification initiated by OnDone() to avoid re-entering |
374 // the URLRequest::Delegate. | 379 // the URLRequest::Delegate. |
375 void NotifyDone(); | 380 void NotifyDone(); |
376 | 381 |
377 // Subclasses may implement this method to record packet arrival times. | 382 // Subclasses may implement this method to record packet arrival times. |
378 // The default implementation does nothing. Only invoked when bytes have been | 383 // The default implementation does nothing. Only invoked when bytes have been |
379 // read since the last invocation. | 384 // read since the last invocation. |
380 virtual void UpdatePacketReadTimes(); | 385 virtual void UpdatePacketReadTimes(); |
381 | 386 |
382 // Computes a new RedirectInfo based on receiving a redirect response of | |
383 // |location| and |http_status_code|. | |
384 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); | |
385 | |
386 // Notify the network delegate that more bytes have been received or sent over | 387 // Notify the network delegate that more bytes have been received or sent over |
387 // the network, if bytes have been received or sent since the previous | 388 // the network, if bytes have been received or sent since the previous |
388 // notification. | 389 // notification. |
389 void MaybeNotifyNetworkBytes(); | 390 void MaybeNotifyNetworkBytes(); |
390 | 391 |
391 // Indicates that the job is done producing data, either it has completed | 392 // Indicates that the job is done producing data, either it has completed |
392 // all the data or an error has been encountered. Set exclusively by | 393 // all the data or an error has been encountered. Set exclusively by |
393 // NotifyDone so that it is kept in sync with the request. | 394 // NotifyDone so that it is kept in sync with the request. |
394 bool done_; | 395 bool done_; |
395 | 396 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 CompletionCallback read_raw_callback_; | 439 CompletionCallback read_raw_callback_; |
439 | 440 |
440 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 441 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
441 | 442 |
442 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 443 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
443 }; | 444 }; |
444 | 445 |
445 } // namespace net | 446 } // namespace net |
446 | 447 |
447 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 448 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
OLD | NEW |