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

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

Issue 158023007: Add GCM check in status code metric collection. We also decided to collect registration success sig… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 10 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
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/registration_request.h" 5 #include "google_apis/gcm/engine/registration_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 "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 << source->GetResponseCode(); 196 << source->GetResponseCode();
197 RetryWithBackoff(true); 197 RetryWithBackoff(true);
198 return; 198 return;
199 } 199 }
200 200
201 DVLOG(1) << "Parsing registration response: " << response; 201 DVLOG(1) << "Parsing registration response: " << response;
202 size_t token_pos = response.find(kTokenPrefix); 202 size_t token_pos = response.find(kTokenPrefix);
203 if (token_pos != std::string::npos) { 203 if (token_pos != std::string::npos) {
204 std::string token = 204 std::string token =
205 response.substr(token_pos + arraysize(kTokenPrefix) - 1); 205 response.substr(token_pos + arraysize(kTokenPrefix) - 1);
206 UMA_HISTOGRAM_ENUMERATION("GCM.RegistrationRequestStatus", SUCCESS,
jianli 2014/02/12 18:41:05 nit: define a helper function as you did in Checki
juyik 2014/02/12 18:55:20 Done.
207 RegistrationRequest::STATUS_COUNT);
206 callback_.Run(SUCCESS, token); 208 callback_.Run(SUCCESS, token);
207 return; 209 return;
208 } 210 }
209 211
210 size_t error_pos = response.find(kErrorPrefix); 212 size_t error_pos = response.find(kErrorPrefix);
211 Status status = UNKNOWN_ERROR; 213 Status status = UNKNOWN_ERROR;
212 if (error_pos != std::string::npos) { 214 if (error_pos != std::string::npos) {
213 std::string error = 215 std::string error =
214 response.substr(error_pos + arraysize(kErrorPrefix) - 1); 216 response.substr(error_pos + arraysize(kErrorPrefix) - 1);
215 status = GetStatusFromError(error); 217 status = GetStatusFromError(error);
216 } 218 }
217 UMA_HISTOGRAM_ENUMERATION("GCM.RegistrationRequestStatus", status, 219 UMA_HISTOGRAM_ENUMERATION("GCM.RegistrationRequestStatus", status,
218 RegistrationRequest::STATUS_COUNT); 220 RegistrationRequest::STATUS_COUNT);
219 221
220 if (ShouldRetryWithStatus(status)) { 222 if (ShouldRetryWithStatus(status)) {
221 RetryWithBackoff(true); 223 RetryWithBackoff(true);
222 return; 224 return;
223 } 225 }
224 226
225 callback_.Run(status, std::string()); 227 callback_.Run(status, std::string());
226 } 228 }
227 229
228 } // namespace gcm 230 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698