Chromium Code Reviews| 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 #include "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 load_flags_(LOAD_NORMAL), | 143 load_flags_(LOAD_NORMAL), |
| 144 delegate_(delegate), | 144 delegate_(delegate), |
| 145 is_pending_(false), | 145 is_pending_(false), |
| 146 redirect_limit_(kMaxRedirects), | 146 redirect_limit_(kMaxRedirects), |
| 147 final_upload_progress_(0), | 147 final_upload_progress_(0), |
| 148 priority_(LOWEST), | 148 priority_(LOWEST), |
| 149 identifier_(GenerateURLRequestIdentifier()), | 149 identifier_(GenerateURLRequestIdentifier()), |
| 150 blocked_on_delegate_(false), | 150 blocked_on_delegate_(false), |
| 151 ALLOW_THIS_IN_INITIALIZER_LIST( | 151 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 152 before_request_callback_(this, &URLRequest::BeforeRequestComplete)), | 152 before_request_callback_(this, &URLRequest::BeforeRequestComplete)), |
| 153 has_notified_completion_(false) { | 153 has_notified_completion_(false), |
| 154 start_time_(base::TimeTicks::Now()) { | |
| 154 SIMPLE_STATS_COUNTER("URLRequestCount"); | 155 SIMPLE_STATS_COUNTER("URLRequestCount"); |
| 155 | 156 |
| 156 // Sanity check out environment. | 157 // Sanity check out environment. |
| 157 DCHECK(MessageLoop::current()) << | 158 DCHECK(MessageLoop::current()) << |
| 158 "The current MessageLoop must exist"; | 159 "The current MessageLoop must exist"; |
| 159 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 160 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
| 160 "The current MessageLoop must be TYPE_IO"; | 161 "The current MessageLoop must be TYPE_IO"; |
| 161 } | 162 } |
| 162 | 163 |
| 163 URLRequest::~URLRequest() { | 164 URLRequest::~URLRequest() { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 } | 406 } |
| 406 | 407 |
| 407 return ret; | 408 return ret; |
| 408 } | 409 } |
| 409 | 410 |
| 410 void URLRequest::set_delegate(Delegate* delegate) { | 411 void URLRequest::set_delegate(Delegate* delegate) { |
| 411 delegate_ = delegate; | 412 delegate_ = delegate; |
| 412 } | 413 } |
| 413 | 414 |
| 414 void URLRequest::Start() { | 415 void URLRequest::Start() { |
| 415 response_info_.request_time = Time::Now(); | 416 response_info_.request_time = Time::Now(); |
|
wtc
2011/12/06 21:00:53
Since URLRequest has a Start() method, setting the
James Simonsen
2011/12/10 00:21:47
Done.
| |
| 416 | 417 |
| 417 // Only notify the delegate for the initial request. | 418 // Only notify the delegate for the initial request. |
| 418 if (context_ && context_->network_delegate()) { | 419 if (context_ && context_->network_delegate()) { |
| 419 int error = context_->network_delegate()->NotifyBeforeURLRequest( | 420 int error = context_->network_delegate()->NotifyBeforeURLRequest( |
| 420 this, &before_request_callback_, &delegate_redirect_url_); | 421 this, &before_request_callback_, &delegate_redirect_url_); |
| 421 if (error != net::OK) { | 422 if (error != net::OK) { |
| 422 if (error == net::ERR_IO_PENDING) { | 423 if (error == net::ERR_IO_PENDING) { |
| 423 // Paused on the delegate, will invoke |before_request_callback_| later. | 424 // Paused on the delegate, will invoke |before_request_callback_| later. |
| 424 SetBlockedOnDelegate(); | 425 SetBlockedOnDelegate(); |
| 425 } else { | 426 } else { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 892 | 893 |
| 893 void URLRequest::SetUnblockedOnDelegate() { | 894 void URLRequest::SetUnblockedOnDelegate() { |
| 894 if (!blocked_on_delegate_) | 895 if (!blocked_on_delegate_) |
| 895 return; | 896 return; |
| 896 blocked_on_delegate_ = false; | 897 blocked_on_delegate_ = false; |
| 897 load_state_param_.clear(); | 898 load_state_param_.clear(); |
| 898 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 899 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 899 } | 900 } |
| 900 | 901 |
| 901 } // namespace net | 902 } // namespace net |
| OLD | NEW |