| 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_FETCHER_CORE_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_CORE_H_ |
| 6 #define NET_URL_REQUEST_URL_FETCHER_CORE_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_CORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "net/base/chunked_upload_data_stream.h" | 20 #include "net/base/chunked_upload_data_stream.h" |
| 21 #include "net/base/host_port_pair.h" | 21 #include "net/base/host_port_pair.h" |
| 22 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
| 23 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 23 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
| 24 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
| 25 #include "net/url_request/url_request_context_getter_observer.h" | 26 #include "net/url_request/url_request_context_getter_observer.h" |
| 26 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 namespace base { | 30 namespace base { |
| 30 class SequencedTaskRunner; | 31 class SequencedTaskRunner; |
| 31 class SingleThreadTaskRunner; | 32 class SingleThreadTaskRunner; |
| 32 } // namespace base | 33 } // namespace base |
| 33 | 34 |
| 34 namespace net { | 35 namespace net { |
| 35 class DrainableIOBuffer; | 36 class DrainableIOBuffer; |
| 36 class HttpResponseHeaders; | 37 class HttpResponseHeaders; |
| 37 class IOBuffer; | 38 class IOBuffer; |
| 38 class URLFetcherDelegate; | 39 class URLFetcherDelegate; |
| 39 class URLFetcherResponseWriter; | 40 class URLFetcherResponseWriter; |
| 40 class URLRequestContextGetter; | 41 class URLRequestContextGetter; |
| 41 class URLRequestThrottlerEntryInterface; | 42 class URLRequestThrottlerEntryInterface; |
| 42 | 43 |
| 43 class URLFetcherCore : public base::RefCountedThreadSafe<URLFetcherCore>, | 44 class URLFetcherCore : public base::RefCountedThreadSafe<URLFetcherCore>, |
| 44 public URLRequest::Delegate, | 45 public URLRequest::Delegate, |
| 45 public URLRequestContextGetterObserver { | 46 public URLRequestContextGetterObserver { |
| 46 public: | 47 public: |
| 47 URLFetcherCore(URLFetcher* fetcher, | 48 URLFetcherCore(URLFetcher* fetcher, |
| 48 const GURL& original_url, | 49 const GURL& original_url, |
| 49 URLFetcher::RequestType request_type, | 50 URLFetcher::RequestType request_type, |
| 50 URLFetcherDelegate* d); | 51 URLFetcherDelegate* d, |
| 52 const net::NetworkTrafficAnnotationTag traffic_annotation); |
| 51 | 53 |
| 52 // Starts the load. It's important that this not happen in the constructor | 54 // Starts the load. It's important that this not happen in the constructor |
| 53 // because it causes the IO thread to begin AddRef()ing and Release()ing | 55 // because it causes the IO thread to begin AddRef()ing and Release()ing |
| 54 // us. If our caller hasn't had time to fully construct us and take a | 56 // us. If our caller hasn't had time to fully construct us and take a |
| 55 // reference, the IO thread could interrupt things, run a task, Release() | 57 // reference, the IO thread could interrupt things, run a task, Release() |
| 56 // us, and destroy us, leaving the caller with an already-destroyed object | 58 // us, and destroy us, leaving the caller with an already-destroyed object |
| 57 // when construction finishes. | 59 // when construction finishes. |
| 58 void Start(); | 60 void Start(); |
| 59 | 61 |
| 60 // Stops any in-progress load and ensures no callback will happen. It is | 62 // Stops any in-progress load and ensures no callback will happen. It is |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // Timer to poll the progress of uploading for POST and PUT requests. | 341 // Timer to poll the progress of uploading for POST and PUT requests. |
| 340 // When crbug.com/119629 is fixed, scoped_ptr is not necessary here. | 342 // When crbug.com/119629 is fixed, scoped_ptr is not necessary here. |
| 341 std::unique_ptr<base::RepeatingTimer> upload_progress_checker_timer_; | 343 std::unique_ptr<base::RepeatingTimer> upload_progress_checker_timer_; |
| 342 // Number of bytes sent so far. | 344 // Number of bytes sent so far. |
| 343 int64_t current_upload_bytes_; | 345 int64_t current_upload_bytes_; |
| 344 // Number of bytes received so far. | 346 // Number of bytes received so far. |
| 345 int64_t current_response_bytes_; | 347 int64_t current_response_bytes_; |
| 346 // Total expected bytes to receive (-1 if it cannot be determined). | 348 // Total expected bytes to receive (-1 if it cannot be determined). |
| 347 int64_t total_response_bytes_; | 349 int64_t total_response_bytes_; |
| 348 | 350 |
| 351 const net::NetworkTrafficAnnotationTag traffic_annotation_; |
| 352 |
| 349 static base::LazyInstance<Registry>::DestructorAtExit g_registry; | 353 static base::LazyInstance<Registry>::DestructorAtExit g_registry; |
| 350 | 354 |
| 351 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore); | 355 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore); |
| 352 }; | 356 }; |
| 353 | 357 |
| 354 } // namespace net | 358 } // namespace net |
| 355 | 359 |
| 356 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_ | 360 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_ |
| OLD | NEW |