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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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_CORE_H_ 5 #ifndef NET_URL_REQUEST_URL_FETCHER_CORE_H_
6 #define NET_URL_REQUEST_URL_FETCHER_CORE_H_ 6 #define NET_URL_REQUEST_URL_FETCHER_CORE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 namespace net { 30 namespace net {
31 class DrainableIOBuffer; 31 class DrainableIOBuffer;
32 class HttpResponseHeaders; 32 class HttpResponseHeaders;
33 class IOBuffer; 33 class IOBuffer;
34 class URLFetcherDelegate; 34 class URLFetcherDelegate;
35 class URLFetcherResponseWriter; 35 class URLFetcherResponseWriter;
36 class URLRequestContextGetter; 36 class URLRequestContextGetter;
37 class URLRequestThrottlerEntryInterface; 37 class URLRequestThrottlerEntryInterface;
38 38
39 class URLFetcherCore 39 class URLFetcherCore : public base::RefCountedThreadSafe<URLFetcherCore>,
40 : public base::RefCountedThreadSafe<URLFetcherCore>, 40 public URLRequest::Delegate {
41 public URLRequest::Delegate {
42 public: 41 public:
43 URLFetcherCore(URLFetcher* fetcher, 42 URLFetcherCore(URLFetcher* fetcher,
44 const GURL& original_url, 43 const GURL& original_url,
45 URLFetcher::RequestType request_type, 44 URLFetcher::RequestType request_type,
46 URLFetcherDelegate* d); 45 URLFetcherDelegate* d);
47 46
48 // Starts the load. It's important that this not happen in the constructor 47 // Starts the load. It's important that this not happen in the constructor
49 // because it causes the IO thread to begin AddRef()ing and Release()ing 48 // because it causes the IO thread to begin AddRef()ing and Release()ing
50 // us. If our caller hasn't had time to fully construct us and take a 49 // us. If our caller hasn't had time to fully construct us and take a
51 // reference, the IO thread could interrupt things, run a task, Release() 50 // reference, the IO thread could interrupt things, run a task, Release()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void ReceivedContentWasMalformed(); 118 void ReceivedContentWasMalformed();
120 bool GetResponseAsString(std::string* out_response_string) const; 119 bool GetResponseAsString(std::string* out_response_string) const;
121 bool GetResponseAsFilePath(bool take_ownership, 120 bool GetResponseAsFilePath(bool take_ownership,
122 base::FilePath* out_response_path); 121 base::FilePath* out_response_path);
123 122
124 // Overridden from URLRequest::Delegate: 123 // Overridden from URLRequest::Delegate:
125 virtual void OnReceivedRedirect(URLRequest* request, 124 virtual void OnReceivedRedirect(URLRequest* request,
126 const GURL& new_url, 125 const GURL& new_url,
127 bool* defer_redirect) OVERRIDE; 126 bool* defer_redirect) OVERRIDE;
128 virtual void OnResponseStarted(URLRequest* request) OVERRIDE; 127 virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
129 virtual void OnReadCompleted(URLRequest* request, 128 virtual void OnReadCompleted(URLRequest* request, int bytes_read) OVERRIDE;
130 int bytes_read) OVERRIDE;
131 virtual void OnCertificateRequested( 129 virtual void OnCertificateRequested(
132 URLRequest* request, 130 URLRequest* request,
133 SSLCertRequestInfo* cert_request_info) OVERRIDE; 131 SSLCertRequestInfo* cert_request_info) OVERRIDE;
134 132
135 URLFetcherDelegate* delegate() const { return delegate_; } 133 URLFetcherDelegate* delegate() const { return delegate_; }
136 static void CancelAll(); 134 static void CancelAll();
137 static int GetNumFetcherCores(); 135 static int GetNumFetcherCores();
138 static void SetEnableInterceptionForTests(bool enabled); 136 static void SetEnableInterceptionForTests(bool enabled);
139 static void SetIgnoreCertificateRequests(bool ignored); 137 static void SetIgnoreCertificateRequests(bool ignored);
140 138
141 private: 139 private:
142 friend class base::RefCountedThreadSafe<URLFetcherCore>; 140 friend class base::RefCountedThreadSafe<URLFetcherCore>;
143 141
144 class Registry { 142 class Registry {
145 public: 143 public:
146 Registry(); 144 Registry();
147 ~Registry(); 145 ~Registry();
148 146
149 void AddURLFetcherCore(URLFetcherCore* core); 147 void AddURLFetcherCore(URLFetcherCore* core);
150 void RemoveURLFetcherCore(URLFetcherCore* core); 148 void RemoveURLFetcherCore(URLFetcherCore* core);
151 149
152 void CancelAll(); 150 void CancelAll();
153 151
154 int size() const { 152 int size() const { return fetchers_.size(); }
155 return fetchers_.size();
156 }
157 153
158 private: 154 private:
159 std::set<URLFetcherCore*> fetchers_; 155 std::set<URLFetcherCore*> fetchers_;
160 156
161 DISALLOW_COPY_AND_ASSIGN(Registry); 157 DISALLOW_COPY_AND_ASSIGN(Registry);
162 }; 158 };
163 159
164 virtual ~URLFetcherCore(); 160 virtual ~URLFetcherCore();
165 161
166 // Wrapper functions that allow us to ensure actions happen on the right 162 // Wrapper functions that allow us to ensure actions happen on the right
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Read response bytes from the request. 194 // Read response bytes from the request.
199 void ReadResponse(); 195 void ReadResponse();
200 196
201 // Notify Delegate about the progress of upload/download. 197 // Notify Delegate about the progress of upload/download.
202 void InformDelegateUploadProgress(); 198 void InformDelegateUploadProgress();
203 void InformDelegateUploadProgressInDelegateThread(int64 current, int64 total); 199 void InformDelegateUploadProgressInDelegateThread(int64 current, int64 total);
204 void InformDelegateDownloadProgress(); 200 void InformDelegateDownloadProgress();
205 void InformDelegateDownloadProgressInDelegateThread(int64 current, 201 void InformDelegateDownloadProgressInDelegateThread(int64 current,
206 int64 total); 202 int64 total);
207 203
208 URLFetcher* fetcher_; // Corresponding fetcher object 204 URLFetcher* fetcher_; // Corresponding fetcher object
209 GURL original_url_; // The URL we were asked to fetch 205 GURL original_url_; // The URL we were asked to fetch
210 GURL url_; // The URL we eventually wound up at 206 GURL url_; // The URL we eventually wound up at
211 URLFetcher::RequestType request_type_; // What type of request is this? 207 URLFetcher::RequestType request_type_; // What type of request is this?
212 URLRequestStatus status_; // Status of the request 208 URLRequestStatus status_; // Status of the request
213 URLFetcherDelegate* delegate_; // Object to notify on completion 209 URLFetcherDelegate* delegate_; // Object to notify on completion
214 // Task runner for the creating thread. Used to interact with the delegate. 210 // Task runner for the creating thread. Used to interact with the delegate.
215 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; 211 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_;
216 // Task runner for network operations. 212 // Task runner for network operations.
217 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 213 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
218 // Task runner for upload file access. 214 // Task runner for upload file access.
219 scoped_refptr<base::TaskRunner> upload_file_task_runner_; 215 scoped_refptr<base::TaskRunner> upload_file_task_runner_;
220 scoped_ptr<URLRequest> request_; // The actual request this wraps 216 scoped_ptr<URLRequest> request_; // The actual request this wraps
221 int load_flags_; // Flags for the load operation 217 int load_flags_; // Flags for the load operation
222 int response_code_; // HTTP status code for the request 218 int response_code_; // HTTP status code for the request
223 scoped_refptr<IOBuffer> buffer_; 219 scoped_refptr<IOBuffer> buffer_;
224 // Read buffer 220 // Read buffer
225 scoped_refptr<URLRequestContextGetter> request_context_getter_; 221 scoped_refptr<URLRequestContextGetter> request_context_getter_;
226 // Cookie/cache info for the request 222 // Cookie/cache info for the request
227 GURL first_party_for_cookies_; // The first party URL for the request 223 GURL first_party_for_cookies_; // The first party URL for the request
228 // The user data to add to each newly-created URLRequest. 224 // The user data to add to each newly-created URLRequest.
229 const void* url_request_data_key_; 225 const void* url_request_data_key_;
230 URLFetcher::CreateDataCallback url_request_create_data_callback_; 226 URLFetcher::CreateDataCallback url_request_create_data_callback_;
231 ResponseCookies cookies_; // Response cookies 227 ResponseCookies cookies_; // Response cookies
232 HttpRequestHeaders extra_request_headers_; 228 HttpRequestHeaders extra_request_headers_;
233 scoped_refptr<HttpResponseHeaders> response_headers_; 229 scoped_refptr<HttpResponseHeaders> response_headers_;
234 bool was_fetched_via_proxy_; 230 bool was_fetched_via_proxy_;
235 HostPortPair socket_address_; 231 HostPortPair socket_address_;
236 232
237 bool upload_content_set_; // SetUploadData has been called 233 bool upload_content_set_; // SetUploadData has been called
238 std::string upload_content_; // HTTP POST payload 234 std::string upload_content_; // HTTP POST payload
239 base::FilePath upload_file_path_; // Path to file containing POST payload 235 base::FilePath upload_file_path_; // Path to file containing POST payload
240 uint64 upload_range_offset_; // Offset from the beginning of the file 236 uint64 upload_range_offset_; // Offset from the beginning of the file
241 // to be uploaded. 237 // to be uploaded.
242 uint64 upload_range_length_; // The length of the part of file to be 238 uint64 upload_range_length_; // The length of the part of file to be
243 // uploaded. 239 // uploaded.
244 std::string upload_content_type_; // MIME type of POST payload 240 std::string upload_content_type_; // MIME type of POST payload
245 std::string referrer_; // HTTP Referer header value and policy 241 std::string referrer_; // HTTP Referer header value and policy
246 URLRequest::ReferrerPolicy referrer_policy_; 242 URLRequest::ReferrerPolicy referrer_policy_;
247 bool is_chunked_upload_; // True if using chunked transfer encoding 243 bool is_chunked_upload_; // True if using chunked transfer encoding
248 244
249 // Used to determine how long to wait before making a request or doing a 245 // Used to determine how long to wait before making a request or doing a
250 // retry. 246 // retry.
251 // 247 //
252 // Both of them can only be accessed on the IO thread. 248 // Both of them can only be accessed on the IO thread.
253 // 249 //
254 // We need not only the throttler entry for |original_URL|, but also 250 // We need not only the throttler entry for |original_URL|, but also
255 // the one for |url|. For example, consider the case that URL A 251 // the one for |url|. For example, consider the case that URL A
256 // redirects to URL B, for which the server returns a 500 252 // redirects to URL B, for which the server returns a 500
257 // response. In this case, the exponential back-off release time of 253 // response. In this case, the exponential back-off release time of
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 base::debug::StackTrace stack_trace_; 312 base::debug::StackTrace stack_trace_;
317 313
318 static base::LazyInstance<Registry> g_registry; 314 static base::LazyInstance<Registry> g_registry;
319 315
320 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore); 316 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore);
321 }; 317 };
322 318
323 } // namespace net 319 } // namespace net
324 320
325 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_ 321 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698