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