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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 StartJob(URLRequestJobManager::GetInstance()->CreateJob( | 548 StartJob(URLRequestJobManager::GetInstance()->CreateJob( |
549 this, network_delegate_)); | 549 this, network_delegate_)); |
550 } | 550 } |
551 | 551 |
552 /////////////////////////////////////////////////////////////////////////////// | 552 /////////////////////////////////////////////////////////////////////////////// |
553 | 553 |
554 URLRequest::URLRequest(const GURL& url, | 554 URLRequest::URLRequest(const GURL& url, |
555 RequestPriority priority, | 555 RequestPriority priority, |
556 Delegate* delegate, | 556 Delegate* delegate, |
557 const URLRequestContext* context, | 557 const URLRequestContext* context, |
558 NetworkDelegate* network_delegate) | 558 NetworkDelegate* network_delegate, |
| 559 NetworkTrafficAnnotationTag traffic_annotation) |
559 : context_(context), | 560 : context_(context), |
560 network_delegate_(network_delegate ? network_delegate | 561 network_delegate_(network_delegate ? network_delegate |
561 : context->network_delegate()), | 562 : context->network_delegate()), |
562 net_log_(NetLogWithSource::Make(context->net_log(), | 563 net_log_(NetLogWithSource::Make(context->net_log(), |
563 NetLogSourceType::URL_REQUEST)), | 564 NetLogSourceType::URL_REQUEST)), |
564 url_chain_(1, url), | 565 url_chain_(1, url), |
565 method_("GET"), | 566 method_("GET"), |
566 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | 567 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), |
567 first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL), | 568 first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL), |
568 load_flags_(LOAD_NORMAL), | 569 load_flags_(LOAD_NORMAL), |
569 delegate_(delegate), | 570 delegate_(delegate), |
570 status_(URLRequestStatus::FromError(OK)), | 571 status_(URLRequestStatus::FromError(OK)), |
571 is_pending_(false), | 572 is_pending_(false), |
572 is_redirecting_(false), | 573 is_redirecting_(false), |
573 redirect_limit_(kMaxRedirects), | 574 redirect_limit_(kMaxRedirects), |
574 priority_(priority), | 575 priority_(priority), |
575 identifier_(GenerateURLRequestIdentifier()), | 576 identifier_(GenerateURLRequestIdentifier()), |
576 calling_delegate_(false), | 577 calling_delegate_(false), |
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 raw_header_size_(0) { | 584 raw_header_size_(0), |
| 585 traffic_annotation_(traffic_annotation) { |
584 // Sanity check out environment. | 586 // Sanity check out environment. |
585 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); | 587 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); |
586 | 588 |
587 context->InsertURLRequest(this); | 589 context->InsertURLRequest(this); |
588 net_log_.BeginEvent( | 590 net_log_.BeginEvent( |
589 NetLogEventType::REQUEST_ALIVE, | 591 NetLogEventType::REQUEST_ALIVE, |
590 base::Bind(&NetLogURLRequestConstructorCallback, &url, priority_)); | 592 base::Bind(&NetLogURLRequestConstructorCallback, &url, priority_)); |
591 } | 593 } |
592 | 594 |
593 void URLRequest::BeforeRequestComplete(int error) { | 595 void URLRequest::BeforeRequestComplete(int error) { |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 out->clear(); | 1215 out->clear(); |
1214 } | 1216 } |
1215 | 1217 |
1216 void URLRequest::set_status(URLRequestStatus status) { | 1218 void URLRequest::set_status(URLRequestStatus status) { |
1217 DCHECK(status_.is_io_pending() || status_.is_success() || | 1219 DCHECK(status_.is_io_pending() || status_.is_success() || |
1218 (!status.is_success() && !status.is_io_pending())); | 1220 (!status.is_success() && !status.is_io_pending())); |
1219 status_ = status; | 1221 status_ = status; |
1220 } | 1222 } |
1221 | 1223 |
1222 } // namespace net | 1224 } // namespace net |
OLD | NEW |