Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: net/url_request/url_fetcher.h

Issue 2421333002: Protobuf for Traffic Annotation and first use by a URLFetcher. (Closed)
Patch Set: More comments added. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // This function should not be used in Chromium, please use the version with
110 // NetworkTrafficAnnotationTag 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 // This function should not be used in Chromium, please use the version with
120 // NetworkTrafficAnnotationTag 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. Note that:
132 // - net provides the API for tagging requests with an opaque identifier.
133 // - tools/traffic_annotation/traffic_annotation.proto contains the Chrome
134 // specific .proto describing the verbose annotation format that Chrome's
135 // callsites are expected to follow.
136 // - tools/traffic_annotation/ contains sample and template for annotation and
137 // tools will be added for verification following crbug.com/690323.
138 static std::unique_ptr<URLFetcher> Create(
139 const GURL& url,
140 URLFetcher::RequestType request_type,
141 URLFetcherDelegate* d,
142 NetworkTrafficAnnotationTag traffic_annotation);
143
144 // Like above, but if there's a URLFetcherFactory registered with the
145 // implementation it will be used. |id| may be used during testing to identify
146 // who is creating the URLFetcher.
116 static std::unique_ptr<URLFetcher> Create( 147 static std::unique_ptr<URLFetcher> Create(
117 int id, 148 int id,
118 const GURL& url, 149 const GURL& url,
119 URLFetcher::RequestType request_type, 150 URLFetcher::RequestType request_type,
120 URLFetcherDelegate* d); 151 URLFetcherDelegate* d,
152 NetworkTrafficAnnotationTag traffic_annotation);
121 153
122 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. 154 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates.
123 // Note that any new URLFetchers created while this is running will not be 155 // 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 156 // 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 157 // 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 158 // 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. 159 // thread though, even though the task won't ever run.
128 static void CancelAll(); 160 static void CancelAll();
129 161
130 // Normally, URLFetcher will abort loads that request SSL client certificate 162 // Normally, URLFetcher will abort loads that request SSL client certificate
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // be removed once the URLFetcher is destroyed. User should not take 361 // be removed once the URLFetcher is destroyed. User should not take
330 // ownership more than once, or call this method after taking ownership. 362 // ownership more than once, or call this method after taking ownership.
331 virtual bool GetResponseAsFilePath( 363 virtual bool GetResponseAsFilePath(
332 bool take_ownership, 364 bool take_ownership,
333 base::FilePath* out_response_path) const = 0; 365 base::FilePath* out_response_path) const = 0;
334 }; 366 };
335 367
336 } // namespace net 368 } // namespace net
337 369
338 #endif // NET_URL_REQUEST_URL_FETCHER_H_ 370 #endif // NET_URL_REQUEST_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « net/traffic_annotation/network_traffic_annotation_test_helper.h ('k') | net/url_request/url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698