| 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> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 15 #include "base/power_monitor/power_observer.h" | 17 #include "base/power_monitor/power_observer.h" |
| 16 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 17 #include "net/base/load_states.h" | 19 #include "net/base/load_states.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // This is just the backend for URLRequest::Read, see that function for | 104 // This is just the backend for URLRequest::Read, see that function for |
| 103 // more info. | 105 // more info. |
| 104 bool Read(IOBuffer* buf, int buf_size, int* bytes_read); | 106 bool Read(IOBuffer* buf, int buf_size, int* bytes_read); |
| 105 | 107 |
| 106 // Stops further caching of this request, if any. For more info, see | 108 // Stops further caching of this request, if any. For more info, see |
| 107 // URLRequest::StopCaching(). | 109 // URLRequest::StopCaching(). |
| 108 virtual void StopCaching(); | 110 virtual void StopCaching(); |
| 109 | 111 |
| 110 virtual bool GetFullRequestHeaders(HttpRequestHeaders* headers) const; | 112 virtual bool GetFullRequestHeaders(HttpRequestHeaders* headers) const; |
| 111 | 113 |
| 112 // Get the number of bytes received from network. | 114 // Get the number of bytes received from network. The values returned by this |
| 115 // will never decrease over the lifetime of the URLRequestJob. |
| 113 virtual int64 GetTotalReceivedBytes() const; | 116 virtual int64 GetTotalReceivedBytes() const; |
| 114 | 117 |
| 115 // Called to fetch the current load state for the job. | 118 // Called to fetch the current load state for the job. |
| 116 virtual LoadState GetLoadState() const; | 119 virtual LoadState GetLoadState() const; |
| 117 | 120 |
| 118 // Called to get the upload progress in bytes. | 121 // Called to get the upload progress in bytes. |
| 119 virtual UploadProgress GetUploadProgress() const; | 122 virtual UploadProgress GetUploadProgress() const; |
| 120 | 123 |
| 121 // Called to fetch the charset for this request. Only makes sense for some | 124 // Called to fetch the charset for this request. Only makes sense for some |
| 122 // types of requests. Returns true on success. Calling this on a type that | 125 // types of requests. Returns true on success. Calling this on a type that |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 391 |
| 389 // Subclasses may implement this method to record packet arrival times. | 392 // Subclasses may implement this method to record packet arrival times. |
| 390 // The default implementation does nothing. Only invoked when bytes have been | 393 // The default implementation does nothing. Only invoked when bytes have been |
| 391 // read since the last invocation. | 394 // read since the last invocation. |
| 392 virtual void UpdatePacketReadTimes(); | 395 virtual void UpdatePacketReadTimes(); |
| 393 | 396 |
| 394 // Computes a new RedirectInfo based on receiving a redirect response of | 397 // Computes a new RedirectInfo based on receiving a redirect response of |
| 395 // |location| and |http_status_code|. | 398 // |location| and |http_status_code|. |
| 396 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); | 399 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); |
| 397 | 400 |
| 401 // Notify the network delegate that more bytes have been received over the |
| 402 // network, if bytes have been received since the previous notification. |
| 403 // TODO(sclittle): Have this method also notify about sent bytes once |
| 404 // URLRequestJob::GetTotalSentBytes has been implemented (crbug.com/518897). |
| 405 void MaybeNotifyNetworkBytes(); |
| 406 |
| 398 // Indicates that the job is done producing data, either it has completed | 407 // Indicates that the job is done producing data, either it has completed |
| 399 // all the data or an error has been encountered. Set exclusively by | 408 // all the data or an error has been encountered. Set exclusively by |
| 400 // NotifyDone so that it is kept in sync with the request. | 409 // NotifyDone so that it is kept in sync with the request. |
| 401 bool done_; | 410 bool done_; |
| 402 | 411 |
| 403 int64 prefilter_bytes_read_; | 412 int64 prefilter_bytes_read_; |
| 404 int64 postfilter_bytes_read_; | 413 int64 postfilter_bytes_read_; |
| 405 | 414 |
| 406 // The data stream filter which is enabled on demand. | 415 // The data stream filter which is enabled on demand. |
| 407 scoped_ptr<Filter> filter_; | 416 scoped_ptr<Filter> filter_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 427 | 436 |
| 428 // Expected content size | 437 // Expected content size |
| 429 int64 expected_content_size_; | 438 int64 expected_content_size_; |
| 430 | 439 |
| 431 // Set when a redirect is deferred. | 440 // Set when a redirect is deferred. |
| 432 RedirectInfo deferred_redirect_info_; | 441 RedirectInfo deferred_redirect_info_; |
| 433 | 442 |
| 434 // The network delegate to use with this request, if any. | 443 // The network delegate to use with this request, if any. |
| 435 NetworkDelegate* network_delegate_; | 444 NetworkDelegate* network_delegate_; |
| 436 | 445 |
| 446 // The value from GetTotalReceivedBytes() the last time |
| 447 // MaybeNotifyNetworkBytes() was called. Used to calculate how bytes have been |
| 448 // newly received since the last notification. |
| 449 int64_t last_notified_total_received_bytes_; |
| 450 |
| 437 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 451 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
| 438 | 452 |
| 439 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 453 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
| 440 }; | 454 }; |
| 441 | 455 |
| 442 } // namespace net | 456 } // namespace net |
| 443 | 457 |
| 444 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 458 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| OLD | NEW |