Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: net/url_request/url_fetcher_core.cc

Issue 2846873002: Network traffic annotation added to URLFetcher. (Closed)
Patch Set: Unnecessary const(s) removed. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_fetcher_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_fetcher_core.h" 5 #include "net/url_request/url_fetcher_core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 while (!fetchers_.empty()) 64 while (!fetchers_.empty())
65 (*fetchers_.begin())->CancelURLRequest(ERR_ABORTED); 65 (*fetchers_.begin())->CancelURLRequest(ERR_ABORTED);
66 } 66 }
67 67
68 // URLFetcherCore ------------------------------------------------------------- 68 // URLFetcherCore -------------------------------------------------------------
69 69
70 // static 70 // static
71 base::LazyInstance<URLFetcherCore::Registry>::DestructorAtExit 71 base::LazyInstance<URLFetcherCore::Registry>::DestructorAtExit
72 URLFetcherCore::g_registry = LAZY_INSTANCE_INITIALIZER; 72 URLFetcherCore::g_registry = LAZY_INSTANCE_INITIALIZER;
73 73
74 URLFetcherCore::URLFetcherCore(URLFetcher* fetcher, 74 URLFetcherCore::URLFetcherCore(
75 const GURL& original_url, 75 URLFetcher* fetcher,
76 URLFetcher::RequestType request_type, 76 const GURL& original_url,
77 URLFetcherDelegate* d) 77 URLFetcher::RequestType request_type,
78 URLFetcherDelegate* d,
79 net::NetworkTrafficAnnotationTag traffic_annotation)
78 : fetcher_(fetcher), 80 : fetcher_(fetcher),
79 original_url_(original_url), 81 original_url_(original_url),
80 request_type_(request_type), 82 request_type_(request_type),
81 delegate_(d), 83 delegate_(d),
82 delegate_task_runner_(base::SequencedTaskRunnerHandle::Get()), 84 delegate_task_runner_(base::SequencedTaskRunnerHandle::Get()),
83 load_flags_(LOAD_NORMAL), 85 load_flags_(LOAD_NORMAL),
84 response_code_(URLFetcher::RESPONSE_CODE_INVALID), 86 response_code_(URLFetcher::RESPONSE_CODE_INVALID),
85 url_request_data_key_(NULL), 87 url_request_data_key_(NULL),
86 was_fetched_via_proxy_(false), 88 was_fetched_via_proxy_(false),
87 was_cached_(false), 89 was_cached_(false),
88 received_response_content_length_(0), 90 received_response_content_length_(0),
89 total_received_bytes_(0), 91 total_received_bytes_(0),
90 upload_content_set_(false), 92 upload_content_set_(false),
91 upload_range_offset_(0), 93 upload_range_offset_(0),
92 upload_range_length_(0), 94 upload_range_length_(0),
93 referrer_policy_( 95 referrer_policy_(
94 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), 96 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
95 is_chunked_upload_(false), 97 is_chunked_upload_(false),
96 was_cancelled_(false), 98 was_cancelled_(false),
97 stop_on_redirect_(false), 99 stop_on_redirect_(false),
98 stopped_on_redirect_(false), 100 stopped_on_redirect_(false),
99 automatically_retry_on_5xx_(true), 101 automatically_retry_on_5xx_(true),
100 num_retries_on_5xx_(0), 102 num_retries_on_5xx_(0),
101 max_retries_on_5xx_(0), 103 max_retries_on_5xx_(0),
102 num_retries_on_network_changes_(0), 104 num_retries_on_network_changes_(0),
103 max_retries_on_network_changes_(0), 105 max_retries_on_network_changes_(0),
104 current_upload_bytes_(-1), 106 current_upload_bytes_(-1),
105 current_response_bytes_(0), 107 current_response_bytes_(0),
106 total_response_bytes_(-1) { 108 total_response_bytes_(-1),
109 traffic_annotation_(traffic_annotation) {
107 CHECK(original_url_.is_valid()); 110 CHECK(original_url_.is_valid());
108 } 111 }
109 112
110 void URLFetcherCore::Start() { 113 void URLFetcherCore::Start() {
111 DCHECK(delegate_task_runner_); 114 DCHECK(delegate_task_runner_);
112 DCHECK(request_context_getter_.get()) << "We need an URLRequestContext!"; 115 DCHECK(request_context_getter_.get()) << "We need an URLRequestContext!";
113 if (network_task_runner_.get()) { 116 if (network_task_runner_.get()) {
114 DCHECK_EQ(network_task_runner_, 117 DCHECK_EQ(network_task_runner_,
115 request_context_getter_->GetNetworkTaskRunner()); 118 request_context_getter_->GetNetworkTaskRunner());
116 } else { 119 } else {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 CancelRequestAndInformDelegate(ERR_CONTEXT_SHUT_DOWN); 548 CancelRequestAndInformDelegate(ERR_CONTEXT_SHUT_DOWN);
546 return; 549 return;
547 } 550 }
548 551
549 DCHECK(!request_.get()); 552 DCHECK(!request_.get());
550 553
551 g_registry.Get().AddURLFetcherCore(this); 554 g_registry.Get().AddURLFetcherCore(this);
552 current_response_bytes_ = 0; 555 current_response_bytes_ = 0;
553 request_context_getter_->AddObserver(this); 556 request_context_getter_->AddObserver(this);
554 request_ = request_context_getter_->GetURLRequestContext()->CreateRequest( 557 request_ = request_context_getter_->GetURLRequestContext()->CreateRequest(
555 original_url_, DEFAULT_PRIORITY, this); 558 original_url_, DEFAULT_PRIORITY, this, traffic_annotation_);
556 int flags = request_->load_flags() | load_flags_; 559 int flags = request_->load_flags() | load_flags_;
557 560
558 // TODO(mmenke): This should really be with the other code to set the upload 561 // TODO(mmenke): This should really be with the other code to set the upload
559 // body, below. 562 // body, below.
560 if (chunked_stream_) 563 if (chunked_stream_)
561 request_->set_upload(std::move(chunked_stream_)); 564 request_->set_upload(std::move(chunked_stream_));
562 565
563 request_->SetLoadFlags(flags); 566 request_->SetLoadFlags(flags);
564 request_->SetReferrer(referrer_); 567 request_->SetReferrer(referrer_);
565 request_->set_referrer_policy(referrer_policy_); 568 request_->set_referrer_policy(referrer_policy_);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 958 }
956 959
957 void URLFetcherCore::AssertHasNoUploadData() const { 960 void URLFetcherCore::AssertHasNoUploadData() const {
958 DCHECK(!upload_content_set_); 961 DCHECK(!upload_content_set_);
959 DCHECK(upload_content_.empty()); 962 DCHECK(upload_content_.empty());
960 DCHECK(upload_file_path_.empty()); 963 DCHECK(upload_file_path_.empty());
961 DCHECK(upload_stream_factory_.is_null()); 964 DCHECK(upload_stream_factory_.is_null());
962 } 965 }
963 966
964 } // namespace net 967 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_fetcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698