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_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_H_ |
6 #define NET_URL_REQUEST_URL_FETCHER_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 18 #include "net/traffic_annotation/network_traffic_annotation.h" |
18 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
19 | 20 |
20 class GURL; | 21 class GURL; |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class FilePath; | 24 class FilePath; |
24 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
25 class TaskRunner; | 26 class TaskRunner; |
26 class TimeDelta; | 27 class TimeDelta; |
27 } | 28 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Used by SetUploadStreamFactory. The callback should assign a fresh upload | 100 // Used by SetUploadStreamFactory. The callback should assign a fresh upload |
100 // data stream every time it's called. | 101 // data stream every time it's called. |
101 typedef base::Callback<std::unique_ptr<UploadDataStream>()> | 102 typedef base::Callback<std::unique_ptr<UploadDataStream>()> |
102 CreateUploadStreamCallback; | 103 CreateUploadStreamCallback; |
103 | 104 |
104 virtual ~URLFetcher(); | 105 virtual ~URLFetcher(); |
105 | 106 |
106 // |url| is the URL to send the request to. It must be valid. | 107 // |url| is the URL to send the request to. It must be valid. |
107 // |request_type| is the type of request to make. | 108 // |request_type| is the type of request to make. |
108 // |d| the object that will receive the callback on fetch completion. | 109 // |d| the object that will receive the callback on fetch completion. |
| 110 // DEPRECATED: Please use the version with NetworkTrafficAnnotationTag |
| 111 // below instead. |
109 static std::unique_ptr<URLFetcher> Create( | 112 static std::unique_ptr<URLFetcher> Create( |
110 const GURL& url, | 113 const GURL& url, |
111 URLFetcher::RequestType request_type, | 114 URLFetcher::RequestType request_type, |
112 URLFetcherDelegate* d); | 115 URLFetcherDelegate* d); |
113 | 116 |
114 // Like above, but if there's a URLFetcherFactory registered with the | 117 // Like above, but if there's a URLFetcherFactory registered with the |
115 // implementation it will be used. |id| may be used during testing to identify | 118 // implementation it will be used. |id| may be used during testing to identify |
116 // who is creating the URLFetcher. | 119 // who is creating the URLFetcher. |
| 120 // DEPRECATED: Please use the version with NetworkTrafficAnnotationTag |
| 121 // below instead. |
| 122 static std::unique_ptr<URLFetcher> Create( |
| 123 int id, |
| 124 const GURL& url, |
| 125 URLFetcher::RequestType request_type, |
| 126 URLFetcherDelegate* d); |
| 127 |
| 128 // |url| is the URL to send the request to. It must be valid. |
| 129 // |request_type| is the type of request to make. |
| 130 // |d| the object that will receive the callback on fetch completion. |
| 131 // |traffic_annotation| metadata about the network traffic send via this |
| 132 // URLFetcher. See net::DefineNetworkTrafficAnnotation. |
| 133 static std::unique_ptr<URLFetcher> Create( |
| 134 const GURL& url, |
| 135 URLFetcher::RequestType request_type, |
| 136 URLFetcherDelegate* d, |
| 137 NetworkTrafficAnnotationTag traffic_annotation); |
| 138 |
| 139 // Like above, but if there's a URLFetcherFactory registered with the |
| 140 // implementation it will be used. |id| may be used during testing to identify |
| 141 // who is creating the URLFetcher. |
117 static std::unique_ptr<URLFetcher> Create( | 142 static std::unique_ptr<URLFetcher> Create( |
118 int id, | 143 int id, |
119 const GURL& url, | 144 const GURL& url, |
120 URLFetcher::RequestType request_type, | 145 URLFetcher::RequestType request_type, |
121 URLFetcherDelegate* d); | 146 URLFetcherDelegate* d, |
| 147 NetworkTrafficAnnotationTag traffic_annotation); |
122 | 148 |
123 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. | 149 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. |
124 // Note that any new URLFetchers created while this is running will not be | 150 // Note that any new URLFetchers created while this is running will not be |
125 // cancelled. Typically, one would call this in the CleanUp() method of an IO | 151 // cancelled. Typically, one would call this in the CleanUp() method of an IO |
126 // thread, so that no new URLRequests would be able to start on the IO thread | 152 // thread, so that no new URLRequests would be able to start on the IO thread |
127 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO | 153 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO |
128 // thread though, even though the task won't ever run. | 154 // thread though, even though the task won't ever run. |
129 static void CancelAll(); | 155 static void CancelAll(); |
130 | 156 |
131 // Normally, URLFetcher will abort loads that request SSL client certificate | 157 // Normally, URLFetcher will abort loads that request SSL client certificate |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // be removed once the URLFetcher is destroyed. User should not take | 356 // be removed once the URLFetcher is destroyed. User should not take |
331 // ownership more than once, or call this method after taking ownership. | 357 // ownership more than once, or call this method after taking ownership. |
332 virtual bool GetResponseAsFilePath( | 358 virtual bool GetResponseAsFilePath( |
333 bool take_ownership, | 359 bool take_ownership, |
334 base::FilePath* out_response_path) const = 0; | 360 base::FilePath* out_response_path) const = 0; |
335 }; | 361 }; |
336 | 362 |
337 } // namespace net | 363 } // namespace net |
338 | 364 |
339 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 365 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
OLD | NEW |