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 // This file contains URLFetcher, a wrapper around URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around URLRequest that handles |
6 // low-level details like thread safety, ref counting, and incremental buffer | 6 // low-level details like thread safety, ref counting, and incremental buffer |
7 // reading. This is useful for callers who simply want to get the data from a | 7 // reading. This is useful for callers who simply want to get the data from a |
8 // URL and don't care about all the nitty-gritty details. | 8 // URL and don't care about all the nitty-gritty details. |
9 // | 9 // |
10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a | 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a |
11 // temporary situation. We will work on allowing support for multiple "io" | 11 // temporary situation. We will work on allowing support for multiple "io" |
12 // threads per process. | 12 // threads per process. |
13 | 13 |
14 #ifndef NET_URL_REQUEST_URL_FETCHER_IMPL_H_ | 14 #ifndef NET_URL_REQUEST_URL_FETCHER_IMPL_H_ |
15 #define NET_URL_REQUEST_URL_FETCHER_IMPL_H_ | 15 #define NET_URL_REQUEST_URL_FETCHER_IMPL_H_ |
16 | 16 |
17 #include <stdint.h> | 17 #include <stdint.h> |
18 | 18 |
19 #include <string> | 19 #include <string> |
20 | 20 |
21 #include "base/basictypes.h" | 21 #include "base/macros.h" |
22 #include "base/compiler_specific.h" | |
23 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
24 #include "net/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
25 | 24 |
26 namespace net { | 25 namespace net { |
27 class URLFetcherCore; | 26 class URLFetcherCore; |
28 class URLFetcherDelegate; | 27 class URLFetcherDelegate; |
29 class URLFetcherFactory; | 28 class URLFetcherFactory; |
30 | 29 |
31 class NET_EXPORT_PRIVATE URLFetcherImpl : public URLFetcher { | 30 class NET_EXPORT_PRIVATE URLFetcherImpl : public URLFetcher { |
32 public: | 31 public: |
33 // |url| is the URL to send the request to. | 32 // |url| is the URL to send the request to. |
34 // |request_type| is the type of request to make. | 33 // |request_type| is the type of request to make. |
35 // |d| the object that will receive the callback on fetch completion. | 34 // |d| the object that will receive the callback on fetch completion. |
36 URLFetcherImpl(const GURL& url, | 35 URLFetcherImpl(const GURL& url, |
37 RequestType request_type, | 36 RequestType request_type, |
38 URLFetcherDelegate* d); | 37 URLFetcherDelegate* d); |
39 ~URLFetcherImpl() override; | 38 ~URLFetcherImpl() override; |
40 | 39 |
41 // URLFetcher implementation: | 40 // URLFetcher implementation: |
42 void SetUploadData(const std::string& upload_content_type, | 41 void SetUploadData(const std::string& upload_content_type, |
43 const std::string& upload_content) override; | 42 const std::string& upload_content) override; |
44 void SetUploadFilePath( | 43 void SetUploadFilePath( |
45 const std::string& upload_content_type, | 44 const std::string& upload_content_type, |
46 const base::FilePath& file_path, | 45 const base::FilePath& file_path, |
47 uint64 range_offset, | 46 uint64_t range_offset, |
48 uint64 range_length, | 47 uint64_t range_length, |
49 scoped_refptr<base::TaskRunner> file_task_runner) override; | 48 scoped_refptr<base::TaskRunner> file_task_runner) override; |
50 void SetUploadStreamFactory( | 49 void SetUploadStreamFactory( |
51 const std::string& upload_content_type, | 50 const std::string& upload_content_type, |
52 const CreateUploadStreamCallback& callback) override; | 51 const CreateUploadStreamCallback& callback) override; |
53 void SetChunkedUpload(const std::string& upload_content_type) override; | 52 void SetChunkedUpload(const std::string& upload_content_type) override; |
54 void AppendChunkToUpload(const std::string& data, | 53 void AppendChunkToUpload(const std::string& data, |
55 bool is_last_chunk) override; | 54 bool is_last_chunk) override; |
56 void SetLoadFlags(int load_flags) override; | 55 void SetLoadFlags(int load_flags) override; |
57 int GetLoadFlags() const override; | 56 int GetLoadFlags() const override; |
58 void SetReferrer(const std::string& referrer) override; | 57 void SetReferrer(const std::string& referrer) override; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 static int GetNumFetcherCores(); | 123 static int GetNumFetcherCores(); |
125 | 124 |
126 const scoped_refptr<URLFetcherCore> core_; | 125 const scoped_refptr<URLFetcherCore> core_; |
127 | 126 |
128 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl); | 127 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl); |
129 }; | 128 }; |
130 | 129 |
131 } // namespace net | 130 } // namespace net |
132 | 131 |
133 #endif // NET_URL_REQUEST_URL_FETCHER_IMPL_H_ | 132 #endif // NET_URL_REQUEST_URL_FETCHER_IMPL_H_ |
OLD | NEW |