| 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_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "net/url_request/url_request_context.h" | 33 #include "net/url_request/url_request_context.h" |
| 34 #include "net/url_request/url_request_error_job.h" | 34 #include "net/url_request/url_request_error_job.h" |
| 35 #include "net/url_request/url_request_redirect_job.h" | 35 #include "net/url_request/url_request_redirect_job.h" |
| 36 #include "net/url_request/url_request_throttler_header_adapter.h" | 36 #include "net/url_request/url_request_throttler_header_adapter.h" |
| 37 #include "net/url_request/url_request_throttler_manager.h" | 37 #include "net/url_request/url_request_throttler_manager.h" |
| 38 | 38 |
| 39 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 39 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 40 | 40 |
| 41 // TODO(darin): make sure the port blocking code is not lost | 41 // TODO(darin): make sure the port blocking code is not lost |
| 42 // static | 42 // static |
| 43 URLRequestJob* URLRequestHttpJob::Factory(net::URLRequest* request, | 43 net::URLRequestJob* URLRequestHttpJob::Factory(net::URLRequest* request, |
| 44 const std::string& scheme) { | 44 const std::string& scheme) { |
| 45 DCHECK(scheme == "http" || scheme == "https"); | 45 DCHECK(scheme == "http" || scheme == "https"); |
| 46 | 46 |
| 47 int port = request->url().IntPort(); | 47 int port = request->url().IntPort(); |
| 48 if (!net::IsPortAllowedByDefault(port) && !net::IsPortAllowedByOverride(port)) | 48 if (!net::IsPortAllowedByDefault(port) && !net::IsPortAllowedByOverride(port)) |
| 49 return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT); | 49 return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT); |
| 50 | 50 |
| 51 if (!request->context() || | 51 if (!request->context() || |
| 52 !request->context()->http_transaction_factory()) { | 52 !request->context()->http_transaction_factory()) { |
| 53 NOTREACHED() << "requires a valid context"; | 53 NOTREACHED() << "requires a valid context"; |
| 54 return new URLRequestErrorJob(request, net::ERR_INVALID_ARGUMENT); | 54 return new URLRequestErrorJob(request, net::ERR_INVALID_ARGUMENT); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 return new URLRequestRedirectJob(request, new_location); | 71 return new URLRequestRedirectJob(request, new_location); |
| 72 } else { | 72 } else { |
| 73 // TODO(agl): implement opportunistic HTTPS upgrade. | 73 // TODO(agl): implement opportunistic HTTPS upgrade. |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 return new URLRequestHttpJob(request); | 77 return new URLRequestHttpJob(request); |
| 78 } | 78 } |
| 79 | 79 |
| 80 URLRequestHttpJob::URLRequestHttpJob(net::URLRequest* request) | 80 URLRequestHttpJob::URLRequestHttpJob(net::URLRequest* request) |
| 81 : URLRequestJob(request), | 81 : net::URLRequestJob(request), |
| 82 response_info_(NULL), | 82 response_info_(NULL), |
| 83 response_cookies_save_index_(0), | 83 response_cookies_save_index_(0), |
| 84 proxy_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), | 84 proxy_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), |
| 85 server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), | 85 server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), |
| 86 ALLOW_THIS_IN_INITIALIZER_LIST(can_get_cookies_callback_( | 86 ALLOW_THIS_IN_INITIALIZER_LIST(can_get_cookies_callback_( |
| 87 this, &URLRequestHttpJob::OnCanGetCookiesCompleted)), | 87 this, &URLRequestHttpJob::OnCanGetCookiesCompleted)), |
| 88 ALLOW_THIS_IN_INITIALIZER_LIST(can_set_cookie_callback_( | 88 ALLOW_THIS_IN_INITIALIZER_LIST(can_set_cookie_callback_( |
| 89 this, &URLRequestHttpJob::OnCanSetCookieCompleted)), | 89 this, &URLRequestHttpJob::OnCanSetCookieCompleted)), |
| 90 ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_( | 90 ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_( |
| 91 this, &URLRequestHttpJob::OnStartCompleted)), | 91 this, &URLRequestHttpJob::OnStartCompleted)), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 AddExtraHeaders(); | 162 AddExtraHeaders(); |
| 163 AddCookieHeaderAndStart(); | 163 AddCookieHeaderAndStart(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void URLRequestHttpJob::Kill() { | 166 void URLRequestHttpJob::Kill() { |
| 167 if (!transaction_.get()) | 167 if (!transaction_.get()) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 DestroyTransaction(); | 170 DestroyTransaction(); |
| 171 URLRequestJob::Kill(); | 171 net::URLRequestJob::Kill(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 net::LoadState URLRequestHttpJob::GetLoadState() const { | 174 net::LoadState URLRequestHttpJob::GetLoadState() const { |
| 175 return transaction_.get() ? | 175 return transaction_.get() ? |
| 176 transaction_->GetLoadState() : net::LOAD_STATE_IDLE; | 176 transaction_->GetLoadState() : net::LOAD_STATE_IDLE; |
| 177 } | 177 } |
| 178 | 178 |
| 179 uint64 URLRequestHttpJob::GetUploadProgress() const { | 179 uint64 URLRequestHttpJob::GetUploadProgress() const { |
| 180 return transaction_.get() ? transaction_->GetUploadProgress() : 0; | 180 return transaction_.get() ? transaction_->GetUploadProgress() : 0; |
| 181 } | 181 } |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 // The HTTP transaction may be restarted several times for the purposes | 616 // The HTTP transaction may be restarted several times for the purposes |
| 617 // of sending authorization information. Each time it restarts, we get | 617 // of sending authorization information. Each time it restarts, we get |
| 618 // notified of the headers completion so that we can update the cookie store. | 618 // notified of the headers completion so that we can update the cookie store. |
| 619 if (transaction_->IsReadyToRestartForAuth()) { | 619 if (transaction_->IsReadyToRestartForAuth()) { |
| 620 DCHECK(!response_info_->auth_challenge.get()); | 620 DCHECK(!response_info_->auth_challenge.get()); |
| 621 RestartTransactionWithAuth(string16(), string16()); | 621 RestartTransactionWithAuth(string16(), string16()); |
| 622 return; | 622 return; |
| 623 } | 623 } |
| 624 | 624 |
| 625 URLRequestJob::NotifyHeadersComplete(); | 625 net::URLRequestJob::NotifyHeadersComplete(); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void URLRequestHttpJob::DestroyTransaction() { | 628 void URLRequestHttpJob::DestroyTransaction() { |
| 629 DCHECK(transaction_.get()); | 629 DCHECK(transaction_.get()); |
| 630 | 630 |
| 631 transaction_.reset(); | 631 transaction_.reset(); |
| 632 response_info_ = NULL; | 632 response_info_ = NULL; |
| 633 context_ = NULL; | 633 context_ = NULL; |
| 634 } | 634 } |
| 635 | 635 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 HTTPSProberDelegate* delegate = | 946 HTTPSProberDelegate* delegate = |
| 947 new HTTPSProberDelegate(request_info_.url.host(), max_age, | 947 new HTTPSProberDelegate(request_info_.url.host(), max_age, |
| 948 include_subdomains, | 948 include_subdomains, |
| 949 ctx->transport_security_state()); | 949 ctx->transport_security_state()); |
| 950 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), | 950 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), |
| 951 delegate)) { | 951 delegate)) { |
| 952 delete delegate; | 952 delete delegate; |
| 953 } | 953 } |
| 954 } | 954 } |
| 955 } | 955 } |
| OLD | NEW |