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