Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "googleurl/src/gurl.h" | |
| 14 #include "net/base/filter.h" | 15 #include "net/base/filter.h" |
| 15 #include "net/base/load_states.h" | 16 #include "net/base/load_states.h" |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 class AuthChallengeInfo; | 19 class AuthChallengeInfo; |
| 19 class HttpResponseInfo; | 20 class HttpResponseInfo; |
| 20 class IOBuffer; | 21 class IOBuffer; |
| 21 class UploadData; | 22 class UploadData; |
| 22 class X509Certificate; | 23 class X509Certificate; |
| 23 } | 24 } |
| 24 | 25 |
| 25 class GURL; | |
| 26 class URLRequest; | 26 class URLRequest; |
| 27 class URLRequestStatus; | 27 class URLRequestStatus; |
| 28 class URLRequestJobMetrics; | 28 class URLRequestJobMetrics; |
| 29 | 29 |
| 30 // The URLRequestJob is using RefCounterThreadSafe because some sub classes | 30 // The URLRequestJob is using RefCounterThreadSafe because some sub classes |
| 31 // can be destroyed on multiple threads. This is the case of the | 31 // can be destroyed on multiple threads. This is the case of the |
| 32 // UrlRequestFileJob. | 32 // UrlRequestFileJob. |
| 33 class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, | 33 class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, |
| 34 public FilterContext { | 34 public FilterContext { |
| 35 public: | 35 public: |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 const std::wstring& password); | 175 const std::wstring& password); |
| 176 | 176 |
| 177 // Display the error page without asking for credentials again. | 177 // Display the error page without asking for credentials again. |
| 178 virtual void CancelAuth(); | 178 virtual void CancelAuth(); |
| 179 | 179 |
| 180 virtual void ContinueWithCertificate(net::X509Certificate* client_cert); | 180 virtual void ContinueWithCertificate(net::X509Certificate* client_cert); |
| 181 | 181 |
| 182 // Continue processing the request ignoring the last error. | 182 // Continue processing the request ignoring the last error. |
| 183 virtual void ContinueDespiteLastError(); | 183 virtual void ContinueDespiteLastError(); |
| 184 | 184 |
| 185 void FollowDeferredRedirect(); | |
| 186 | |
| 185 // Returns true if the Job is done producing response data and has called | 187 // Returns true if the Job is done producing response data and has called |
| 186 // NotifyDone on the request. | 188 // NotifyDone on the request. |
| 187 bool is_done() const { return done_; } | 189 bool is_done() const { return done_; } |
| 188 | 190 |
| 189 // Returns true if the job is doing performance profiling | 191 // Returns true if the job is doing performance profiling |
| 190 bool is_profiling() const { return is_profiling_; } | 192 bool is_profiling() const { return is_profiling_; } |
| 191 | 193 |
| 192 // Retrieve the performance measurement of the job. The data is encapsulated | 194 // Retrieve the performance measurement of the job. The data is encapsulated |
| 193 // with a URLRequestJobMetrics object. The caller owns this object from now | 195 // with a URLRequestJobMetrics object. The caller owns this object from now |
| 194 // on. | 196 // on. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 | 298 |
| 297 private: | 299 private: |
| 298 // Size of filter input buffers used by this class. | 300 // Size of filter input buffers used by this class. |
| 299 static const int kFilterBufSize; | 301 static const int kFilterBufSize; |
| 300 | 302 |
| 301 // When data filtering is enabled, this function is used to read data | 303 // When data filtering is enabled, this function is used to read data |
| 302 // for the filter. Returns true if raw data was read. Returns false if | 304 // for the filter. Returns true if raw data was read. Returns false if |
| 303 // an error occurred (or we are waiting for IO to complete). | 305 // an error occurred (or we are waiting for IO to complete). |
| 304 bool ReadRawDataForFilter(int *bytes_read); | 306 bool ReadRawDataForFilter(int *bytes_read); |
| 305 | 307 |
| 306 // Called in response to a redirect that was not canceled to follow the | |
| 307 // redirect. The current job will be replaced with a new job loading the | |
| 308 // given redirect destination. | |
| 309 void FollowRedirect(const GURL& location, int http_status_code); | |
| 310 | |
| 311 // Updates the profiling info and notifies observers that bytes_read bytes | 308 // Updates the profiling info and notifies observers that bytes_read bytes |
| 312 // have been read. | 309 // have been read. |
| 313 void RecordBytesRead(int bytes_read); | 310 void RecordBytesRead(int bytes_read); |
| 314 | 311 |
| 315 // Called to query whether there is data available in the filter to be read | 312 // Called to query whether there is data available in the filter to be read |
| 316 // out. | 313 // out. |
| 317 bool FilterHasData(); | 314 bool FilterHasData(); |
| 318 | 315 |
| 319 // Record packet arrival times for possible use in histograms. | 316 // Record packet arrival times for possible use in histograms. |
| 320 void UpdatePacketReadTimes(); | 317 void UpdatePacketReadTimes(); |
| 321 | 318 |
| 319 // Called in response to a redirect that was not canceled to follow the | |
| 320 // redirect. The current job will be replaced with a new job loading the | |
| 321 // given redirect destination. | |
| 322 void FollowRedirect(const GURL& location, int http_status_code); | |
|
wtc
2009/07/23 00:30:12
Nit: move this method back to its original locatio
darin (slow to review)
2009/07/23 01:27:29
Done.
| |
| 323 | |
| 322 // Indicates that the job is done producing data, either it has completed | 324 // Indicates that the job is done producing data, either it has completed |
| 323 // all the data or an error has been encountered. Set exclusively by | 325 // all the data or an error has been encountered. Set exclusively by |
| 324 // NotifyDone so that it is kept in sync with the request. | 326 // NotifyDone so that it is kept in sync with the request. |
| 325 bool done_; | 327 bool done_; |
| 326 | 328 |
| 327 // Cache the load flags from request_ because it might go away. | 329 // Cache the load flags from request_ because it might go away. |
| 328 int load_flags_; | 330 int load_flags_; |
| 329 | 331 |
| 330 // The data stream filter which is enabled on demand. | 332 // The data stream filter which is enabled on demand. |
| 331 scoped_ptr<Filter> filter_; | 333 scoped_ptr<Filter> filter_; |
| 332 | 334 |
| 333 // If the filter filled its output buffer, then there is a change that it | 335 // If the filter filled its output buffer, then there is a change that it |
| 334 // still has internal data to emit, and this flag is set. | 336 // still has internal data to emit, and this flag is set. |
| 335 bool filter_needs_more_output_space_; | 337 bool filter_needs_more_output_space_; |
| 336 | 338 |
| 337 // When we filter data, we receive data into the filter buffers. After | 339 // When we filter data, we receive data into the filter buffers. After |
| 338 // processing the filtered data, we return the data in the caller's buffer. | 340 // processing the filtered data, we return the data in the caller's buffer. |
| 339 // While the async IO is in progress, we save the user buffer here, and | 341 // While the async IO is in progress, we save the user buffer here, and |
| 340 // when the IO completes, we fill this in. | 342 // when the IO completes, we fill this in. |
| 341 net::IOBuffer *read_buffer_; | 343 net::IOBuffer *read_buffer_; |
| 342 int read_buffer_len_; | 344 int read_buffer_len_; |
| 343 | 345 |
| 344 // Used by HandleResponseIfNecessary to track whether we've sent the | 346 // Used by HandleResponseIfNecessary to track whether we've sent the |
| 345 // OnResponseStarted callback and potentially redirect callbacks as well. | 347 // OnResponseStarted callback and potentially redirect callbacks as well. |
| 346 bool has_handled_response_; | 348 bool has_handled_response_; |
| 347 | 349 |
| 348 // Expected content size | 350 // Expected content size |
| 349 int64 expected_content_size_; | 351 int64 expected_content_size_; |
| 350 | 352 |
| 353 // Set when a redirect is deferred. | |
| 354 GURL deferred_redirect_url_; | |
| 355 int deferred_redirect_status_code_; | |
| 356 | |
| 351 //---------------------------------------------------------------------------- | 357 //---------------------------------------------------------------------------- |
| 352 // Data used for statistics gathering in some instances. This data is only | 358 // Data used for statistics gathering in some instances. This data is only |
| 353 // used for histograms etc., and is not required. It is optionally gathered | 359 // used for histograms etc., and is not required. It is optionally gathered |
| 354 // based on the settings of several control variables. | 360 // based on the settings of several control variables. |
| 355 | 361 |
| 356 // Enable recording of packet arrival times for histogramming. | 362 // Enable recording of packet arrival times for histogramming. |
| 357 bool packet_timing_enabled_; | 363 bool packet_timing_enabled_; |
| 358 | 364 |
| 359 // TODO(jar): improve the quality of the gathered info by gathering most times | 365 // TODO(jar): improve the quality of the gathered info by gathering most times |
| 360 // at a lower point in the network stack, assuring we have actual packet | 366 // at a lower point in the network stack, assuring we have actual packet |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 387 base::Time final_packet_time_; | 393 base::Time final_packet_time_; |
| 388 | 394 |
| 389 // The count of the number of packets, some of which may not have been timed. | 395 // The count of the number of packets, some of which may not have been timed. |
| 390 // We're ignoring overflow, as 1430 x 2^31 is a LOT of bytes. | 396 // We're ignoring overflow, as 1430 x 2^31 is a LOT of bytes. |
| 391 int observed_packet_count_; | 397 int observed_packet_count_; |
| 392 | 398 |
| 393 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 399 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
| 394 }; | 400 }; |
| 395 | 401 |
| 396 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 402 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| OLD | NEW |