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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 10 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 will_retry); | 74 will_retry); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 CheckinRequest::RequestInfo::RequestInfo( | 80 CheckinRequest::RequestInfo::RequestInfo( |
81 uint64 android_id, | 81 uint64 android_id, |
82 uint64 security_token, | 82 uint64 security_token, |
83 const std::string& settings_digest, | 83 const std::string& settings_digest, |
84 const std::vector<std::string>& account_ids, | |
85 const checkin_proto::ChromeBuildProto& chrome_build_proto) | 84 const checkin_proto::ChromeBuildProto& chrome_build_proto) |
86 : android_id(android_id), | 85 : android_id(android_id), |
87 security_token(security_token), | 86 security_token(security_token), |
88 settings_digest(settings_digest), | 87 settings_digest(settings_digest), |
89 account_ids(account_ids), | |
90 chrome_build_proto(chrome_build_proto) { | 88 chrome_build_proto(chrome_build_proto) { |
91 } | 89 } |
92 | 90 |
93 CheckinRequest::RequestInfo::~RequestInfo() {} | 91 CheckinRequest::RequestInfo::~RequestInfo() {} |
94 | 92 |
95 CheckinRequest::CheckinRequest( | 93 CheckinRequest::CheckinRequest( |
96 const GURL& checkin_url, | 94 const GURL& checkin_url, |
97 const RequestInfo& request_info, | 95 const RequestInfo& request_info, |
98 const net::BackoffEntry::Policy& backoff_policy, | 96 const net::BackoffEntry::Policy& backoff_policy, |
99 const CheckinRequestCallback& callback, | 97 const CheckinRequestCallback& callback, |
(...skipping 22 matching lines...) Expand all Loading... |
122 request.set_digest(request_info_.settings_digest); | 120 request.set_digest(request_info_.settings_digest); |
123 | 121 |
124 checkin_proto::AndroidCheckinProto* checkin = request.mutable_checkin(); | 122 checkin_proto::AndroidCheckinProto* checkin = request.mutable_checkin(); |
125 checkin->mutable_chrome_build()->CopyFrom(request_info_.chrome_build_proto); | 123 checkin->mutable_chrome_build()->CopyFrom(request_info_.chrome_build_proto); |
126 #if defined(CHROME_OS) | 124 #if defined(CHROME_OS) |
127 checkin->set_type(checkin_proto::DEVICE_CHROME_OS); | 125 checkin->set_type(checkin_proto::DEVICE_CHROME_OS); |
128 #else | 126 #else |
129 checkin->set_type(checkin_proto::DEVICE_CHROME_BROWSER); | 127 checkin->set_type(checkin_proto::DEVICE_CHROME_BROWSER); |
130 #endif | 128 #endif |
131 | 129 |
132 for (std::vector<std::string>::const_iterator iter = | |
133 request_info_.account_ids.begin(); | |
134 iter != request_info_.account_ids.end(); | |
135 ++iter) { | |
136 request.add_account_cookie("[" + *iter + "]"); | |
137 } | |
138 | |
139 std::string upload_data; | 130 std::string upload_data; |
140 CHECK(request.SerializeToString(&upload_data)); | 131 CHECK(request.SerializeToString(&upload_data)); |
141 | 132 |
142 url_fetcher_.reset( | 133 url_fetcher_.reset( |
143 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this)); | 134 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this)); |
144 url_fetcher_->SetRequestContext(request_context_getter_); | 135 url_fetcher_->SetRequestContext(request_context_getter_); |
145 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 136 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
146 recorder_->RecordCheckinInitiated(request_info_.android_id); | 137 recorder_->RecordCheckinInitiated(request_info_.android_id); |
147 request_start_time_ = base::TimeTicks::Now(); | 138 request_start_time_ = base::TimeTicks::Now(); |
148 url_fetcher_->Start(); | 139 url_fetcher_->Start(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 212 |
222 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); | 213 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); |
223 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", | 214 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", |
224 backoff_entry_.failure_count()); | 215 backoff_entry_.failure_count()); |
225 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", | 216 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", |
226 base::TimeTicks::Now() - request_start_time_); | 217 base::TimeTicks::Now() - request_start_time_); |
227 callback_.Run(response_proto); | 218 callback_.Run(response_proto); |
228 } | 219 } |
229 | 220 |
230 } // namespace gcm | 221 } // namespace gcm |
OLD | NEW |