OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "google_apis/gcm/engine/checkin_request.h" | 5 #include "google_apis/gcm/engine/checkin_request.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 11 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
12 #include "google_apis/gcm/protocol/checkin.pb.h" | 12 #include "google_apis/gcm/protocol/checkin.pb.h" |
13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
14 #include "net/traffic_annotation/network_traffic_annotation.h" | |
14 #include "net/url_request/url_fetcher.h" | 15 #include "net/url_request/url_fetcher.h" |
15 #include "net/url_request/url_request_status.h" | 16 #include "net/url_request/url_request_status.h" |
16 | 17 |
17 namespace gcm { | 18 namespace gcm { |
18 | 19 |
19 namespace { | 20 namespace { |
20 const char kRequestContentType[] = "application/x-protobuf"; | 21 const char kRequestContentType[] = "application/x-protobuf"; |
21 const int kRequestVersionValue = 3; | 22 const int kRequestVersionValue = 3; |
22 const int kDefaultUserSerialNumber = 0; | 23 const int kDefaultUserSerialNumber = 0; |
23 | 24 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 for (std::map<std::string, std::string>::const_iterator iter = | 138 for (std::map<std::string, std::string>::const_iterator iter = |
138 request_info_.account_tokens.begin(); | 139 request_info_.account_tokens.begin(); |
139 iter != request_info_.account_tokens.end(); | 140 iter != request_info_.account_tokens.end(); |
140 ++iter) { | 141 ++iter) { |
141 request.add_account_cookie(iter->first); | 142 request.add_account_cookie(iter->first); |
142 request.add_account_cookie(iter->second); | 143 request.add_account_cookie(iter->second); |
143 } | 144 } |
144 | 145 |
145 std::string upload_data; | 146 std::string upload_data; |
146 CHECK(request.SerializeToString(&upload_data)); | 147 CHECK(request.SerializeToString(&upload_data)); |
147 | 148 net::NetworkTrafficAnnotationTag traffic_annotation = |
Peter Beverloo
2017/03/15 18:58:04
Proposal (gcm_checkin):
semantics {
sender: "GC
Ramin Halavati
2017/03/16 08:43:51
Done.
| |
148 url_fetcher_ = | 149 net::DefineNetworkTrafficAnnotation("...", R"( |
149 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this); | 150 semantics { |
151 sender: "..." | |
152 description: "..." | |
153 trigger: "..." | |
154 data: "..." | |
155 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
156 } | |
157 policy { | |
158 cookies_allowed: false/true | |
159 cookies_store: "..." | |
160 setting: "..." | |
161 policy { | |
162 [POLICY_NAME] { | |
163 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
164 [POLICY_NAME]: ... //(value to disable it) | |
165 } | |
166 } | |
167 policy_exception_justification: "..." | |
168 })"); | |
169 url_fetcher_ = net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, | |
170 this, traffic_annotation); | |
150 url_fetcher_->SetRequestContext(request_context_getter_); | 171 url_fetcher_->SetRequestContext(request_context_getter_); |
151 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 172 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
152 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 173 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
153 net::LOAD_DO_NOT_SAVE_COOKIES); | 174 net::LOAD_DO_NOT_SAVE_COOKIES); |
154 recorder_->RecordCheckinInitiated(request_info_.android_id); | 175 recorder_->RecordCheckinInitiated(request_info_.android_id); |
155 request_start_time_ = base::TimeTicks::Now(); | 176 request_start_time_ = base::TimeTicks::Now(); |
156 url_fetcher_->Start(); | 177 url_fetcher_->Start(); |
157 } | 178 } |
158 | 179 |
159 void CheckinRequest::RetryWithBackoff() { | 180 void CheckinRequest::RetryWithBackoff() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 | 242 |
222 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); | 243 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); |
223 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", | 244 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", |
224 backoff_entry_.failure_count()); | 245 backoff_entry_.failure_count()); |
225 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", | 246 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", |
226 base::TimeTicks::Now() - request_start_time_); | 247 base::TimeTicks::Now() - request_start_time_); |
227 callback_.Run(response_status, response_proto); | 248 callback_.Run(response_status, response_proto); |
228 } | 249 } |
229 | 250 |
230 } // namespace gcm | 251 } // namespace gcm |
OLD | NEW |