1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_H_ 7 8 #include <map> 9 #include <string> 10 #include <vector> 11 12 #include "base/leak_tracker.h" 13 #include "base/linked_list.h" 14 #include "base/linked_ptr.h" 15 #include "base/logging.h" 16 #include "base/ref_counted.h" 17 #include "base/scoped_ptr.h" 18 #include "googleurl/src/gurl.h" 19 #include "net/base/load_log.h" 20 #include "net/base/load_states.h" 21 #include "net/base/request_priority.h" 22 #include "net/http/http_response_info.h" 23 #include "net/url_request/request_tracker.h" 24 #include "net/url_request/url_request_status.h" 25 26 namespace base { 27 class Time; 28 } // namespace base 29 30 namespace net { 31 class IOBuffer; 32 class SSLCertRequestInfo; 33 class UploadData; 34 class X509Certificate; 35 } // namespace net 36 37 class FilePath; 38 class URLRequestContext; 39 class URLRequestJob; 40 41 // This stores the values of the Set-Cookie headers received during the request. 42 // Each item in the vector corresponds to a Set-Cookie: line received, 43 // excluding the "Set-Cookie:" part. 44 typedef std::vector<std::string> ResponseCookies; 45 46 //----------------------------------------------------------------------------- 47 // A class representing the asynchronous load of a data stream from an URL. 48 // 49 // The lifetime of an instance of this class is completely controlled by the 50 // consumer, and the instance is not required to live on the heap or be 51 // allocated in any special way. It is also valid to delete an URLRequest 52 // object during the handling of a callback to its delegate. Of course, once 53 // the URLRequest is deleted, no further callbacks to its delegate will occur. 54 // 55 // NOTE: All usage of all instances of this class should be on the same thread. 56 // 57 class URLRequest { 58 public: 59 // Derive from this class and add your own data members to associate extra 60 // information with a URLRequest. Use GetUserData(key) and SetUserData() 61 class UserData { 62 public: UserData()63 UserData() {} ~UserData()64 virtual ~UserData() {} 65 }; 66 67 // Callback function implemented by protocol handlers to create new jobs. 68 // The factory may return NULL to indicate an error, which will cause other 69 // factories to be queried. If no factory handles the request, then the 70 // default job will be used. 71 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request, 72 const std::string& scheme); 73 74 // This class handles network interception. Use with 75 // (Un)RegisterRequestInterceptor. 76 class Interceptor { 77 public: ~Interceptor()78 virtual ~Interceptor() {} 79 80 // Called for every request made. Should return a new job to handle the 81 // request if it should be intercepted, or NULL to allow the request to 82 // be handled in the normal manner. 83 virtual URLRequestJob* MaybeIntercept(URLRequest* request) = 0; 84 85 // Called after having received a redirect response, but prior to the 86 // the request delegate being informed of the redirect. Can return a new 87 // job to replace the existing job if it should be intercepted, or NULL 88 // to allow the normal handling to continue. If a new job is provided, 89 // the delegate never sees the original redirect response, instead the 90 // response produced by the intercept job will be returned. MaybeInterceptRedirect(URLRequest * request,const GURL & location)91 virtual URLRequestJob* MaybeInterceptRedirect(URLRequest* request, 92 const GURL& location) { 93 return NULL; 94 } 95 96 // Called after having received a final response, but prior to the 97 // the request delegate being informed of the response. This is also 98 // called when there is no server response at all to allow interception 99 // on dns or network errors. Can return a new job to replace the existing 100 // job if it should be intercepted, or NULL to allow the normal handling to 101 // continue. If a new job is provided, the delegate never sees the original 102 // response, instead the response produced by the intercept job will be 103 // returned. MaybeInterceptResponse(URLRequest * request)104 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request) { 105 return NULL; 106 } 107 }; 108 109 // The delegate's methods are called from the message loop of the thread 110 // on which the request's Start() method is called. See above for the 111 // ordering of callbacks. 112 // 113 // The callbacks will be called in the following order: 114 // Start() 115 // - OnCertificateRequested* (zero or one call, if the SSL server 116 // requests a client certificate for authentication) 117 // - OnSSLCertificateError* (zero or one call, if the SSL server's 118 // certificate has an error) 119 // - OnReceivedRedirect* (zero or more calls, for the number of redirects) 120 // - OnAuthRequired* (zero or more calls, for the number of 121 // authentication failures) 122 // - OnResponseStarted 123 // Read() initiated by delegate 124 // - OnReadCompleted* (zero or more calls until all data is read) 125 // 126 // Read() must be called at least once. Read() returns true when it completed 127 // immediately, and false if an IO is pending or if there is an error. When 128 // Read() returns false, the caller can check the Request's status() to see 129 // if an error occurred, or if the IO is just pending. When Read() returns 130 // true with zero bytes read, it indicates the end of the response. 131 // 132 class Delegate { 133 public: ~Delegate()134 virtual ~Delegate() {} 135 136 // Called upon a server-initiated redirect. The delegate may call the 137 // request's Cancel method to prevent the redirect from being followed. 138 // Since there may be multiple chained redirects, there may also be more 139 // than one redirect call. 140 // 141 // When this function is called, the request will still contain the 142 // original URL, the destination of the redirect is provided in 'new_url'. 143 // If the delegate does not cancel the request and |*defer_redirect| is 144 // false, then the redirect will be followed, and the request's URL will be 145 // changed to the new URL. Otherwise if the delegate does not cancel the 146 // request and |*defer_redirect| is true, then the redirect will be 147 // followed once FollowDeferredRedirect is called on the URLRequest. 148 // 149 // The caller must set |*defer_redirect| to false, so that delegates do not 150 // need to set it if they are happy with the default behavior of not 151 // deferring redirect. OnReceivedRedirect(URLRequest * request,const GURL & new_url,bool * defer_redirect)152 virtual void OnReceivedRedirect(URLRequest* request, 153 const GURL& new_url, 154 bool* defer_redirect) { 155 } 156 157 // Called when we receive an authentication failure. The delegate should 158 // call request->SetAuth() with the user's credentials once it obtains them, 159 // or request->CancelAuth() to cancel the login and display the error page. 160 // When it does so, the request will be reissued, restarting the sequence 161 // of On* callbacks. OnAuthRequired(URLRequest * request,net::AuthChallengeInfo * auth_info)162 virtual void OnAuthRequired(URLRequest* request, 163 net::AuthChallengeInfo* auth_info) { 164 request->CancelAuth(); 165 } 166 167 // Called when we receive an SSL CertificateRequest message for client 168 // authentication. The delegate should call 169 // request->ContinueWithCertificate() with the client certificate the user 170 // selected, or request->ContinueWithCertificate(NULL) to continue the SSL 171 // handshake without a client certificate. OnCertificateRequested(URLRequest * request,net::SSLCertRequestInfo * cert_request_info)172 virtual void OnCertificateRequested( 173 URLRequest* request, 174 net::SSLCertRequestInfo* cert_request_info) { 175 request->ContinueWithCertificate(NULL); 176 } 177 178 // Called when using SSL and the server responds with a certificate with 179 // an error, for example, whose common name does not match the common name 180 // we were expecting for that host. The delegate should either do the 181 // safe thing and Cancel() the request or decide to proceed by calling 182 // ContinueDespiteLastError(). cert_error is a net::ERR_* error code 183 // indicating what's wrong with the certificate. OnSSLCertificateError(URLRequest * request,int cert_error,net::X509Certificate * cert)184 virtual void OnSSLCertificateError(URLRequest* request, 185 int cert_error, 186 net::X509Certificate* cert) { 187 request->Cancel(); 188 } 189 190 // After calling Start(), the delegate will receive an OnResponseStarted 191 // callback when the request has completed. If an error occurred, the 192 // request->status() will be set. On success, all redirects have been 193 // followed and the final response is beginning to arrive. At this point, 194 // meta data about the response is available, including for example HTTP 195 // response headers if this is a request for a HTTP resource. 196 virtual void OnResponseStarted(URLRequest* request) = 0; 197 198 // Called when the a Read of the response body is completed after an 199 // IO_PENDING status from a Read() call. 200 // The data read is filled into the buffer which the caller passed 201 // to Read() previously. 202 // 203 // If an error occurred, request->status() will contain the error, 204 // and bytes read will be -1. 205 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; 206 }; 207 208 // Initialize an URL request. 209 URLRequest(const GURL& url, Delegate* delegate); 210 211 // If destroyed after Start() has been called but while IO is pending, 212 // then the request will be effectively canceled and the delegate 213 // will not have any more of its methods called. 214 ~URLRequest(); 215 216 // The user data allows the clients to associate data with this request. 217 // Multiple user data values can be stored under different keys. 218 // This request will TAKE OWNERSHIP of the given data pointer, and will 219 // delete the object if it is changed or the request is destroyed. 220 UserData* GetUserData(const void* key) const; 221 void SetUserData(const void* key, UserData* data); 222 223 // Registers a new protocol handler for the given scheme. If the scheme is 224 // already handled, this will overwrite the given factory. To delete the 225 // protocol factory, use NULL for the factory BUT this WILL NOT put back 226 // any previously registered protocol factory. It will have returned 227 // the previously registered factory (or NULL if none is registered) when 228 // the scheme was first registered so that the caller can manually put it 229 // back if desired. 230 // 231 // The scheme must be all-lowercase ASCII. See the ProtocolFactory 232 // declaration for its requirements. 233 // 234 // The registered protocol factory may return NULL, which will cause the 235 // regular "built-in" protocol factory to be used. 236 // 237 static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme, 238 ProtocolFactory* factory); 239 240 // Registers or unregisters a network interception class. 241 static void RegisterRequestInterceptor(Interceptor* interceptor); 242 static void UnregisterRequestInterceptor(Interceptor* interceptor); 243 244 // Returns true if the scheme can be handled by URLRequest. False otherwise. 245 static bool IsHandledProtocol(const std::string& scheme); 246 247 // Returns true if the url can be handled by URLRequest. False otherwise. 248 // The function returns true for invalid urls because URLRequest knows how 249 // to handle those. 250 static bool IsHandledURL(const GURL& url); 251 252 // The original url is the url used to initialize the request, and it may 253 // differ from the url if the request was redirected. original_url()254 const GURL& original_url() const { return original_url_; } url()255 const GURL& url() const { return url_; } 256 257 // The URL that should be consulted for the third-party cookie blocking 258 // policy. first_party_for_cookies()259 const GURL& first_party_for_cookies() const { 260 return first_party_for_cookies_; 261 } 262 // This method may be called before Start() or FollowDeferredRedirect() is 263 // called. 264 void set_first_party_for_cookies(const GURL& first_party_for_cookies); 265 266 // The request method, as an uppercase string. "GET" is the default value. 267 // The request method may only be changed before Start() is called and 268 // should only be assigned an uppercase value. method()269 const std::string& method() const { return method_; } 270 void set_method(const std::string& method); 271 272 // The referrer URL for the request. This header may actually be suppressed 273 // from the underlying network request for security reasons (e.g., a HTTPS 274 // URL will not be sent as the referrer for a HTTP request). The referrer 275 // may only be changed before Start() is called. referrer()276 const std::string& referrer() const { return referrer_; } 277 void set_referrer(const std::string& referrer); 278 // Returns the referrer header with potential username and password removed. 279 GURL GetSanitizedReferrer() const; 280 281 // The delegate of the request. This value may be changed at any time, 282 // and it is permissible for it to be null. delegate()283 Delegate* delegate() const { return delegate_; } set_delegate(Delegate * delegate)284 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 285 286 // The data comprising the request message body is specified as a sequence of 287 // data segments and/or files containing data to upload. These methods may 288 // be called to construct the data sequence to upload, and they may only be 289 // called before Start() is called. For POST requests, the user must call 290 // SetRequestHeaderBy{Id,Name} to set the Content-Type of the request to the 291 // appropriate value before calling Start(). 292 // 293 // When uploading data, bytes_len must be non-zero. 294 // When uploading a file range, length must be non-zero. If length 295 // exceeds the end-of-file, the upload is clipped at end-of-file. 296 void AppendBytesToUpload(const char* bytes, int bytes_len); 297 void AppendFileRangeToUpload(const FilePath& file_path, 298 uint64 offset, uint64 length); AppendFileToUpload(const FilePath & file_path)299 void AppendFileToUpload(const FilePath& file_path) { 300 AppendFileRangeToUpload(file_path, 0, kuint64max); 301 } 302 303 // Set the upload data directly. 304 void set_upload(net::UploadData* upload); 305 306 // Get the upload data directly. 307 net::UploadData* get_upload(); 308 309 // Returns true if the request has a non-empty message body to upload. 310 bool has_upload() const; 311 312 // Set an extra request header by ID or name. These methods may only be 313 // called before Start() is called. It is an error to call it later. 314 void SetExtraRequestHeaderById(int header_id, const std::string& value, 315 bool overwrite); 316 void SetExtraRequestHeaderByName(const std::string& name, 317 const std::string& value, bool overwrite); 318 319 // Sets all extra request headers, from a \r\n-delimited string. Any extra 320 // request headers set by other methods are overwritten by this method. This 321 // method may only be called before Start() is called. It is an error to 322 // call it later. 323 // 324 // Note: \r\n is only used to separate the headers in the string if there 325 // are multiple headers. The last header in the string must not be followed 326 // by \r\n. 327 void SetExtraRequestHeaders(const std::string& headers); 328 extra_request_headers()329 const std::string& extra_request_headers() { return extra_request_headers_; } 330 331 // Returns the current load state for the request. 332 net::LoadState GetLoadState() const; 333 334 // Returns the current upload progress in bytes. 335 uint64 GetUploadProgress() const; 336 337 // Get response header(s) by ID or name. These methods may only be called 338 // once the delegate's OnResponseStarted method has been called. Headers 339 // that appear more than once in the response are coalesced, with values 340 // separated by commas (per RFC 2616). This will not work with cookies since 341 // comma can be used in cookie values. 342 // TODO(darin): add API to enumerate response headers. 343 void GetResponseHeaderById(int header_id, std::string* value); 344 void GetResponseHeaderByName(const std::string& name, std::string* value); 345 346 // Get all response headers, \n-delimited and \n\0-terminated. This includes 347 // the response status line. Restrictions on GetResponseHeaders apply. 348 void GetAllResponseHeaders(std::string* headers); 349 350 // The time at which the returned response was requested. For cached 351 // responses, this is the last time the cache entry was validated. request_time()352 const base::Time& request_time() const { 353 return response_info_.request_time; 354 } 355 356 // The time at which the returned response was generated. For cached 357 // responses, this is the last time the cache entry was validated. response_time()358 const base::Time& response_time() const { 359 return response_info_.response_time; 360 } 361 362 // Indicate if this response was fetched from disk cache. was_cached()363 bool was_cached() const { return response_info_.was_cached; } 364 365 // Returns true if the URLRequest was delivered with SPDY. was_fetched_via_spdy()366 bool was_fetched_via_spdy() const { 367 return response_info_.was_fetched_via_spdy; 368 } 369 370 // Get all response headers, as a HttpResponseHeaders object. See comments 371 // in HttpResponseHeaders class as to the format of the data. 372 net::HttpResponseHeaders* response_headers() const; 373 374 // Get the SSL connection info. ssl_info()375 const net::SSLInfo& ssl_info() const { 376 return response_info_.ssl_info; 377 } 378 379 // Returns the cookie values included in the response, if the request is one 380 // that can have cookies. Returns true if the request is a cookie-bearing 381 // type, false otherwise. This method may only be called once the 382 // delegate's OnResponseStarted method has been called. 383 bool GetResponseCookies(ResponseCookies* cookies); 384 385 // Get the mime type. This method may only be called once the delegate's 386 // OnResponseStarted method has been called. 387 void GetMimeType(std::string* mime_type); 388 389 // Get the charset (character encoding). This method may only be called once 390 // the delegate's OnResponseStarted method has been called. 391 void GetCharset(std::string* charset); 392 393 // Returns the HTTP response code (e.g., 200, 404, and so on). This method 394 // may only be called once the delegate's OnResponseStarted method has been 395 // called. For non-HTTP requests, this method returns -1. 396 int GetResponseCode(); 397 398 // Get the HTTP response info in its entirety. response_info()399 const net::HttpResponseInfo& response_info() const { return response_info_; } 400 401 // Access the net::LOAD_* flags modifying this request (see load_flags.h). load_flags()402 int load_flags() const { return load_flags_; } set_load_flags(int flags)403 void set_load_flags(int flags) { load_flags_ = flags; } 404 405 // Returns true if the request is "pending" (i.e., if Start() has been called, 406 // and the response has not yet been called). is_pending()407 bool is_pending() const { return is_pending_; } 408 409 // Returns the error status of the request. This value is 0 if there is no 410 // error. Otherwise, it is a value defined by the operating system (e.g., an 411 // error code returned by GetLastError() on windows). status()412 const URLRequestStatus& status() const { return status_; } 413 414 // This method is called to start the request. The delegate will receive 415 // a OnResponseStarted callback when the request is started. 416 void Start(); 417 418 // This method may be called at any time after Start() has been called to 419 // cancel the request. This method may be called many times, and it has 420 // no effect once the response has completed. It is guaranteed that no 421 // methods of the delegate will be called after the request has been 422 // cancelled, including during the call to Cancel itself. 423 void Cancel(); 424 425 // Cancels the request and sets the error to |os_error| (see net_error_list.h 426 // for values). 427 void SimulateError(int os_error); 428 429 // Cancels the request and sets the error to |os_error| (see net_error_list.h 430 // for values) and attaches |ssl_info| as the SSLInfo for that request. This 431 // is useful to attach a certificate and certificate error to a canceled 432 // request. 433 void SimulateSSLError(int os_error, const net::SSLInfo& ssl_info); 434 435 // Read initiates an asynchronous read from the response, and must only 436 // be called after the OnResponseStarted callback is received with a 437 // successful status. 438 // If data is available, Read will return true, and the data and length will 439 // be returned immediately. If data is not available, Read returns false, 440 // and an asynchronous Read is initiated. The Read is finished when 441 // the caller receives the OnReadComplete callback. Unless the request was 442 // cancelled, OnReadComplete will always be called, even if the read failed. 443 // 444 // The buf parameter is a buffer to receive the data. If the operation 445 // completes asynchronously, the implementation will reference the buffer 446 // until OnReadComplete is called. The buffer must be at least max_bytes in 447 // length. 448 // 449 // The max_bytes parameter is the maximum number of bytes to read. 450 // 451 // The bytes_read parameter is an output parameter containing the 452 // the number of bytes read. A value of 0 indicates that there is no 453 // more data available to read from the stream. 454 // 455 // If a read error occurs, Read returns false and the request->status 456 // will be set to an error. 457 bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); 458 459 // This method may be called to follow a redirect that was deferred in 460 // response to an OnReceivedRedirect call. 461 void FollowDeferredRedirect(); 462 463 // One of the following two methods should be called in response to an 464 // OnAuthRequired() callback (and only then). 465 // SetAuth will reissue the request with the given credentials. 466 // CancelAuth will give up and display the error page. 467 void SetAuth(const std::wstring& username, const std::wstring& password); 468 void CancelAuth(); 469 470 // This method can be called after the user selects a client certificate to 471 // instruct this URLRequest to continue with the request with the 472 // certificate. Pass NULL if the user doesn't have a client certificate. 473 void ContinueWithCertificate(net::X509Certificate* client_cert); 474 475 // This method can be called after some error notifications to instruct this 476 // URLRequest to ignore the current error and continue with the request. To 477 // cancel the request instead, call Cancel(). 478 void ContinueDespiteLastError(); 479 480 // HTTP request/response header IDs (via some preprocessor fun) for use with 481 // SetRequestHeaderById and GetResponseHeaderById. 482 enum { 483 #define HTTP_ATOM(x) HTTP_ ## x, 484 #include "net/http/http_atom_list.h" 485 #undef HTTP_ATOM 486 }; 487 488 // Returns true if performance profiling should be enabled on the 489 // URLRequestJob serving this request. enable_profiling()490 bool enable_profiling() const { return enable_profiling_; } 491 set_enable_profiling(bool profiling)492 void set_enable_profiling(bool profiling) { enable_profiling_ = profiling; } 493 494 // Used to specify the context (cookie store, cache) for this request. 495 URLRequestContext* context(); 496 void set_context(URLRequestContext* context); 497 load_log()498 net::LoadLog* load_log() { return load_log_; } 499 500 // Returns the expected content size if available 501 int64 GetExpectedContentSize() const; 502 503 // Returns the priority level for this request. priority()504 net::RequestPriority priority() const { return priority_; } set_priority(net::RequestPriority priority)505 void set_priority(net::RequestPriority priority) { 506 DCHECK_GE(priority, net::HIGHEST); 507 DCHECK_LE(priority, net::LOWEST); 508 priority_ = priority; 509 } 510 511 #ifdef UNIT_TEST job()512 URLRequestJob* job() { return job_; } 513 #endif 514 515 protected: 516 // Allow the URLRequestJob class to control the is_pending() flag. set_is_pending(bool value)517 void set_is_pending(bool value) { is_pending_ = value; } 518 519 // Allow the URLRequestJob class to set our status too set_status(const URLRequestStatus & value)520 void set_status(const URLRequestStatus& value) { status_ = value; } 521 522 // Allow the URLRequestJob to redirect this request. Returns net::OK if 523 // successful, otherwise an error code is returned. 524 int Redirect(const GURL& location, int http_status_code); 525 526 // Called by URLRequestJob to allow interception when a redirect occurs. 527 void ReceivedRedirect(const GURL& location, bool* defer_redirect); 528 529 // Called by URLRequestJob to allow interception when the final response 530 // occurs. 531 void ResponseStarted(); 532 533 // Allow an interceptor's URLRequestJob to restart this request. 534 // Should only be called if the original job has not started a resposne. 535 void Restart(); 536 537 private: 538 friend class URLRequestJob; 539 friend class RequestTracker<URLRequest>; 540 541 void StartJob(URLRequestJob* job); 542 543 // Restarting involves replacing the current job with a new one such as what 544 // happens when following a HTTP redirect. 545 void RestartWithJob(URLRequestJob *job); 546 void PrepareToRestart(); 547 548 // Detaches the job from this request in preparation for this object going 549 // away or the job being replaced. The job will not call us back when it has 550 // been orphaned. 551 void OrphanJob(); 552 553 // Cancels the request and set the error and ssl info for this request to the 554 // passed values. 555 void DoCancel(int os_error, const net::SSLInfo& ssl_info); 556 557 // Discard headers which have meaning in POST (Content-Length, Content-Type, 558 // Origin). 559 static std::string StripPostSpecificHeaders(const std::string& headers); 560 561 // Gets the goodies out of this that we want to show the user later on the 562 // chrome://net-internals/ page. 563 void GetInfoForTracker( 564 RequestTracker<URLRequest>::RecentRequestInfo* info) const; 565 566 // Contextual information used for this request (can be NULL). This contains 567 // most of the dependencies which are shared between requests (disk cache, 568 // cookie store, socket poool, etc.) 569 scoped_refptr<URLRequestContext> context_; 570 571 // Tracks the time spent in various load states throughout this request. 572 scoped_refptr<net::LoadLog> load_log_; 573 574 scoped_refptr<URLRequestJob> job_; 575 scoped_refptr<net::UploadData> upload_; 576 GURL url_; 577 GURL original_url_; 578 GURL first_party_for_cookies_; 579 std::string method_; // "GET", "POST", etc. Should be all uppercase. 580 std::string referrer_; 581 std::string extra_request_headers_; 582 int load_flags_; // Flags indicating the request type for the load; 583 // expected values are LOAD_* enums above. 584 585 Delegate* delegate_; 586 587 // Current error status of the job. When no error has been encountered, this 588 // will be SUCCESS. If multiple errors have been encountered, this will be 589 // the first non-SUCCESS status seen. 590 URLRequestStatus status_; 591 592 // The HTTP response info, lazily initialized. 593 net::HttpResponseInfo response_info_; 594 595 // Tells us whether the job is outstanding. This is true from the time 596 // Start() is called to the time we dispatch RequestComplete and indicates 597 // whether the job is active. 598 bool is_pending_; 599 600 // Externally-defined data accessible by key 601 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap; 602 UserDataMap user_data_; 603 604 // Whether to enable performance profiling on the job serving this request. 605 bool enable_profiling_; 606 607 // Number of times we're willing to redirect. Used to guard against 608 // infinite redirects. 609 int redirect_limit_; 610 611 // Cached value for use after we've orphaned the job handling the 612 // first transaction in a request involving redirects. 613 uint64 final_upload_progress_; 614 615 // The priority level for this request. Objects like ClientSocketPool use 616 // this to determine which URLRequest to allocate sockets to first. 617 net::RequestPriority priority_; 618 619 RequestTracker<URLRequest>::Node request_tracker_node_; 620 base::LeakTracker<URLRequest> leak_tracker_; 621 622 DISALLOW_COPY_AND_ASSIGN(URLRequest); 623 }; 624 625 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 626