| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 virtual void OnReceivedRedirect(URLRequest* request, | 160 virtual void OnReceivedRedirect(URLRequest* request, |
| 161 const GURL& new_url, | 161 const GURL& new_url, |
| 162 bool* defer_redirect); | 162 bool* defer_redirect); |
| 163 | 163 |
| 164 // Called when we receive an authentication failure. The delegate should | 164 // Called when we receive an authentication failure. The delegate should |
| 165 // call request->SetAuth() with the user's credentials once it obtains them, | 165 // call request->SetAuth() with the user's credentials once it obtains them, |
| 166 // or request->CancelAuth() to cancel the login and display the error page. | 166 // or request->CancelAuth() to cancel the login and display the error page. |
| 167 // When it does so, the request will be reissued, restarting the sequence | 167 // When it does so, the request will be reissued, restarting the sequence |
| 168 // of On* callbacks. | 168 // of On* callbacks. |
| 169 virtual void OnAuthRequired(URLRequest* request, | 169 virtual void OnAuthRequired(URLRequest* request, |
| 170 net::AuthChallengeInfo* auth_info); | 170 AuthChallengeInfo* auth_info); |
| 171 | 171 |
| 172 // Called when we receive an SSL CertificateRequest message for client | 172 // Called when we receive an SSL CertificateRequest message for client |
| 173 // authentication. The delegate should call | 173 // authentication. The delegate should call |
| 174 // request->ContinueWithCertificate() with the client certificate the user | 174 // request->ContinueWithCertificate() with the client certificate the user |
| 175 // selected, or request->ContinueWithCertificate(NULL) to continue the SSL | 175 // selected, or request->ContinueWithCertificate(NULL) to continue the SSL |
| 176 // handshake without a client certificate. | 176 // handshake without a client certificate. |
| 177 virtual void OnCertificateRequested( | 177 virtual void OnCertificateRequested( |
| 178 URLRequest* request, | 178 URLRequest* request, |
| 179 net::SSLCertRequestInfo* cert_request_info); | 179 SSLCertRequestInfo* cert_request_info); |
| 180 | 180 |
| 181 // Called when using SSL and the server responds with a certificate with | 181 // Called when using SSL and the server responds with a certificate with |
| 182 // an error, for example, whose common name does not match the common name | 182 // an error, for example, whose common name does not match the common name |
| 183 // we were expecting for that host. The delegate should either do the | 183 // we were expecting for that host. The delegate should either do the |
| 184 // safe thing and Cancel() the request or decide to proceed by calling | 184 // safe thing and Cancel() the request or decide to proceed by calling |
| 185 // ContinueDespiteLastError(). cert_error is a net::ERR_* error code | 185 // ContinueDespiteLastError(). cert_error is a ERR_* error code |
| 186 // indicating what's wrong with the certificate. | 186 // indicating what's wrong with the certificate. |
| 187 virtual void OnSSLCertificateError(URLRequest* request, | 187 virtual void OnSSLCertificateError(URLRequest* request, |
| 188 int cert_error, | 188 int cert_error, |
| 189 net::X509Certificate* cert); | 189 X509Certificate* cert); |
| 190 | 190 |
| 191 // Called when reading cookies. |blocked_by_policy| is true if access to | 191 // Called when reading cookies. |blocked_by_policy| is true if access to |
| 192 // cookies was denied due to content settings. This method will never be | 192 // cookies was denied due to content settings. This method will never be |
| 193 // invoked when LOAD_DO_NOT_SEND_COOKIES is specified. | 193 // invoked when LOAD_DO_NOT_SEND_COOKIES is specified. |
| 194 virtual void OnGetCookies(URLRequest* request, bool blocked_by_policy); | 194 virtual void OnGetCookies(URLRequest* request, bool blocked_by_policy); |
| 195 | 195 |
| 196 // Called when a cookie is set. |blocked_by_policy| is true if the cookie | 196 // Called when a cookie is set. |blocked_by_policy| is true if the cookie |
| 197 // was rejected due to content settings. This method will never be invoked | 197 // was rejected due to content settings. This method will never be invoked |
| 198 // when LOAD_DO_NOT_SAVE_COOKIES is specified. | 198 // when LOAD_DO_NOT_SAVE_COOKIES is specified. |
| 199 virtual void OnSetCookie(URLRequest* request, | 199 virtual void OnSetCookie(URLRequest* request, |
| 200 const std::string& cookie_line, | 200 const std::string& cookie_line, |
| 201 const net::CookieOptions& options, | 201 const CookieOptions& options, |
| 202 bool blocked_by_policy); | 202 bool blocked_by_policy); |
| 203 | 203 |
| 204 // After calling Start(), the delegate will receive an OnResponseStarted | 204 // After calling Start(), the delegate will receive an OnResponseStarted |
| 205 // callback when the request has completed. If an error occurred, the | 205 // callback when the request has completed. If an error occurred, the |
| 206 // request->status() will be set. On success, all redirects have been | 206 // request->status() will be set. On success, all redirects have been |
| 207 // followed and the final response is beginning to arrive. At this point, | 207 // followed and the final response is beginning to arrive. At this point, |
| 208 // meta data about the response is available, including for example HTTP | 208 // meta data about the response is available, including for example HTTP |
| 209 // response headers if this is a request for a HTTP resource. | 209 // response headers if this is a request for a HTTP resource. |
| 210 virtual void OnResponseStarted(URLRequest* request) = 0; | 210 virtual void OnResponseStarted(URLRequest* request) = 0; |
| 211 | 211 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // Appends the given bytes to the request's upload data to be sent | 332 // Appends the given bytes to the request's upload data to be sent |
| 333 // immediately via chunked transfer encoding. When all data has been sent, | 333 // immediately via chunked transfer encoding. When all data has been sent, |
| 334 // call MarkEndOfChunks() to indicate the end of upload data. | 334 // call MarkEndOfChunks() to indicate the end of upload data. |
| 335 // | 335 // |
| 336 // This method may be called only after calling EnableChunkedUpload(). | 336 // This method may be called only after calling EnableChunkedUpload(). |
| 337 void AppendChunkToUpload(const char* bytes, | 337 void AppendChunkToUpload(const char* bytes, |
| 338 int bytes_len, | 338 int bytes_len, |
| 339 bool is_last_chunk); | 339 bool is_last_chunk); |
| 340 | 340 |
| 341 // Set the upload data directly. | 341 // Set the upload data directly. |
| 342 void set_upload(net::UploadData* upload); | 342 void set_upload(UploadData* upload); |
| 343 | 343 |
| 344 // Get the upload data directly. | 344 // Get the upload data directly. |
| 345 net::UploadData* get_upload(); | 345 UploadData* get_upload(); |
| 346 | 346 |
| 347 // Returns true if the request has a non-empty message body to upload. | 347 // Returns true if the request has a non-empty message body to upload. |
| 348 bool has_upload() const; | 348 bool has_upload() const; |
| 349 | 349 |
| 350 // Set an extra request header by ID or name. These methods may only be | 350 // Set an extra request header by ID or name. These methods may only be |
| 351 // called before Start() is called. It is an error to call it later. | 351 // called before Start() is called. It is an error to call it later. |
| 352 void SetExtraRequestHeaderById(int header_id, const std::string& value, | 352 void SetExtraRequestHeaderById(int header_id, const std::string& value, |
| 353 bool overwrite); | 353 bool overwrite); |
| 354 void SetExtraRequestHeaderByName(const std::string& name, | 354 void SetExtraRequestHeaderByName(const std::string& name, |
| 355 const std::string& value, bool overwrite); | 355 const std::string& value, bool overwrite); |
| 356 | 356 |
| 357 // Sets all extra request headers. Any extra request headers set by other | 357 // Sets all extra request headers. Any extra request headers set by other |
| 358 // methods are overwritten by this method. This method may only be called | 358 // methods are overwritten by this method. This method may only be called |
| 359 // before Start() is called. It is an error to call it later. | 359 // before Start() is called. It is an error to call it later. |
| 360 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); | 360 void SetExtraRequestHeaders(const HttpRequestHeaders& headers); |
| 361 | 361 |
| 362 const net::HttpRequestHeaders& extra_request_headers() const { | 362 const HttpRequestHeaders& extra_request_headers() const { |
| 363 return extra_request_headers_; | 363 return extra_request_headers_; |
| 364 } | 364 } |
| 365 | 365 |
| 366 // Returns the current load state for the request. | 366 // Returns the current load state for the request. |
| 367 net::LoadState GetLoadState() const; | 367 LoadState GetLoadState() const; |
| 368 | 368 |
| 369 // Returns the current upload progress in bytes. | 369 // Returns the current upload progress in bytes. |
| 370 uint64 GetUploadProgress() const; | 370 uint64 GetUploadProgress() const; |
| 371 | 371 |
| 372 // Get response header(s) by ID or name. These methods may only be called | 372 // Get response header(s) by ID or name. These methods may only be called |
| 373 // once the delegate's OnResponseStarted method has been called. Headers | 373 // once the delegate's OnResponseStarted method has been called. Headers |
| 374 // that appear more than once in the response are coalesced, with values | 374 // that appear more than once in the response are coalesced, with values |
| 375 // separated by commas (per RFC 2616). This will not work with cookies since | 375 // separated by commas (per RFC 2616). This will not work with cookies since |
| 376 // comma can be used in cookie values. | 376 // comma can be used in cookie values. |
| 377 // TODO(darin): add API to enumerate response headers. | 377 // TODO(darin): add API to enumerate response headers. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 bool was_fetched_via_proxy() const { | 413 bool was_fetched_via_proxy() const { |
| 414 return response_info_.was_fetched_via_proxy; | 414 return response_info_.was_fetched_via_proxy; |
| 415 } | 415 } |
| 416 | 416 |
| 417 // Returns the host and port that the content was fetched from. See | 417 // Returns the host and port that the content was fetched from. See |
| 418 // http_response_info.h for caveats relating to cached content. | 418 // http_response_info.h for caveats relating to cached content. |
| 419 HostPortPair GetSocketAddress() const; | 419 HostPortPair GetSocketAddress() const; |
| 420 | 420 |
| 421 // Get all response headers, as a HttpResponseHeaders object. See comments | 421 // Get all response headers, as a HttpResponseHeaders object. See comments |
| 422 // in HttpResponseHeaders class as to the format of the data. | 422 // in HttpResponseHeaders class as to the format of the data. |
| 423 net::HttpResponseHeaders* response_headers() const; | 423 HttpResponseHeaders* response_headers() const; |
| 424 | 424 |
| 425 // Get the SSL connection info. | 425 // Get the SSL connection info. |
| 426 const net::SSLInfo& ssl_info() const { | 426 const SSLInfo& ssl_info() const { |
| 427 return response_info_.ssl_info; | 427 return response_info_.ssl_info; |
| 428 } | 428 } |
| 429 | 429 |
| 430 // Returns the cookie values included in the response, if the request is one | 430 // Returns the cookie values included in the response, if the request is one |
| 431 // that can have cookies. Returns true if the request is a cookie-bearing | 431 // that can have cookies. Returns true if the request is a cookie-bearing |
| 432 // type, false otherwise. This method may only be called once the | 432 // type, false otherwise. This method may only be called once the |
| 433 // delegate's OnResponseStarted method has been called. | 433 // delegate's OnResponseStarted method has been called. |
| 434 bool GetResponseCookies(ResponseCookies* cookies); | 434 bool GetResponseCookies(ResponseCookies* cookies); |
| 435 | 435 |
| 436 // Get the mime type. This method may only be called once the delegate's | 436 // Get the mime type. This method may only be called once the delegate's |
| 437 // OnResponseStarted method has been called. | 437 // OnResponseStarted method has been called. |
| 438 void GetMimeType(std::string* mime_type); | 438 void GetMimeType(std::string* mime_type); |
| 439 | 439 |
| 440 // Get the charset (character encoding). This method may only be called once | 440 // Get the charset (character encoding). This method may only be called once |
| 441 // the delegate's OnResponseStarted method has been called. | 441 // the delegate's OnResponseStarted method has been called. |
| 442 void GetCharset(std::string* charset); | 442 void GetCharset(std::string* charset); |
| 443 | 443 |
| 444 // Returns the HTTP response code (e.g., 200, 404, and so on). This method | 444 // Returns the HTTP response code (e.g., 200, 404, and so on). This method |
| 445 // may only be called once the delegate's OnResponseStarted method has been | 445 // may only be called once the delegate's OnResponseStarted method has been |
| 446 // called. For non-HTTP requests, this method returns -1. | 446 // called. For non-HTTP requests, this method returns -1. |
| 447 int GetResponseCode(); | 447 int GetResponseCode(); |
| 448 | 448 |
| 449 // Get the HTTP response info in its entirety. | 449 // Get the HTTP response info in its entirety. |
| 450 const net::HttpResponseInfo& response_info() const { return response_info_; } | 450 const HttpResponseInfo& response_info() const { return response_info_; } |
| 451 | 451 |
| 452 // Access the net::LOAD_* flags modifying this request (see load_flags.h). | 452 // Access the LOAD_* flags modifying this request (see load_flags.h). |
| 453 int load_flags() const { return load_flags_; } | 453 int load_flags() const { return load_flags_; } |
| 454 void set_load_flags(int flags) { load_flags_ = flags; } | 454 void set_load_flags(int flags) { load_flags_ = flags; } |
| 455 | 455 |
| 456 // Returns true if the request is "pending" (i.e., if Start() has been called, | 456 // Returns true if the request is "pending" (i.e., if Start() has been called, |
| 457 // and the response has not yet been called). | 457 // and the response has not yet been called). |
| 458 bool is_pending() const { return is_pending_; } | 458 bool is_pending() const { return is_pending_; } |
| 459 | 459 |
| 460 // Returns the error status of the request. | 460 // Returns the error status of the request. |
| 461 const net::URLRequestStatus& status() const { return status_; } | 461 const URLRequestStatus& status() const { return status_; } |
| 462 | 462 |
| 463 // Returns a globally unique identifier for this request. | 463 // Returns a globally unique identifier for this request. |
| 464 uint64 identifier() const { return identifier_; } | 464 uint64 identifier() const { return identifier_; } |
| 465 | 465 |
| 466 // This method is called to start the request. The delegate will receive | 466 // This method is called to start the request. The delegate will receive |
| 467 // a OnResponseStarted callback when the request is started. | 467 // a OnResponseStarted callback when the request is started. |
| 468 void Start(); | 468 void Start(); |
| 469 | 469 |
| 470 // This method may be called at any time after Start() has been called to | 470 // This method may be called at any time after Start() has been called to |
| 471 // cancel the request. This method may be called many times, and it has | 471 // cancel the request. This method may be called many times, and it has |
| 472 // no effect once the response has completed. It is guaranteed that no | 472 // no effect once the response has completed. It is guaranteed that no |
| 473 // methods of the delegate will be called after the request has been | 473 // methods of the delegate will be called after the request has been |
| 474 // cancelled, including during the call to Cancel itself. | 474 // cancelled, including during the call to Cancel itself. |
| 475 void Cancel(); | 475 void Cancel(); |
| 476 | 476 |
| 477 // Cancels the request and sets the error to |os_error| (see net_error_list.h | 477 // Cancels the request and sets the error to |os_error| (see net_error_list.h |
| 478 // for values). | 478 // for values). |
| 479 void SimulateError(int os_error); | 479 void SimulateError(int os_error); |
| 480 | 480 |
| 481 // Cancels the request and sets the error to |os_error| (see net_error_list.h | 481 // Cancels the request and sets the error to |os_error| (see net_error_list.h |
| 482 // for values) and attaches |ssl_info| as the SSLInfo for that request. This | 482 // for values) and attaches |ssl_info| as the SSLInfo for that request. This |
| 483 // is useful to attach a certificate and certificate error to a canceled | 483 // is useful to attach a certificate and certificate error to a canceled |
| 484 // request. | 484 // request. |
| 485 void SimulateSSLError(int os_error, const net::SSLInfo& ssl_info); | 485 void SimulateSSLError(int os_error, const SSLInfo& ssl_info); |
| 486 | 486 |
| 487 // Read initiates an asynchronous read from the response, and must only | 487 // Read initiates an asynchronous read from the response, and must only |
| 488 // be called after the OnResponseStarted callback is received with a | 488 // be called after the OnResponseStarted callback is received with a |
| 489 // successful status. | 489 // successful status. |
| 490 // If data is available, Read will return true, and the data and length will | 490 // If data is available, Read will return true, and the data and length will |
| 491 // be returned immediately. If data is not available, Read returns false, | 491 // be returned immediately. If data is not available, Read returns false, |
| 492 // and an asynchronous Read is initiated. The Read is finished when | 492 // and an asynchronous Read is initiated. The Read is finished when |
| 493 // the caller receives the OnReadComplete callback. Unless the request was | 493 // the caller receives the OnReadComplete callback. Unless the request was |
| 494 // cancelled, OnReadComplete will always be called, even if the read failed. | 494 // cancelled, OnReadComplete will always be called, even if the read failed. |
| 495 // | 495 // |
| 496 // The buf parameter is a buffer to receive the data. If the operation | 496 // The buf parameter is a buffer to receive the data. If the operation |
| 497 // completes asynchronously, the implementation will reference the buffer | 497 // completes asynchronously, the implementation will reference the buffer |
| 498 // until OnReadComplete is called. The buffer must be at least max_bytes in | 498 // until OnReadComplete is called. The buffer must be at least max_bytes in |
| 499 // length. | 499 // length. |
| 500 // | 500 // |
| 501 // The max_bytes parameter is the maximum number of bytes to read. | 501 // The max_bytes parameter is the maximum number of bytes to read. |
| 502 // | 502 // |
| 503 // The bytes_read parameter is an output parameter containing the | 503 // The bytes_read parameter is an output parameter containing the |
| 504 // the number of bytes read. A value of 0 indicates that there is no | 504 // the number of bytes read. A value of 0 indicates that there is no |
| 505 // more data available to read from the stream. | 505 // more data available to read from the stream. |
| 506 // | 506 // |
| 507 // If a read error occurs, Read returns false and the request->status | 507 // If a read error occurs, Read returns false and the request->status |
| 508 // will be set to an error. | 508 // will be set to an error. |
| 509 bool Read(net::IOBuffer* buf, int max_bytes, int* bytes_read); | 509 bool Read(IOBuffer* buf, int max_bytes, int* bytes_read); |
| 510 | 510 |
| 511 // If this request is being cached by the HTTP cache, stop subsequent caching. | 511 // If this request is being cached by the HTTP cache, stop subsequent caching. |
| 512 // Note that this method has no effect on other (simultaneous or not) requests | 512 // Note that this method has no effect on other (simultaneous or not) requests |
| 513 // for the same resource. The typical example is a request that results in | 513 // for the same resource. The typical example is a request that results in |
| 514 // the data being stored to disk (downloaded instead of rendered) so we don't | 514 // the data being stored to disk (downloaded instead of rendered) so we don't |
| 515 // want to store it twice. | 515 // want to store it twice. |
| 516 void StopCaching(); | 516 void StopCaching(); |
| 517 | 517 |
| 518 // This method may be called to follow a redirect that was deferred in | 518 // This method may be called to follow a redirect that was deferred in |
| 519 // response to an OnReceivedRedirect call. | 519 // response to an OnReceivedRedirect call. |
| 520 void FollowDeferredRedirect(); | 520 void FollowDeferredRedirect(); |
| 521 | 521 |
| 522 // One of the following two methods should be called in response to an | 522 // One of the following two methods should be called in response to an |
| 523 // OnAuthRequired() callback (and only then). | 523 // OnAuthRequired() callback (and only then). |
| 524 // SetAuth will reissue the request with the given credentials. | 524 // SetAuth will reissue the request with the given credentials. |
| 525 // CancelAuth will give up and display the error page. | 525 // CancelAuth will give up and display the error page. |
| 526 void SetAuth(const string16& username, const string16& password); | 526 void SetAuth(const string16& username, const string16& password); |
| 527 void CancelAuth(); | 527 void CancelAuth(); |
| 528 | 528 |
| 529 // This method can be called after the user selects a client certificate to | 529 // This method can be called after the user selects a client certificate to |
| 530 // instruct this URLRequest to continue with the request with the | 530 // instruct this URLRequest to continue with the request with the |
| 531 // certificate. Pass NULL if the user doesn't have a client certificate. | 531 // certificate. Pass NULL if the user doesn't have a client certificate. |
| 532 void ContinueWithCertificate(net::X509Certificate* client_cert); | 532 void ContinueWithCertificate(X509Certificate* client_cert); |
| 533 | 533 |
| 534 // This method can be called after some error notifications to instruct this | 534 // This method can be called after some error notifications to instruct this |
| 535 // URLRequest to ignore the current error and continue with the request. To | 535 // URLRequest to ignore the current error and continue with the request. To |
| 536 // cancel the request instead, call Cancel(). | 536 // cancel the request instead, call Cancel(). |
| 537 void ContinueDespiteLastError(); | 537 void ContinueDespiteLastError(); |
| 538 | 538 |
| 539 // Used to specify the context (cookie store, cache) for this request. | 539 // Used to specify the context (cookie store, cache) for this request. |
| 540 URLRequestContext* context() const; | 540 URLRequestContext* context() const; |
| 541 void set_context(URLRequestContext* context); | 541 void set_context(URLRequestContext* context); |
| 542 | 542 |
| 543 const net::BoundNetLog& net_log() const { return net_log_; } | 543 const BoundNetLog& net_log() const { return net_log_; } |
| 544 | 544 |
| 545 // Returns the expected content size if available | 545 // Returns the expected content size if available |
| 546 int64 GetExpectedContentSize() const; | 546 int64 GetExpectedContentSize() const; |
| 547 | 547 |
| 548 // Returns the priority level for this request. | 548 // Returns the priority level for this request. |
| 549 net::RequestPriority priority() const { return priority_; } | 549 RequestPriority priority() const { return priority_; } |
| 550 void set_priority(net::RequestPriority priority) { | 550 void set_priority(RequestPriority priority) { |
| 551 DCHECK_GE(priority, net::HIGHEST); | 551 DCHECK_GE(priority, HIGHEST); |
| 552 DCHECK_LT(priority, net::NUM_PRIORITIES); | 552 DCHECK_LT(priority, NUM_PRIORITIES); |
| 553 priority_ = priority; | 553 priority_ = priority; |
| 554 } | 554 } |
| 555 | 555 |
| 556 #ifdef UNIT_TEST | 556 #ifdef UNIT_TEST |
| 557 URLRequestJob* job() { return job_; } | 557 URLRequestJob* job() { return job_; } |
| 558 #endif | 558 #endif |
| 559 | 559 |
| 560 protected: | 560 protected: |
| 561 // Allow the URLRequestJob class to control the is_pending() flag. | 561 // Allow the URLRequestJob class to control the is_pending() flag. |
| 562 void set_is_pending(bool value) { is_pending_ = value; } | 562 void set_is_pending(bool value) { is_pending_ = value; } |
| 563 | 563 |
| 564 // Allow the URLRequestJob class to set our status too | 564 // Allow the URLRequestJob class to set our status too |
| 565 void set_status(const net::URLRequestStatus& value) { status_ = value; } | 565 void set_status(const URLRequestStatus& value) { status_ = value; } |
| 566 | 566 |
| 567 // Allow the URLRequestJob to redirect this request. Returns net::OK if | 567 // Allow the URLRequestJob to redirect this request. Returns OK if |
| 568 // successful, otherwise an error code is returned. | 568 // successful, otherwise an error code is returned. |
| 569 int Redirect(const GURL& location, int http_status_code); | 569 int Redirect(const GURL& location, int http_status_code); |
| 570 | 570 |
| 571 // Called by URLRequestJob to allow interception when a redirect occurs. | 571 // Called by URLRequestJob to allow interception when a redirect occurs. |
| 572 void ReceivedRedirect(const GURL& location, bool* defer_redirect); | 572 void ReceivedRedirect(const GURL& location, bool* defer_redirect); |
| 573 | 573 |
| 574 // Called by URLRequestJob to allow interception when the final response | 574 // Called by URLRequestJob to allow interception when the final response |
| 575 // occurs. | 575 // occurs. |
| 576 void ResponseStarted(); | 576 void ResponseStarted(); |
| 577 | 577 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 590 void RestartWithJob(URLRequestJob* job); | 590 void RestartWithJob(URLRequestJob* job); |
| 591 void PrepareToRestart(); | 591 void PrepareToRestart(); |
| 592 | 592 |
| 593 // Detaches the job from this request in preparation for this object going | 593 // Detaches the job from this request in preparation for this object going |
| 594 // away or the job being replaced. The job will not call us back when it has | 594 // away or the job being replaced. The job will not call us back when it has |
| 595 // been orphaned. | 595 // been orphaned. |
| 596 void OrphanJob(); | 596 void OrphanJob(); |
| 597 | 597 |
| 598 // Cancels the request and set the error and ssl info for this request to the | 598 // Cancels the request and set the error and ssl info for this request to the |
| 599 // passed values. | 599 // passed values. |
| 600 void DoCancel(int os_error, const net::SSLInfo& ssl_info); | 600 void DoCancel(int os_error, const SSLInfo& ssl_info); |
| 601 | 601 |
| 602 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest | 602 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest |
| 603 // handler. If |blocked| is true, the request is blocked and an error page is | 603 // handler. If |blocked| is true, the request is blocked and an error page is |
| 604 // returned indicating so. This should only be called after Start is called | 604 // returned indicating so. This should only be called after Start is called |
| 605 // and OnBeforeRequest returns true (signalling that the request should be | 605 // and OnBeforeRequest returns true (signalling that the request should be |
| 606 // paused). | 606 // paused). |
| 607 void BeforeRequestComplete(int error); | 607 void BeforeRequestComplete(int error); |
| 608 | 608 |
| 609 // Contextual information used for this request (can be NULL). This contains | 609 // Contextual information used for this request (can be NULL). This contains |
| 610 // most of the dependencies which are shared between requests (disk cache, | 610 // most of the dependencies which are shared between requests (disk cache, |
| 611 // cookie store, socket pool, etc.) | 611 // cookie store, socket pool, etc.) |
| 612 scoped_refptr<URLRequestContext> context_; | 612 scoped_refptr<URLRequestContext> context_; |
| 613 | 613 |
| 614 // Tracks the time spent in various load states throughout this request. | 614 // Tracks the time spent in various load states throughout this request. |
| 615 net::BoundNetLog net_log_; | 615 BoundNetLog net_log_; |
| 616 | 616 |
| 617 scoped_refptr<URLRequestJob> job_; | 617 scoped_refptr<URLRequestJob> job_; |
| 618 scoped_refptr<net::UploadData> upload_; | 618 scoped_refptr<UploadData> upload_; |
| 619 GURL url_; | 619 GURL url_; |
| 620 GURL original_url_; | 620 GURL original_url_; |
| 621 GURL first_party_for_cookies_; | 621 GURL first_party_for_cookies_; |
| 622 std::string method_; // "GET", "POST", etc. Should be all uppercase. | 622 std::string method_; // "GET", "POST", etc. Should be all uppercase. |
| 623 std::string referrer_; | 623 std::string referrer_; |
| 624 net::HttpRequestHeaders extra_request_headers_; | 624 HttpRequestHeaders extra_request_headers_; |
| 625 int load_flags_; // Flags indicating the request type for the load; | 625 int load_flags_; // Flags indicating the request type for the load; |
| 626 // expected values are LOAD_* enums above. | 626 // expected values are LOAD_* enums above. |
| 627 | 627 |
| 628 Delegate* delegate_; | 628 Delegate* delegate_; |
| 629 | 629 |
| 630 // Current error status of the job. When no error has been encountered, this | 630 // Current error status of the job. When no error has been encountered, this |
| 631 // will be SUCCESS. If multiple errors have been encountered, this will be | 631 // will be SUCCESS. If multiple errors have been encountered, this will be |
| 632 // the first non-SUCCESS status seen. | 632 // the first non-SUCCESS status seen. |
| 633 net::URLRequestStatus status_; | 633 URLRequestStatus status_; |
| 634 | 634 |
| 635 // The HTTP response info, lazily initialized. | 635 // The HTTP response info, lazily initialized. |
| 636 net::HttpResponseInfo response_info_; | 636 HttpResponseInfo response_info_; |
| 637 | 637 |
| 638 // Tells us whether the job is outstanding. This is true from the time | 638 // Tells us whether the job is outstanding. This is true from the time |
| 639 // Start() is called to the time we dispatch RequestComplete and indicates | 639 // Start() is called to the time we dispatch RequestComplete and indicates |
| 640 // whether the job is active. | 640 // whether the job is active. |
| 641 bool is_pending_; | 641 bool is_pending_; |
| 642 | 642 |
| 643 // Externally-defined data accessible by key | 643 // Externally-defined data accessible by key |
| 644 UserDataMap user_data_; | 644 UserDataMap user_data_; |
| 645 | 645 |
| 646 // Number of times we're willing to redirect. Used to guard against | 646 // Number of times we're willing to redirect. Used to guard against |
| 647 // infinite redirects. | 647 // infinite redirects. |
| 648 int redirect_limit_; | 648 int redirect_limit_; |
| 649 | 649 |
| 650 // Cached value for use after we've orphaned the job handling the | 650 // Cached value for use after we've orphaned the job handling the |
| 651 // first transaction in a request involving redirects. | 651 // first transaction in a request involving redirects. |
| 652 uint64 final_upload_progress_; | 652 uint64 final_upload_progress_; |
| 653 | 653 |
| 654 // The priority level for this request. Objects like ClientSocketPool use | 654 // The priority level for this request. Objects like ClientSocketPool use |
| 655 // this to determine which URLRequest to allocate sockets to first. | 655 // this to determine which URLRequest to allocate sockets to first. |
| 656 net::RequestPriority priority_; | 656 RequestPriority priority_; |
| 657 | 657 |
| 658 // A globally unique identifier for this request. | 658 // A globally unique identifier for this request. |
| 659 const uint64 identifier_; | 659 const uint64 identifier_; |
| 660 | 660 |
| 661 base::debug::LeakTracker<URLRequest> leak_tracker_; | 661 base::debug::LeakTracker<URLRequest> leak_tracker_; |
| 662 | 662 |
| 663 // Callback passed to the network delegate to notify us when a blocked request | 663 // Callback passed to the network delegate to notify us when a blocked request |
| 664 // is ready to be resumed or canceled. | 664 // is ready to be resumed or canceled. |
| 665 scoped_refptr< CancelableCompletionCallback<URLRequest> > | 665 scoped_refptr< CancelableCompletionCallback<URLRequest> > |
| 666 before_request_callback_; | 666 before_request_callback_; |
| 667 | 667 |
| 668 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 668 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
| 669 }; | 669 }; |
| 670 | 670 |
| 671 } // namespace net | 671 } // namespace net |
| 672 | 672 |
| 673 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 673 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
| OLD | NEW |