| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 // The status of the job. | 333 // The status of the job. |
| 334 const URLRequestStatus GetStatus(); | 334 const URLRequestStatus GetStatus(); |
| 335 | 335 |
| 336 // Set the status of the job. | 336 // Set the status of the job. |
| 337 void SetStatus(const URLRequestStatus& status); | 337 void SetStatus(const URLRequestStatus& status); |
| 338 | 338 |
| 339 // Set the proxy server that was used, if any. | 339 // Set the proxy server that was used, if any. |
| 340 void SetProxyServer(const HostPortPair& proxy_server); | 340 void SetProxyServer(const HostPortPair& proxy_server); |
| 341 | 341 |
| 342 // The number of bytes read before passing to the filter. | 342 // The number of bytes read before passing to the filter. This value reflects |
| 343 // bytes read even when there is no filter. |
| 343 int64 prefilter_bytes_read() const { return prefilter_bytes_read_; } | 344 int64 prefilter_bytes_read() const { return prefilter_bytes_read_; } |
| 344 | 345 |
| 345 // The number of bytes read after passing through the filter. | 346 // The number of bytes read after passing through the filter. This value |
| 347 // reflects bytes read even when there is no filter. |
| 346 int64 postfilter_bytes_read() const { return postfilter_bytes_read_; } | 348 int64 postfilter_bytes_read() const { return postfilter_bytes_read_; } |
| 347 | 349 |
| 348 // Total number of bytes read from network (or cache) and typically handed | |
| 349 // to filter to process. Used to histogram compression ratios, and error | |
| 350 // recovery scenarios in filters. | |
| 351 int64 filter_input_byte_count() const { return filter_input_byte_count_; } | |
| 352 | |
| 353 // The request that initiated this job. This value MAY BE NULL if the | 350 // The request that initiated this job. This value MAY BE NULL if the |
| 354 // request was released by DetachRequest(). | 351 // request was released by DetachRequest(). |
| 355 URLRequest* request_; | 352 URLRequest* request_; |
| 356 | 353 |
| 357 private: | 354 private: |
| 358 // When data filtering is enabled, this function is used to read data | 355 // When data filtering is enabled, this function is used to read data |
| 359 // for the filter. Returns true if raw data was read. Returns false if | 356 // for the filter. Returns true if raw data was read. Returns false if |
| 360 // an error occurred (or we are waiting for IO to complete). | 357 // an error occurred (or we are waiting for IO to complete). |
| 361 bool ReadRawDataForFilter(int *bytes_read); | 358 bool ReadRawDataForFilter(int *bytes_read); |
| 362 | 359 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 377 | 374 |
| 378 // Updates the profiling info and notifies observers that an additional | 375 // Updates the profiling info and notifies observers that an additional |
| 379 // |bytes_read| unfiltered bytes have been read for this job. | 376 // |bytes_read| unfiltered bytes have been read for this job. |
| 380 void RecordBytesRead(int bytes_read); | 377 void RecordBytesRead(int bytes_read); |
| 381 | 378 |
| 382 // Called to query whether there is data available in the filter to be read | 379 // Called to query whether there is data available in the filter to be read |
| 383 // out. | 380 // out. |
| 384 bool FilterHasData(); | 381 bool FilterHasData(); |
| 385 | 382 |
| 386 // Subclasses may implement this method to record packet arrival times. | 383 // Subclasses may implement this method to record packet arrival times. |
| 387 // The default implementation does nothing. | 384 // The default implementation does nothing. Only invoked when bytes have been |
| 385 // read since the last invocation. |
| 388 virtual void UpdatePacketReadTimes(); | 386 virtual void UpdatePacketReadTimes(); |
| 389 | 387 |
| 390 // Computes a new RedirectInfo based on receiving a redirect response of | 388 // Computes a new RedirectInfo based on receiving a redirect response of |
| 391 // |location| and |http_status_code|. | 389 // |location| and |http_status_code|. |
| 392 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); | 390 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); |
| 393 | 391 |
| 394 // 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 |
| 395 // 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 |
| 396 // NotifyDone so that it is kept in sync with the request. | 394 // NotifyDone so that it is kept in sync with the request. |
| 397 bool done_; | 395 bool done_; |
| 398 | 396 |
| 399 int64 prefilter_bytes_read_; | 397 int64 prefilter_bytes_read_; |
| 400 int64 postfilter_bytes_read_; | 398 int64 postfilter_bytes_read_; |
| 401 int64 filter_input_byte_count_; | |
| 402 | 399 |
| 403 // The data stream filter which is enabled on demand. | 400 // The data stream filter which is enabled on demand. |
| 404 scoped_ptr<Filter> filter_; | 401 scoped_ptr<Filter> filter_; |
| 405 | 402 |
| 406 // If the filter filled its output buffer, then there is a change that it | 403 // If the filter filled its output buffer, then there is a change that it |
| 407 // still has internal data to emit, and this flag is set. | 404 // still has internal data to emit, and this flag is set. |
| 408 bool filter_needs_more_output_space_; | 405 bool filter_needs_more_output_space_; |
| 409 | 406 |
| 410 // When we filter data, we receive data into the filter buffers. After | 407 // When we filter data, we receive data into the filter buffers. After |
| 411 // processing the filtered data, we return the data in the caller's buffer. | 408 // processing the filtered data, we return the data in the caller's buffer. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 432 NetworkDelegate* network_delegate_; | 429 NetworkDelegate* network_delegate_; |
| 433 | 430 |
| 434 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 431 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
| 435 | 432 |
| 436 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 433 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
| 437 }; | 434 }; |
| 438 | 435 |
| 439 } // namespace net | 436 } // namespace net |
| 440 | 437 |
| 441 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 438 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| OLD | NEW |