| 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.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/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/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
| 15 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
| 16 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
| 17 | 18 |
| 18 namespace gcm { | 19 namespace gcm { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ++iter) { | 140 ++iter) { |
| 140 request.add_account_cookie(iter->first); | 141 request.add_account_cookie(iter->first); |
| 141 request.add_account_cookie(iter->second); | 142 request.add_account_cookie(iter->second); |
| 142 } | 143 } |
| 143 | 144 |
| 144 std::string upload_data; | 145 std::string upload_data; |
| 145 CHECK(request.SerializeToString(&upload_data)); | 146 CHECK(request.SerializeToString(&upload_data)); |
| 146 | 147 |
| 147 url_fetcher_ = | 148 url_fetcher_ = |
| 148 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this); | 149 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this); |
| 150 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 151 url_fetcher_.get(), data_use_measurement::DataUseUserData::GOOGLE_APIS); |
| 149 url_fetcher_->SetRequestContext(request_context_getter_); | 152 url_fetcher_->SetRequestContext(request_context_getter_); |
| 150 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 153 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
| 151 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 154 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 152 net::LOAD_DO_NOT_SAVE_COOKIES); | 155 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 153 recorder_->RecordCheckinInitiated(request_info_.android_id); | 156 recorder_->RecordCheckinInitiated(request_info_.android_id); |
| 154 request_start_time_ = base::TimeTicks::Now(); | 157 request_start_time_ = base::TimeTicks::Now(); |
| 155 url_fetcher_->Start(); | 158 url_fetcher_->Start(); |
| 156 } | 159 } |
| 157 | 160 |
| 158 void CheckinRequest::RetryWithBackoff() { | 161 void CheckinRequest::RetryWithBackoff() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 223 |
| 221 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); | 224 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); |
| 222 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", | 225 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", |
| 223 backoff_entry_.failure_count()); | 226 backoff_entry_.failure_count()); |
| 224 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", | 227 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", |
| 225 base::TimeTicks::Now() - request_start_time_); | 228 base::TimeTicks::Now() - request_start_time_); |
| 226 callback_.Run(response_proto); | 229 callback_.Run(response_proto); |
| 227 } | 230 } |
| 228 | 231 |
| 229 } // namespace gcm | 232 } // namespace gcm |
| OLD | NEW |