| 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 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/power_monitor/power_observer.h" | 15 #include "base/power_monitor/power_observer.h" |
| 16 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
| 17 #include "net/base/load_states.h" | 17 #include "net/base/load_states.h" |
| 18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 19 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
| 20 #include "net/base/upload_progress.h" | 20 #include "net/base/upload_progress.h" |
| 21 #include "net/cookies/canonical_cookie.h" | 21 #include "net/cookies/canonical_cookie.h" |
| 22 #include "net/url_request/redirect_info.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| 24 namespace net { | 25 namespace net { |
| 25 | 26 |
| 26 class AuthChallengeInfo; | 27 class AuthChallengeInfo; |
| 27 class AuthCredentials; | 28 class AuthCredentials; |
| 28 class CookieOptions; | 29 class CookieOptions; |
| 29 class CookieStore; | 30 class CookieStore; |
| 30 class Filter; | 31 class Filter; |
| 31 class HttpRequestHeaders; | 32 class HttpRequestHeaders; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // an error occurred (or we are waiting for IO to complete). | 358 // an error occurred (or we are waiting for IO to complete). |
| 358 bool ReadRawDataForFilter(int *bytes_read); | 359 bool ReadRawDataForFilter(int *bytes_read); |
| 359 | 360 |
| 360 // Invokes ReadRawData and records bytes read if the read completes | 361 // Invokes ReadRawData and records bytes read if the read completes |
| 361 // synchronously. | 362 // synchronously. |
| 362 bool ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read); | 363 bool ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read); |
| 363 | 364 |
| 364 // Called in response to a redirect that was not canceled to follow the | 365 // Called in response to a redirect that was not canceled to follow the |
| 365 // redirect. The current job will be replaced with a new job loading the | 366 // redirect. The current job will be replaced with a new job loading the |
| 366 // given redirect destination. | 367 // given redirect destination. |
| 367 void FollowRedirect(const GURL& location, int http_status_code); | 368 void FollowRedirect(const RedirectInfo& redirect_info); |
| 368 | 369 |
| 369 // Called after every raw read. If |bytes_read| is > 0, this indicates | 370 // Called after every raw read. If |bytes_read| is > 0, this indicates |
| 370 // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| | 371 // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| |
| 371 // is 0, this indicates that there is no additional data to read. If | 372 // is 0, this indicates that there is no additional data to read. If |
| 372 // |bytes_read| is < 0, an error occurred and no bytes were read. | 373 // |bytes_read| is < 0, an error occurred and no bytes were read. |
| 373 void OnRawReadComplete(int bytes_read); | 374 void OnRawReadComplete(int bytes_read); |
| 374 | 375 |
| 375 // Updates the profiling info and notifies observers that an additional | 376 // Updates the profiling info and notifies observers that an additional |
| 376 // |bytes_read| unfiltered bytes have been read for this job. | 377 // |bytes_read| unfiltered bytes have been read for this job. |
| 377 void RecordBytesRead(int bytes_read); | 378 void RecordBytesRead(int bytes_read); |
| 378 | 379 |
| 379 // Called to query whether there is data available in the filter to be read | 380 // Called to query whether there is data available in the filter to be read |
| 380 // out. | 381 // out. |
| 381 bool FilterHasData(); | 382 bool FilterHasData(); |
| 382 | 383 |
| 383 // Subclasses may implement this method to record packet arrival times. | 384 // Subclasses may implement this method to record packet arrival times. |
| 384 // The default implementation does nothing. | 385 // The default implementation does nothing. |
| 385 virtual void UpdatePacketReadTimes(); | 386 virtual void UpdatePacketReadTimes(); |
| 386 | 387 |
| 388 // Computes a new RedirectInfo based on receiving a redirect response of |
| 389 // |location| and |http_status_code|. |
| 390 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); |
| 391 |
| 387 // 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 |
| 388 // 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 |
| 389 // NotifyDone so that it is kept in sync with the request. | 394 // NotifyDone so that it is kept in sync with the request. |
| 390 bool done_; | 395 bool done_; |
| 391 | 396 |
| 392 int prefilter_bytes_read_; | 397 int prefilter_bytes_read_; |
| 393 int postfilter_bytes_read_; | 398 int postfilter_bytes_read_; |
| 394 int64 filter_input_byte_count_; | 399 int64 filter_input_byte_count_; |
| 395 | 400 |
| 396 // The data stream filter which is enabled on demand. | 401 // The data stream filter which is enabled on demand. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 412 scoped_refptr<IOBuffer> raw_read_buffer_; | 417 scoped_refptr<IOBuffer> raw_read_buffer_; |
| 413 | 418 |
| 414 // Used by HandleResponseIfNecessary to track whether we've sent the | 419 // Used by HandleResponseIfNecessary to track whether we've sent the |
| 415 // OnResponseStarted callback and potentially redirect callbacks as well. | 420 // OnResponseStarted callback and potentially redirect callbacks as well. |
| 416 bool has_handled_response_; | 421 bool has_handled_response_; |
| 417 | 422 |
| 418 // Expected content size | 423 // Expected content size |
| 419 int64 expected_content_size_; | 424 int64 expected_content_size_; |
| 420 | 425 |
| 421 // Set when a redirect is deferred. | 426 // Set when a redirect is deferred. |
| 422 GURL deferred_redirect_url_; | 427 RedirectInfo deferred_redirect_info_; |
| 423 int deferred_redirect_status_code_; | |
| 424 | 428 |
| 425 // The network delegate to use with this request, if any. | 429 // The network delegate to use with this request, if any. |
| 426 NetworkDelegate* network_delegate_; | 430 NetworkDelegate* network_delegate_; |
| 427 | 431 |
| 428 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 432 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
| 429 | 433 |
| 430 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 434 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
| 431 }; | 435 }; |
| 432 | 436 |
| 433 } // namespace net | 437 } // namespace net |
| 434 | 438 |
| 435 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 439 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| OLD | NEW |