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

Side by Side Diff: google_apis/gcm/engine/checkin_request.cc

Issue 2486423002: Add data usage tracking for GAIA auth api and GCM engine service (Closed)
Patch Set: Fixed DEPS Created 4 years, 1 month 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 | « google_apis/gcm/DEPS ('k') | google_apis/gcm/engine/registration_request.cc » ('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 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 "components/data_use_measurement/core/data_use_user_data.h"
11 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" 12 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
12 #include "google_apis/gcm/protocol/checkin.pb.h" 13 #include "google_apis/gcm/protocol/checkin.pb.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.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";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
148 url_fetcher_ = 149 url_fetcher_ =
149 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this); 150 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this);
150 url_fetcher_->SetRequestContext(request_context_getter_); 151 url_fetcher_->SetRequestContext(request_context_getter_);
151 url_fetcher_->SetUploadData(kRequestContentType, upload_data); 152 url_fetcher_->SetUploadData(kRequestContentType, upload_data);
152 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 153 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
153 net::LOAD_DO_NOT_SAVE_COOKIES); 154 net::LOAD_DO_NOT_SAVE_COOKIES);
155 data_use_measurement::DataUseUserData::AttachToFetcher(
156 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_ENGINE);
154 recorder_->RecordCheckinInitiated(request_info_.android_id); 157 recorder_->RecordCheckinInitiated(request_info_.android_id);
155 request_start_time_ = base::TimeTicks::Now(); 158 request_start_time_ = base::TimeTicks::Now();
156 url_fetcher_->Start(); 159 url_fetcher_->Start();
157 } 160 }
158 161
159 void CheckinRequest::RetryWithBackoff() { 162 void CheckinRequest::RetryWithBackoff() {
160 backoff_entry_.InformOfRequest(false); 163 backoff_entry_.InformOfRequest(false);
161 url_fetcher_.reset(); 164 url_fetcher_.reset();
162 165
163 DVLOG(1) << "Delay GCM checkin for: " 166 DVLOG(1) << "Delay GCM checkin for: "
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 224
222 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); 225 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false);
223 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", 226 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount",
224 backoff_entry_.failure_count()); 227 backoff_entry_.failure_count());
225 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", 228 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime",
226 base::TimeTicks::Now() - request_start_time_); 229 base::TimeTicks::Now() - request_start_time_);
227 callback_.Run(response_status, response_proto); 230 callback_.Run(response_status, response_proto);
228 } 231 }
229 232
230 } // namespace gcm 233 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/DEPS ('k') | google_apis/gcm/engine/registration_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698