| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| 11 #include "base/utf_string_conversions.h" |
| 11 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
| 14 #include "net/base/ssl_cert_request_info.h" | 15 #include "net/base/ssl_cert_request_info.h" |
| 15 #include "net/base/upload_data.h" | 16 #include "net/base/upload_data.h" |
| 16 #include "net/http/http_network_delegate.h" | 17 #include "net/http/http_network_delegate.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 19 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 20 #include "net/url_request/url_request_job.h" | 21 #include "net/url_request/url_request_job.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void URLRequest::Delegate::OnReceivedRedirect(URLRequest* request, | 64 void URLRequest::Delegate::OnReceivedRedirect(URLRequest* request, |
| 64 const GURL& new_url, | 65 const GURL& new_url, |
| 65 bool* defer_redirect) { | 66 bool* defer_redirect) { |
| 66 } | 67 } |
| 67 | 68 |
| 68 void URLRequest::Delegate::OnAuthRequired(URLRequest* request, | 69 void URLRequest::Delegate::OnAuthRequired(URLRequest* request, |
| 69 net::AuthChallengeInfo* auth_info) { | 70 net::AuthChallengeInfo* auth_info) { |
| 70 request->CancelAuth(); | 71 request->CancelAuth(); |
| 71 } | 72 } |
| 72 | 73 |
| 74 void URLRequest::Delegate::OnTLSLoginRequired( |
| 75 URLRequest* request, |
| 76 net::AuthChallengeInfo* login_request_info) { |
| 77 } |
| 78 |
| 73 void URLRequest::Delegate::OnCertificateRequested( | 79 void URLRequest::Delegate::OnCertificateRequested( |
| 74 URLRequest* request, | 80 URLRequest* request, |
| 75 net::SSLCertRequestInfo* cert_request_info) { | 81 net::SSLCertRequestInfo* cert_request_info) { |
| 76 request->ContinueWithCertificate(NULL); | 82 request->ContinueWithCertificate(NULL); |
| 77 } | 83 } |
| 78 | 84 |
| 79 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, | 85 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, |
| 80 int cert_error, | 86 int cert_error, |
| 81 net::X509Certificate* cert) { | 87 net::X509Certificate* cert) { |
| 82 request->Cancel(); | 88 request->Cancel(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 URLRequest::URLRequest(const GURL& url, Delegate* delegate) | 104 URLRequest::URLRequest(const GURL& url, Delegate* delegate) |
| 99 : url_(url), | 105 : url_(url), |
| 100 original_url_(url), | 106 original_url_(url), |
| 101 method_("GET"), | 107 method_("GET"), |
| 102 load_flags_(net::LOAD_NORMAL), | 108 load_flags_(net::LOAD_NORMAL), |
| 103 delegate_(delegate), | 109 delegate_(delegate), |
| 104 is_pending_(false), | 110 is_pending_(false), |
| 105 enable_profiling_(false), | 111 enable_profiling_(false), |
| 106 redirect_limit_(kMaxRedirects), | 112 redirect_limit_(kMaxRedirects), |
| 107 final_upload_progress_(0), | 113 final_upload_progress_(0), |
| 108 priority_(net::LOWEST) { | 114 priority_(net::LOWEST), |
| 115 tls_login_auth_data_(new AuthData()) { |
| 109 SIMPLE_STATS_COUNTER("URLRequestCount"); | 116 SIMPLE_STATS_COUNTER("URLRequestCount"); |
| 110 | 117 |
| 111 // Sanity check out environment. | 118 // Sanity check out environment. |
| 112 DCHECK(MessageLoop::current()) << | 119 DCHECK(MessageLoop::current()) << |
| 113 "The current MessageLoop must exist"; | 120 "The current MessageLoop must exist"; |
| 114 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 121 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
| 115 "The current MessageLoop must be TYPE_IO"; | 122 "The current MessageLoop must be TYPE_IO"; |
| 116 } | 123 } |
| 117 | 124 |
| 118 URLRequest::~URLRequest() { | 125 URLRequest::~URLRequest() { |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 504 |
| 498 job_->CancelAuth(); | 505 job_->CancelAuth(); |
| 499 } | 506 } |
| 500 | 507 |
| 501 void URLRequest::ContinueWithCertificate(net::X509Certificate* client_cert) { | 508 void URLRequest::ContinueWithCertificate(net::X509Certificate* client_cert) { |
| 502 DCHECK(job_); | 509 DCHECK(job_); |
| 503 | 510 |
| 504 job_->ContinueWithCertificate(client_cert); | 511 job_->ContinueWithCertificate(client_cert); |
| 505 } | 512 } |
| 506 | 513 |
| 514 void URLRequest::SetTLSLogin(const string16& username, |
| 515 const string16& password) { |
| 516 tls_login_auth_data_->username = username; |
| 517 tls_login_auth_data_->password = password; |
| 518 tls_login_auth_data_->state = AUTH_STATE_HAVE_AUTH; |
| 519 } |
| 520 |
| 521 AuthData* URLRequest::GetTLSLoginAuthData() { |
| 522 return tls_login_auth_data_.get(); |
| 523 } |
| 524 |
| 525 void URLRequest::CancelTLSLogin() { |
| 526 DCHECK(job_); |
| 527 |
| 528 job_->CancelTLSLogin(); |
| 529 } |
| 530 |
| 531 void URLRequest::ContinueWithTLSLogin() { |
| 532 DCHECK(job_); |
| 533 DCHECK(tls_login_auth_data_->state == AUTH_STATE_HAVE_AUTH); |
| 534 DCHECK(!tls_login_auth_data_->username.empty()); |
| 535 |
| 536 job_->ContinueWithTLSLogin(); |
| 537 } |
| 538 |
| 507 void URLRequest::ContinueDespiteLastError() { | 539 void URLRequest::ContinueDespiteLastError() { |
| 508 DCHECK(job_); | 540 DCHECK(job_); |
| 509 | 541 |
| 510 job_->ContinueDespiteLastError(); | 542 job_->ContinueDespiteLastError(); |
| 511 } | 543 } |
| 512 | 544 |
| 513 void URLRequest::PrepareToRestart() { | 545 void URLRequest::PrepareToRestart() { |
| 514 DCHECK(job_); | 546 DCHECK(job_); |
| 515 | 547 |
| 516 // Close the current URL_REQUEST_START_JOB, since we will be starting a new | 548 // Close the current URL_REQUEST_START_JOB, since we will be starting a new |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 if (found != user_data_.end()) | 654 if (found != user_data_.end()) |
| 623 return found->second.get(); | 655 return found->second.get(); |
| 624 return NULL; | 656 return NULL; |
| 625 } | 657 } |
| 626 | 658 |
| 627 void URLRequest::SetUserData(const void* key, UserData* data) { | 659 void URLRequest::SetUserData(const void* key, UserData* data) { |
| 628 user_data_[key] = linked_ptr<UserData>(data); | 660 user_data_[key] = linked_ptr<UserData>(data); |
| 629 } | 661 } |
| 630 | 662 |
| 631 } // namespace net | 663 } // namespace net |
| OLD | NEW |