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.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 dict->Set("url_chain", std::move(list)); | 287 dict->Set("url_chain", std::move(list)); |
288 } | 288 } |
289 | 289 |
290 dict->SetInteger("load_flags", load_flags_); | 290 dict->SetInteger("load_flags", load_flags_); |
291 | 291 |
292 LoadStateWithParam load_state = GetLoadState(); | 292 LoadStateWithParam load_state = GetLoadState(); |
293 dict->SetInteger("load_state", load_state.state); | 293 dict->SetInteger("load_state", load_state.state); |
294 if (!load_state.param.empty()) | 294 if (!load_state.param.empty()) |
295 dict->SetString("load_state_param", load_state.param); | 295 dict->SetString("load_state_param", load_state.param); |
296 if (!blocked_by_.empty()) | 296 if (!blocked_by_.empty()) |
297 dict->SetString("delegate_info", blocked_by_); | 297 dict->SetString("delegate_blocked_by", blocked_by_); |
298 | 298 |
299 dict->SetString("method", method_); | 299 dict->SetString("method", method_); |
300 dict->SetBoolean("has_upload", has_upload()); | 300 dict->SetBoolean("has_upload", has_upload()); |
301 dict->SetBoolean("is_pending", is_pending_); | 301 dict->SetBoolean("is_pending", is_pending_); |
302 | 302 |
303 // Add the status of the request. The status should always be IO_PENDING, and | 303 // Add the status of the request. The status should always be IO_PENDING, and |
304 // the error should always be OK, unless something is holding onto a request | 304 // the error should always be OK, unless something is holding onto a request |
305 // that has finished or a request was leaked. Neither of these should happen. | 305 // that has finished or a request was leaked. Neither of these should happen. |
306 switch (status_.status()) { | 306 switch (status_.status()) { |
307 case URLRequestStatus::SUCCESS: | 307 case URLRequestStatus::SUCCESS: |
(...skipping 20 matching lines...) Expand all Loading... |
328 | 328 |
329 // Only log information to NetLog during startup and certain deferring calls | 329 // Only log information to NetLog during startup and certain deferring calls |
330 // to delegates. For all reads but the first, do nothing. | 330 // to delegates. For all reads but the first, do nothing. |
331 if (!calling_delegate_ && !response_info_.request_time.is_null()) | 331 if (!calling_delegate_ && !response_info_.request_time.is_null()) |
332 return; | 332 return; |
333 | 333 |
334 LogUnblocked(); | 334 LogUnblocked(); |
335 blocked_by_ = blocked_by; | 335 blocked_by_ = blocked_by; |
336 use_blocked_by_as_load_param_ = false; | 336 use_blocked_by_as_load_param_ = false; |
337 | 337 |
338 net_log_.BeginEvent(NetLogEventType::DELEGATE_INFO, | 338 net_log_.BeginEvent( |
339 NetLog::StringCallback("delegate_info", &blocked_by_)); | 339 NetLogEventType::DELEGATE_INFO, |
| 340 NetLog::StringCallback("delegate_blocked_by", &blocked_by_)); |
340 } | 341 } |
341 | 342 |
342 void URLRequest::LogAndReportBlockedBy(const char* source) { | 343 void URLRequest::LogAndReportBlockedBy(const char* source) { |
343 LogBlockedBy(source); | 344 LogBlockedBy(source); |
344 use_blocked_by_as_load_param_ = true; | 345 use_blocked_by_as_load_param_ = true; |
345 } | 346 } |
346 | 347 |
347 void URLRequest::LogUnblocked() { | 348 void URLRequest::LogUnblocked() { |
348 if (blocked_by_.empty()) | 349 if (blocked_by_.empty()) |
349 return; | 350 return; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 use_blocked_by_as_load_param_(false), | 578 use_blocked_by_as_load_param_(false), |
578 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, | 579 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, |
579 base::Unretained(this))), | 580 base::Unretained(this))), |
580 has_notified_completion_(false), | 581 has_notified_completion_(false), |
581 received_response_content_length_(0), | 582 received_response_content_length_(0), |
582 creation_time_(base::TimeTicks::Now()) { | 583 creation_time_(base::TimeTicks::Now()) { |
583 // Sanity check out environment. | 584 // Sanity check out environment. |
584 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); | 585 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); |
585 | 586 |
586 context->url_requests()->insert(this); | 587 context->url_requests()->insert(this); |
587 net_log_.BeginEvent(NetLogEventType::REQUEST_ALIVE); | 588 net_log_.BeginEvent( |
| 589 NetLogEventType::REQUEST_ALIVE, |
| 590 base::Bind(&NetLogURLRequestConstructorCallback, &url, priority_)); |
588 } | 591 } |
589 | 592 |
590 void URLRequest::BeforeRequestComplete(int error) { | 593 void URLRequest::BeforeRequestComplete(int error) { |
591 DCHECK(!job_.get()); | 594 DCHECK(!job_.get()); |
592 DCHECK_NE(ERR_IO_PENDING, error); | 595 DCHECK_NE(ERR_IO_PENDING, error); |
593 | 596 |
594 // Check that there are no callbacks to already canceled requests. | 597 // Check that there are no callbacks to already canceled requests. |
595 DCHECK_NE(URLRequestStatus::CANCELED, status_.status()); | 598 DCHECK_NE(URLRequestStatus::CANCELED, status_.status()); |
596 | 599 |
597 OnCallToDelegateComplete(); | 600 OnCallToDelegateComplete(); |
(...skipping 22 matching lines...) Expand all Loading... |
620 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 623 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
621 tracked_objects::ScopedTracker tracking_profile( | 624 tracked_objects::ScopedTracker tracking_profile( |
622 FROM_HERE_WITH_EXPLICIT_FUNCTION("456327 URLRequest::StartJob")); | 625 FROM_HERE_WITH_EXPLICIT_FUNCTION("456327 URLRequest::StartJob")); |
623 | 626 |
624 DCHECK(!is_pending_); | 627 DCHECK(!is_pending_); |
625 DCHECK(!job_.get()); | 628 DCHECK(!job_.get()); |
626 | 629 |
627 net_log_.BeginEvent( | 630 net_log_.BeginEvent( |
628 NetLogEventType::URL_REQUEST_START_JOB, | 631 NetLogEventType::URL_REQUEST_START_JOB, |
629 base::Bind(&NetLogURLRequestStartCallback, &url(), &method_, load_flags_, | 632 base::Bind(&NetLogURLRequestStartCallback, &url(), &method_, load_flags_, |
630 priority_, | |
631 upload_data_stream_ ? upload_data_stream_->identifier() : -1)); | 633 upload_data_stream_ ? upload_data_stream_->identifier() : -1)); |
632 | 634 |
633 job_.reset(job); | 635 job_.reset(job); |
634 job_->SetExtraRequestHeaders(extra_request_headers_); | 636 job_->SetExtraRequestHeaders(extra_request_headers_); |
635 job_->SetPriority(priority_); | 637 job_->SetPriority(priority_); |
636 | 638 |
637 if (upload_data_stream_.get()) | 639 if (upload_data_stream_.get()) |
638 job_->SetUpload(upload_data_stream_.get()); | 640 job_->SetUpload(upload_data_stream_.get()); |
639 | 641 |
640 is_pending_ = true; | 642 is_pending_ = true; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 NOTREACHED(); | 1019 NOTREACHED(); |
1018 // Maintain the invariant that requests with IGNORE_LIMITS set | 1020 // Maintain the invariant that requests with IGNORE_LIMITS set |
1019 // have MAXIMUM_PRIORITY for release mode. | 1021 // have MAXIMUM_PRIORITY for release mode. |
1020 return; | 1022 return; |
1021 } | 1023 } |
1022 | 1024 |
1023 if (priority_ == priority) | 1025 if (priority_ == priority) |
1024 return; | 1026 return; |
1025 | 1027 |
1026 priority_ = priority; | 1028 priority_ = priority; |
1027 if (job_.get()) { | 1029 net_log_.AddEvent( |
1028 net_log_.AddEvent( | 1030 NetLogEventType::URL_REQUEST_SET_PRIORITY, |
1029 NetLogEventType::URL_REQUEST_SET_PRIORITY, | 1031 NetLog::StringCallback("priority", RequestPriorityToString(priority_))); |
1030 NetLog::StringCallback("priority", RequestPriorityToString(priority_))); | 1032 if (job_.get()) |
1031 job_->SetPriority(priority_); | 1033 job_->SetPriority(priority_); |
1032 } | |
1033 } | 1034 } |
1034 | 1035 |
1035 void URLRequest::NotifyAuthRequired(AuthChallengeInfo* auth_info) { | 1036 void URLRequest::NotifyAuthRequired(AuthChallengeInfo* auth_info) { |
1036 NetworkDelegate::AuthRequiredResponse rv = | 1037 NetworkDelegate::AuthRequiredResponse rv = |
1037 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 1038 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
1038 auth_info_ = auth_info; | 1039 auth_info_ = auth_info; |
1039 if (network_delegate_) { | 1040 if (network_delegate_) { |
1040 OnCallToDelegate(); | 1041 OnCallToDelegate(); |
1041 rv = network_delegate_->NotifyAuthRequired( | 1042 rv = network_delegate_->NotifyAuthRequired( |
1042 this, | 1043 this, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 out->clear(); | 1215 out->clear(); |
1215 } | 1216 } |
1216 | 1217 |
1217 void URLRequest::set_status(URLRequestStatus status) { | 1218 void URLRequest::set_status(URLRequestStatus status) { |
1218 DCHECK(status_.is_io_pending() || status_.is_success() || | 1219 DCHECK(status_.is_io_pending() || status_.is_success() || |
1219 (!status.is_success() && !status.is_io_pending())); | 1220 (!status.is_success() && !status.is_io_pending())); |
1220 status_ = status; | 1221 status_ = status; |
1221 } | 1222 } |
1222 | 1223 |
1223 } // namespace net | 1224 } // namespace net |
OLD | NEW |