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 <string> | 10 #include <string> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Continue with the network request. | 207 // Continue with the network request. |
208 virtual void ResumeNetworkStart(); | 208 virtual void ResumeNetworkStart(); |
209 | 209 |
210 void FollowDeferredRedirect(); | 210 void FollowDeferredRedirect(); |
211 | 211 |
212 // Returns true if the Job is done producing response data and has called | 212 // Returns true if the Job is done producing response data and has called |
213 // NotifyDone on the request. | 213 // NotifyDone on the request. |
214 bool is_done() const { return done_; } | 214 bool is_done() const { return done_; } |
215 | 215 |
216 // Get/Set expected content size | 216 // Get/Set expected content size |
217 int64 expected_content_size() const { return expected_content_size_; } | 217 int64_t expected_content_size() const { return expected_content_size_; } |
218 void set_expected_content_size(const int64& size) { | 218 void set_expected_content_size(const int64_t& size) { |
219 expected_content_size_ = size; | 219 expected_content_size_ = size; |
220 } | 220 } |
221 | 221 |
222 // Whether we have processed the response for that request yet. | 222 // Whether we have processed the response for that request yet. |
223 bool has_response_started() const { return has_handled_response_; } | 223 bool has_response_started() const { return has_handled_response_; } |
224 | 224 |
225 // These methods are not applicable to all connections. | 225 // These methods are not applicable to all connections. |
226 virtual bool GetMimeType(std::string* mime_type) const; | 226 virtual bool GetMimeType(std::string* mime_type) const; |
227 virtual int GetResponseCode() const; | 227 virtual int GetResponseCode() const; |
228 | 228 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 const URLRequestStatus GetStatus(); | 338 const URLRequestStatus GetStatus(); |
339 | 339 |
340 // Set the status of the job. | 340 // Set the status of the job. |
341 void SetStatus(const URLRequestStatus& status); | 341 void SetStatus(const URLRequestStatus& status); |
342 | 342 |
343 // Set the proxy server that was used, if any. | 343 // Set the proxy server that was used, if any. |
344 void SetProxyServer(const HostPortPair& proxy_server); | 344 void SetProxyServer(const HostPortPair& proxy_server); |
345 | 345 |
346 // The number of bytes read before passing to the filter. This value reflects | 346 // The number of bytes read before passing to the filter. This value reflects |
347 // bytes read even when there is no filter. | 347 // bytes read even when there is no filter. |
348 int64 prefilter_bytes_read() const { return prefilter_bytes_read_; } | 348 int64_t prefilter_bytes_read() const { return prefilter_bytes_read_; } |
349 | 349 |
350 // The number of bytes read after passing through the filter. This value | 350 // The number of bytes read after passing through the filter. This value |
351 // reflects bytes read even when there is no filter. | 351 // reflects bytes read even when there is no filter. |
352 int64 postfilter_bytes_read() const { return postfilter_bytes_read_; } | 352 int64_t postfilter_bytes_read() const { return postfilter_bytes_read_; } |
353 | 353 |
354 // Turns an integer result code into an Error and a count of bytes read. | 354 // Turns an integer result code into an Error and a count of bytes read. |
355 // The semantics are: | 355 // The semantics are: |
356 // |result| >= 0: |*error| == OK, |*count| == |result| | 356 // |result| >= 0: |*error| == OK, |*count| == |result| |
357 // |result| < 0: |*error| = |result|, |*count| == 0 | 357 // |result| < 0: |*error| = |result|, |*count| == 0 |
358 static void ConvertResultToError(int result, Error* error, int* count); | 358 static void ConvertResultToError(int result, Error* error, int* count); |
359 | 359 |
360 // Completion callback for raw reads. See |ReadRawData| for details. | 360 // Completion callback for raw reads. See |ReadRawData| for details. |
361 // |bytes_read| is either >= 0 to indicate a successful read and count of | 361 // |bytes_read| is either >= 0 to indicate a successful read and count of |
362 // bytes read, or < 0 to indicate an error. | 362 // bytes read, or < 0 to indicate an error. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // Notify the network delegate that more bytes have been received or sent over | 419 // Notify the network delegate that more bytes have been received or sent over |
420 // the network, if bytes have been received or sent since the previous | 420 // the network, if bytes have been received or sent since the previous |
421 // notification. | 421 // notification. |
422 void MaybeNotifyNetworkBytes(); | 422 void MaybeNotifyNetworkBytes(); |
423 | 423 |
424 // Indicates that the job is done producing data, either it has completed | 424 // Indicates that the job is done producing data, either it has completed |
425 // all the data or an error has been encountered. Set exclusively by | 425 // all the data or an error has been encountered. Set exclusively by |
426 // NotifyDone so that it is kept in sync with the request. | 426 // NotifyDone so that it is kept in sync with the request. |
427 bool done_; | 427 bool done_; |
428 | 428 |
429 int64 prefilter_bytes_read_; | 429 int64_t prefilter_bytes_read_; |
430 int64 postfilter_bytes_read_; | 430 int64_t postfilter_bytes_read_; |
431 | 431 |
432 // The data stream filter which is enabled on demand. | 432 // The data stream filter which is enabled on demand. |
433 scoped_ptr<Filter> filter_; | 433 scoped_ptr<Filter> filter_; |
434 | 434 |
435 // If the filter filled its output buffer, then there is a change that it | 435 // If the filter filled its output buffer, then there is a change that it |
436 // still has internal data to emit, and this flag is set. | 436 // still has internal data to emit, and this flag is set. |
437 bool filter_needs_more_output_space_; | 437 bool filter_needs_more_output_space_; |
438 | 438 |
439 // When we filter data, we receive data into the filter buffers. After | 439 // When we filter data, we receive data into the filter buffers. After |
440 // processing the filtered data, we return the data in the caller's buffer. | 440 // processing the filtered data, we return the data in the caller's buffer. |
441 // While the async IO is in progress, we save the user buffer here, and | 441 // While the async IO is in progress, we save the user buffer here, and |
442 // when the IO completes, we fill this in. | 442 // when the IO completes, we fill this in. |
443 scoped_refptr<IOBuffer> filtered_read_buffer_; | 443 scoped_refptr<IOBuffer> filtered_read_buffer_; |
444 int filtered_read_buffer_len_; | 444 int filtered_read_buffer_len_; |
445 | 445 |
446 // We keep a pointer to the read buffer while asynchronous reads are | 446 // We keep a pointer to the read buffer while asynchronous reads are |
447 // in progress, so we are able to pass those bytes to job observers. | 447 // in progress, so we are able to pass those bytes to job observers. |
448 scoped_refptr<IOBuffer> raw_read_buffer_; | 448 scoped_refptr<IOBuffer> raw_read_buffer_; |
449 | 449 |
450 // Used by HandleResponseIfNecessary to track whether we've sent the | 450 // Used by HandleResponseIfNecessary to track whether we've sent the |
451 // OnResponseStarted callback and potentially redirect callbacks as well. | 451 // OnResponseStarted callback and potentially redirect callbacks as well. |
452 bool has_handled_response_; | 452 bool has_handled_response_; |
453 | 453 |
454 // Expected content size | 454 // Expected content size |
455 int64 expected_content_size_; | 455 int64_t expected_content_size_; |
456 | 456 |
457 // Set when a redirect is deferred. | 457 // Set when a redirect is deferred. |
458 RedirectInfo deferred_redirect_info_; | 458 RedirectInfo deferred_redirect_info_; |
459 | 459 |
460 // The network delegate to use with this request, if any. | 460 // The network delegate to use with this request, if any. |
461 NetworkDelegate* network_delegate_; | 461 NetworkDelegate* network_delegate_; |
462 | 462 |
463 // The value from GetTotalReceivedBytes() the last time | 463 // The value from GetTotalReceivedBytes() the last time |
464 // MaybeNotifyNetworkBytes() was called. Used to calculate how bytes have been | 464 // MaybeNotifyNetworkBytes() was called. Used to calculate how bytes have been |
465 // newly received since the last notification. | 465 // newly received since the last notification. |
466 int64_t last_notified_total_received_bytes_; | 466 int64_t last_notified_total_received_bytes_; |
467 | 467 |
468 // The value from GetTotalSentBytes() the last time MaybeNotifyNetworkBytes() | 468 // The value from GetTotalSentBytes() the last time MaybeNotifyNetworkBytes() |
469 // was called. Used to calculate how bytes have been newly sent since the last | 469 // was called. Used to calculate how bytes have been newly sent since the last |
470 // notification. | 470 // notification. |
471 int64_t last_notified_total_sent_bytes_; | 471 int64_t last_notified_total_sent_bytes_; |
472 | 472 |
473 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 473 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
474 | 474 |
475 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 475 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
476 }; | 476 }; |
477 | 477 |
478 } // namespace net | 478 } // namespace net |
479 | 479 |
480 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 480 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
OLD | NEW |