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

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

Issue 20378: Reduce the amount of included header files. Vast change like in "Oh God! This... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_REQUEST_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_
6 #define NET_URL_REQUEST_URL_REQUEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h"
12 #include "base/logging.h"
13 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
14 #include "base/time.h" 12 #include "base/time.h"
15 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
16 #include "net/base/load_states.h" 14 #include "net/base/load_states.h"
17 #include "net/base/ssl_info.h"
18 #include "net/base/upload_data.h"
19 #include "net/base/x509_certificate.h"
20 #include "net/http/http_response_info.h" 15 #include "net/http/http_response_info.h"
21 #include "net/url_request/url_request_context.h"
22 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
23 17
24 namespace net { 18 namespace net {
19
25 class IOBuffer; 20 class IOBuffer;
21 class UploadData;
22 class X509Certificate;
23
26 } 24 }
25
26 class URLRequestContext;
27 class URLRequestJob; 27 class URLRequestJob;
28 28
29 // This stores the values of the Set-Cookie headers received during the request. 29 // This stores the values of the Set-Cookie headers received during the request.
30 // Each item in the vector corresponds to a Set-Cookie: line received, 30 // Each item in the vector corresponds to a Set-Cookie: line received,
31 // excluding the "Set-Cookie:" part. 31 // excluding the "Set-Cookie:" part.
32 typedef std::vector<std::string> ResponseCookies; 32 typedef std::vector<std::string> ResponseCookies;
33 33
34 //----------------------------------------------------------------------------- 34 //-----------------------------------------------------------------------------
35 // A class representing the asynchronous load of a data stream from an URL. 35 // A class representing the asynchronous load of a data stream from an URL.
36 // 36 //
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 static bool IsHandledURL(const GURL& url); 196 static bool IsHandledURL(const GURL& url);
197 197
198 // The original url is the url used to initialize the request, and it may 198 // The original url is the url used to initialize the request, and it may
199 // differ from the url if the request was redirected. 199 // differ from the url if the request was redirected.
200 const GURL& original_url() const { return original_url_; } 200 const GURL& original_url() const { return original_url_; }
201 const GURL& url() const { return url_; } 201 const GURL& url() const { return url_; }
202 202
203 // The URL that should be consulted for the third-party cookie blocking 203 // The URL that should be consulted for the third-party cookie blocking
204 // policy. 204 // policy.
205 const GURL& policy_url() const { return policy_url_; } 205 const GURL& policy_url() const { return policy_url_; }
206 void set_policy_url(const GURL& policy_url) { 206 void set_policy_url(const GURL& policy_url);
207 DCHECK(!is_pending_);
208 policy_url_ = policy_url;
209 }
210 207
211 // The request method, as an uppercase string. "GET" is the default value. 208 // The request method, as an uppercase string. "GET" is the default value.
212 // The request method may only be changed before Start() is called and 209 // The request method may only be changed before Start() is called and
213 // should only be assigned an uppercase value. 210 // should only be assigned an uppercase value.
214 const std::string& method() const { return method_; } 211 const std::string& method() const { return method_; }
215 void set_method(const std::string& method) { 212 void set_method(const std::string& method);
216 DCHECK(!is_pending_);
217 method_ = method;
218 }
219 213
220 // The referrer URL for the request. This header may actually be suppressed 214 // The referrer URL for the request. This header may actually be suppressed
221 // from the underlying network request for security reasons (e.g., a HTTPS 215 // from the underlying network request for security reasons (e.g., a HTTPS
222 // URL will not be sent as the referrer for a HTTP request). The referrer 216 // URL will not be sent as the referrer for a HTTP request). The referrer
223 // may only be changed before Start() is called. 217 // may only be changed before Start() is called.
224 const std::string& referrer() const { return referrer_; } 218 const std::string& referrer() const { return referrer_; }
225 void set_referrer(const std::string& referrer) { 219 void set_referrer(const std::string& referrer);
226 DCHECK(!is_pending_);
227 referrer_ = referrer;
228 }
229 220
230 // The delegate of the request. This value may be changed at any time, 221 // The delegate of the request. This value may be changed at any time,
231 // and it is permissible for it to be null. 222 // and it is permissible for it to be null.
232 Delegate* delegate() const { return delegate_; } 223 Delegate* delegate() const { return delegate_; }
233 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 224 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
234 225
235 // The data comprising the request message body is specified as a sequence of 226 // The data comprising the request message body is specified as a sequence of
236 // data segments and/or files containing data to upload. These methods may 227 // data segments and/or files containing data to upload. These methods may
237 // be called to construct the data sequence to upload, and they may only be 228 // be called to construct the data sequence to upload, and they may only be
238 // called before Start() is called. For POST requests, the user must call 229 // called before Start() is called. For POST requests, the user must call
239 // SetRequestHeaderBy{Id,Name} to set the Content-Type of the request to the 230 // SetRequestHeaderBy{Id,Name} to set the Content-Type of the request to the
240 // appropriate value before calling Start(). 231 // appropriate value before calling Start().
241 // 232 //
242 // When uploading data, bytes_len must be non-zero. 233 // When uploading data, bytes_len must be non-zero.
243 // When uploading a file range, length must be non-zero. If length 234 // When uploading a file range, length must be non-zero. If length
244 // exceeds the end-of-file, the upload is clipped at end-of-file. 235 // exceeds the end-of-file, the upload is clipped at end-of-file.
245 void AppendBytesToUpload(const char* bytes, int bytes_len); 236 void AppendBytesToUpload(const char* bytes, int bytes_len);
246 void AppendFileRangeToUpload(const std::wstring& file_path, 237 void AppendFileRangeToUpload(const std::wstring& file_path,
247 uint64 offset, uint64 length); 238 uint64 offset, uint64 length);
248 void AppendFileToUpload(const std::wstring& file_path) { 239 void AppendFileToUpload(const std::wstring& file_path) {
249 AppendFileRangeToUpload(file_path, 0, kuint64max); 240 AppendFileRangeToUpload(file_path, 0, kuint64max);
250 } 241 }
251 242
252 // Set the upload data directly. 243 // Set the upload data directly.
253 void set_upload(net::UploadData* upload) { upload_ = upload; } 244 void set_upload(net::UploadData* upload);
254 245
255 // Get the upload data directly. 246 // Get the upload data directly.
256 net::UploadData* get_upload() { return upload_.get(); } 247 net::UploadData* get_upload();
257 248
258 // Returns true if the request has a non-empty message body to upload. 249 // Returns true if the request has a non-empty message body to upload.
259 bool has_upload() const { return upload_ != NULL; } 250 bool has_upload() const;
260 251
261 // Set an extra request header by ID or name. These methods may only be 252 // Set an extra request header by ID or name. These methods may only be
262 // called before Start() is called. It is an error to call it later. 253 // called before Start() is called. It is an error to call it later.
263 void SetExtraRequestHeaderById(int header_id, const std::string& value, 254 void SetExtraRequestHeaderById(int header_id, const std::string& value,
264 bool overwrite); 255 bool overwrite);
265 void SetExtraRequestHeaderByName(const std::string& name, 256 void SetExtraRequestHeaderByName(const std::string& name,
266 const std::string& value, bool overwrite); 257 const std::string& value, bool overwrite);
267 258
268 // Sets all extra request headers, from a \r\n-delimited string. Any extra 259 // Sets all extra request headers, from a \r\n-delimited string. Any extra
269 // request headers set by other methods are overwritten by this method. This 260 // request headers set by other methods are overwritten by this method. This
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // responses, this may be a time well in the past. 293 // responses, this may be a time well in the past.
303 const base::Time& response_time() const { 294 const base::Time& response_time() const {
304 return response_info_.response_time; 295 return response_info_.response_time;
305 } 296 }
306 297
307 // Indicate if this response was fetched from disk cache. 298 // Indicate if this response was fetched from disk cache.
308 bool was_cached() const { return response_info_.was_cached; } 299 bool was_cached() const { return response_info_.was_cached; }
309 300
310 // Get all response headers, as a HttpResponseHeaders object. See comments 301 // Get all response headers, as a HttpResponseHeaders object. See comments
311 // in HttpResponseHeaders class as to the format of the data. 302 // in HttpResponseHeaders class as to the format of the data.
312 net::HttpResponseHeaders* response_headers() const { 303 net::HttpResponseHeaders* response_headers() const;
313 return response_info_.headers.get();
314 }
315 304
316 // Get the SSL connection info. 305 // Get the SSL connection info.
317 const net::SSLInfo& ssl_info() const { 306 const net::SSLInfo& ssl_info() const {
318 return response_info_.ssl_info; 307 return response_info_.ssl_info;
319 } 308 }
320 309
321 // Returns the cookie values included in the response, if the request is one 310 // Returns the cookie values included in the response, if the request is one
322 // that can have cookies. Returns true if the request is a cookie-bearing 311 // that can have cookies. Returns true if the request is a cookie-bearing
323 // type, false otherwise. This method may only be called once the 312 // type, false otherwise. This method may only be called once the
324 // delegate's OnResponseStarted method has been called. 313 // delegate's OnResponseStarted method has been called.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 #undef HTTP_ATOM 403 #undef HTTP_ATOM
415 }; 404 };
416 405
417 // Returns true if performance profiling should be enabled on the 406 // Returns true if performance profiling should be enabled on the
418 // URLRequestJob serving this request. 407 // URLRequestJob serving this request.
419 bool enable_profiling() const { return enable_profiling_; } 408 bool enable_profiling() const { return enable_profiling_; }
420 409
421 void set_enable_profiling(bool profiling) { enable_profiling_ = profiling; } 410 void set_enable_profiling(bool profiling) { enable_profiling_ = profiling; }
422 411
423 // Used to specify the context (cookie store, cache) for this request. 412 // Used to specify the context (cookie store, cache) for this request.
424 URLRequestContext* context() { return context_.get(); } 413 URLRequestContext* context();
425 void set_context(URLRequestContext* context) { context_ = context; } 414 void set_context(URLRequestContext* context);
426 415
427 // Returns the expected content size if available 416 // Returns the expected content size if available
428 int64 GetExpectedContentSize() const; 417 int64 GetExpectedContentSize() const;
429 418
430 protected: 419 protected:
431 // Allow the URLRequestJob class to control the is_pending() flag. 420 // Allow the URLRequestJob class to control the is_pending() flag.
432 void set_is_pending(bool value) { is_pending_ = value; } 421 void set_is_pending(bool value) { is_pending_ = value; }
433 422
434 // Allow the URLRequestJob class to set our status too 423 // Allow the URLRequestJob class to set our status too
435 void set_status(const URLRequestStatus &value) { status_ = value; } 424 void set_status(const URLRequestStatus &value) { status_ = value; }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // infinite redirects. 479 // infinite redirects.
491 int redirect_limit_; 480 int redirect_limit_;
492 481
493 // Contextual information used for this request (can be NULL). 482 // Contextual information used for this request (can be NULL).
494 scoped_refptr<URLRequestContext> context_; 483 scoped_refptr<URLRequestContext> context_;
495 484
496 // Cached value for use after we've orphaned the job handling the 485 // Cached value for use after we've orphaned the job handling the
497 // first transaction in a request involving redirects. 486 // first transaction in a request involving redirects.
498 uint64 final_upload_progress_; 487 uint64 final_upload_progress_;
499 488
500 DISALLOW_EVIL_CONSTRUCTORS(URLRequest); 489 DISALLOW_COPY_AND_ASSIGN(URLRequest);
501 }; 490 };
502 491
503 //----------------------------------------------------------------------------- 492 //-----------------------------------------------------------------------------
504 // To help ensure that all requests are cleaned up properly, we keep static 493 // To help ensure that all requests are cleaned up properly, we keep static
505 // counters of live objects. TODO(darin): Move this leak checking stuff into 494 // counters of live objects. TODO(darin): Move this leak checking stuff into
506 // a common place and generalize it so it can be used everywhere (Bug 566229). 495 // a common place and generalize it so it can be used everywhere (Bug 566229).
507 496
508 #ifndef NDEBUG 497 #ifndef NDEBUG
509 498
510 struct URLRequestMetrics { 499 struct URLRequestMetrics {
511 int object_count; 500 int object_count;
512 URLRequestMetrics() : object_count(0) {} 501 URLRequestMetrics() : object_count(0) {}
513 ~URLRequestMetrics() { 502 ~URLRequestMetrics();
514 DLOG_IF(WARNING, object_count != 0) <<
515 "Leaking " << object_count << " URLRequest object(s)";
516 }
517 }; 503 };
518 504
519 extern URLRequestMetrics url_request_metrics; 505 extern URLRequestMetrics url_request_metrics;
520 506
521 #define URLREQUEST_COUNT_CTOR() url_request_metrics.object_count++ 507 #define URLREQUEST_COUNT_CTOR() url_request_metrics.object_count++
522 #define URLREQUEST_COUNT_DTOR() url_request_metrics.object_count-- 508 #define URLREQUEST_COUNT_DTOR() url_request_metrics.object_count--
523 509
524 #else // disable leak checking in release builds... 510 #else // disable leak checking in release builds...
525 511
526 #define URLREQUEST_COUNT_CTOR() 512 #define URLREQUEST_COUNT_CTOR()
527 #define URLREQUEST_COUNT_DTOR() 513 #define URLREQUEST_COUNT_DTOR()
528 514
529 #endif 515 #endif // #ifndef NDEBUG
530
531 516
532 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 517 #endif // NET_URL_REQUEST_URL_REQUEST_H_
533
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698