| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_job.h" | 5 #include "net/url_request/url_request_job.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/location.h" | 12 #include "base/location.h" |
| 12 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/power_monitor/power_monitor.h" | 14 #include "base/power_monitor/power_monitor.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 15 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 void URLRequestJob::SetUpload(UploadDataStream* upload) { | 92 void URLRequestJob::SetUpload(UploadDataStream* upload) { |
| 92 } | 93 } |
| 93 | 94 |
| 94 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { | 95 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { |
| 95 } | 96 } |
| 96 | 97 |
| 97 void URLRequestJob::SetPriority(RequestPriority priority) { | 98 void URLRequestJob::SetPriority(RequestPriority priority) { |
| 98 } | 99 } |
| 99 | 100 |
| 100 void URLRequestJob::Kill() { | 101 void URLRequestJob::Kill() { |
| 102 TRACE_EVENT0("toplevel", "URLRequestJob::Kill"); |
| 103 |
| 101 weak_factory_.InvalidateWeakPtrs(); | 104 weak_factory_.InvalidateWeakPtrs(); |
| 102 // Make sure the URLRequest is notified that the job is done. This assumes | 105 // Make sure the URLRequest is notified that the job is done. This assumes |
| 103 // that the URLRequest took care of setting its error status before calling | 106 // that the URLRequest took care of setting its error status before calling |
| 104 // Kill(). | 107 // Kill(). |
| 105 // TODO(mmenke): The URLRequest is currently deleted before this method | 108 // TODO(mmenke): The URLRequest is currently deleted before this method |
| 106 // invokes its async callback whenever this is called by the URLRequest. | 109 // invokes its async callback whenever this is called by the URLRequest. |
| 107 // Try to simplify how cancellation works. | 110 // Try to simplify how cancellation works. |
| 108 NotifyCanceled(); | 111 NotifyCanceled(); |
| 109 } | 112 } |
| 110 | 113 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 SSLCertRequestInfo* cert_request_info) { | 360 SSLCertRequestInfo* cert_request_info) { |
| 358 request_->NotifyCertificateRequested(cert_request_info); | 361 request_->NotifyCertificateRequested(cert_request_info); |
| 359 } | 362 } |
| 360 | 363 |
| 361 void URLRequestJob::NotifySSLCertificateError(const SSLInfo& ssl_info, | 364 void URLRequestJob::NotifySSLCertificateError(const SSLInfo& ssl_info, |
| 362 bool fatal) { | 365 bool fatal) { |
| 363 request_->NotifySSLCertificateError(ssl_info, fatal); | 366 request_->NotifySSLCertificateError(ssl_info, fatal); |
| 364 } | 367 } |
| 365 | 368 |
| 366 bool URLRequestJob::CanGetCookies(const CookieList& cookie_list) const { | 369 bool URLRequestJob::CanGetCookies(const CookieList& cookie_list) const { |
| 370 TRACE_EVENT0("toplevel", "URLRequestJob::CanGetCookies"); |
| 367 return request_->CanGetCookies(cookie_list); | 371 return request_->CanGetCookies(cookie_list); |
| 368 } | 372 } |
| 369 | 373 |
| 370 bool URLRequestJob::CanSetCookie(const std::string& cookie_line, | 374 bool URLRequestJob::CanSetCookie(const std::string& cookie_line, |
| 371 CookieOptions* options) const { | 375 CookieOptions* options) const { |
| 372 return request_->CanSetCookie(cookie_line, options); | 376 return request_->CanSetCookie(cookie_line, options); |
| 373 } | 377 } |
| 374 | 378 |
| 375 bool URLRequestJob::CanEnablePrivacyMode() const { | 379 bool URLRequestJob::CanEnablePrivacyMode() const { |
| 376 return request_->CanEnablePrivacyMode(); | 380 return request_->CanEnablePrivacyMode(); |
| 377 } | 381 } |
| 378 | 382 |
| 379 void URLRequestJob::NotifyBeforeNetworkStart(bool* defer) { | 383 void URLRequestJob::NotifyBeforeNetworkStart(bool* defer) { |
| 380 request_->NotifyBeforeNetworkStart(defer); | 384 request_->NotifyBeforeNetworkStart(defer); |
| 381 } | 385 } |
| 382 | 386 |
| 383 void URLRequestJob::NotifyHeadersComplete() { | 387 void URLRequestJob::NotifyHeadersComplete() { |
| 388 TRACE_EVENT0("toplevel", "URLRequestJob::NotifyHeadersComplete"); |
| 384 if (has_handled_response_) | 389 if (has_handled_response_) |
| 385 return; | 390 return; |
| 386 | 391 |
| 387 // The URLRequest status should still be IO_PENDING, which it was set to | 392 // The URLRequest status should still be IO_PENDING, which it was set to |
| 388 // before the URLRequestJob was started. On error or cancellation, this | 393 // before the URLRequestJob was started. On error or cancellation, this |
| 389 // method should not be called. | 394 // method should not be called. |
| 390 DCHECK(request_->status().is_io_pending()); | 395 DCHECK(request_->status().is_io_pending()); |
| 391 SetStatus(URLRequestStatus()); | 396 SetStatus(URLRequestStatus()); |
| 392 | 397 |
| 393 // Initialize to the current time, and let the subclass optionally override | 398 // Initialize to the current time, and let the subclass optionally override |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 int64_t total_sent_bytes = GetTotalSentBytes(); | 978 int64_t total_sent_bytes = GetTotalSentBytes(); |
| 974 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); | 979 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); |
| 975 if (total_sent_bytes > last_notified_total_sent_bytes_) { | 980 if (total_sent_bytes > last_notified_total_sent_bytes_) { |
| 976 network_delegate_->NotifyNetworkBytesSent( | 981 network_delegate_->NotifyNetworkBytesSent( |
| 977 request_, total_sent_bytes - last_notified_total_sent_bytes_); | 982 request_, total_sent_bytes - last_notified_total_sent_bytes_); |
| 978 } | 983 } |
| 979 last_notified_total_sent_bytes_ = total_sent_bytes; | 984 last_notified_total_sent_bytes_ = total_sent_bytes; |
| 980 } | 985 } |
| 981 | 986 |
| 982 } // namespace net | 987 } // namespace net |
| OLD | NEW |