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/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
24 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
25 #include "net/url_request/url_request_context_getter_observer.h" | 25 #include "net/url_request/url_request_context_getter_observer.h" |
26 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 namespace base { | 29 namespace base { |
| 30 class SequencedTaskRunner; |
30 class SingleThreadTaskRunner; | 31 class SingleThreadTaskRunner; |
31 } // namespace base | 32 } // namespace base |
32 | 33 |
33 namespace net { | 34 namespace net { |
34 class DrainableIOBuffer; | 35 class DrainableIOBuffer; |
35 class HttpResponseHeaders; | 36 class HttpResponseHeaders; |
36 class IOBuffer; | 37 class IOBuffer; |
37 class URLFetcherDelegate; | 38 class URLFetcherDelegate; |
38 class URLFetcherResponseWriter; | 39 class URLFetcherResponseWriter; |
39 class URLRequestContextGetter; | 40 class URLRequestContextGetter; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 int WriteBuffer(scoped_refptr<DrainableIOBuffer> data); | 210 int WriteBuffer(scoped_refptr<DrainableIOBuffer> data); |
210 | 211 |
211 // Used to implement WriteBuffer(). | 212 // Used to implement WriteBuffer(). |
212 void DidWriteBuffer(scoped_refptr<DrainableIOBuffer> data, int result); | 213 void DidWriteBuffer(scoped_refptr<DrainableIOBuffer> data, int result); |
213 | 214 |
214 // Read response bytes from the request. | 215 // Read response bytes from the request. |
215 void ReadResponse(); | 216 void ReadResponse(); |
216 | 217 |
217 // Notify Delegate about the progress of upload/download. | 218 // Notify Delegate about the progress of upload/download. |
218 void InformDelegateUploadProgress(); | 219 void InformDelegateUploadProgress(); |
219 void InformDelegateUploadProgressInDelegateThread(int64_t current, | 220 void InformDelegateUploadProgressInDelegateSequence(int64_t current, |
220 int64_t total); | 221 int64_t total); |
221 void InformDelegateDownloadProgress(); | 222 void InformDelegateDownloadProgress(); |
222 void InformDelegateDownloadProgressInDelegateThread( | 223 void InformDelegateDownloadProgressInDelegateSequence( |
223 int64_t current, | 224 int64_t current, |
224 int64_t total, | 225 int64_t total, |
225 int64_t current_network_bytes); | 226 int64_t current_network_bytes); |
226 | 227 |
227 // Check if any upload data is set or not. | 228 // Check if any upload data is set or not. |
228 void AssertHasNoUploadData() const; | 229 void AssertHasNoUploadData() const; |
229 | 230 |
230 URLFetcher* fetcher_; // Corresponding fetcher object | 231 URLFetcher* fetcher_; // Corresponding fetcher object |
231 GURL original_url_; // The URL we were asked to fetch | 232 GURL original_url_; // The URL we were asked to fetch |
232 GURL url_; // The URL we eventually wound up at | 233 GURL url_; // The URL we eventually wound up at |
233 URLFetcher::RequestType request_type_; // What type of request is this? | 234 URLFetcher::RequestType request_type_; // What type of request is this? |
234 URLRequestStatus status_; // Status of the request | 235 URLRequestStatus status_; // Status of the request |
235 URLFetcherDelegate* delegate_; // Object to notify on completion | 236 URLFetcherDelegate* delegate_; // Object to notify on completion |
236 // Task runner for the creating thread. Used to interact with the delegate. | 237 // Task runner for the creating sequence. Used to interact with the delegate. |
237 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; | 238 const scoped_refptr<base::SequencedTaskRunner> delegate_task_runner_; |
238 // Task runner for network operations. | 239 // Task runner for network operations. |
239 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 240 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
240 // Task runner for upload file access. | 241 // Task runner for upload file access. |
241 scoped_refptr<base::TaskRunner> upload_file_task_runner_; | 242 scoped_refptr<base::TaskRunner> upload_file_task_runner_; |
242 std::unique_ptr<URLRequest> request_; // The actual request this wraps | 243 std::unique_ptr<URLRequest> request_; // The actual request this wraps |
243 int load_flags_; // Flags for the load operation | 244 int load_flags_; // Flags for the load operation |
244 int response_code_; // HTTP status code for the request | 245 int response_code_; // HTTP status code for the request |
245 scoped_refptr<IOBuffer> buffer_; | 246 scoped_refptr<IOBuffer> buffer_; |
246 // Read buffer | 247 // Read buffer |
247 scoped_refptr<URLRequestContextGetter> request_context_getter_; | 248 scoped_refptr<URLRequestContextGetter> request_context_getter_; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 int64_t total_response_bytes_; | 347 int64_t total_response_bytes_; |
347 | 348 |
348 static base::LazyInstance<Registry> g_registry; | 349 static base::LazyInstance<Registry> g_registry; |
349 | 350 |
350 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore); | 351 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore); |
351 }; | 352 }; |
352 | 353 |
353 } // namespace net | 354 } // namespace net |
354 | 355 |
355 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_ | 356 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_ |
OLD | NEW |