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

Side by Side Diff: components/gcm_driver/gcm_client_impl.cc

Issue 2471433003: [GCM] Update ResetStore histograms (Closed)
Patch Set: Mark old histo as obsolete 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
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 "components/gcm_driver/gcm_client_impl.h" 5 #include "components/gcm_driver/gcm_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_DAY; 226 ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_DAY;
227 else 227 else
228 ttl_category = TTL_MAXIMUM; 228 ttl_category = TTL_MAXIMUM;
229 229
230 UMA_HISTOGRAM_ENUMERATION("GCM.OutgoingMessageTTL", 230 UMA_HISTOGRAM_ENUMERATION("GCM.OutgoingMessageTTL",
231 ttl_category, 231 ttl_category,
232 TTL_CATEGORY_COUNT); 232 TTL_CATEGORY_COUNT);
233 } 233 }
234 234
235 void RecordResetStoreErrorToUMA(ResetStoreError error) { 235 void RecordResetStoreErrorToUMA(ResetStoreError error) {
236 UMA_HISTOGRAM_ENUMERATION("GCM.ResetStore", error, RESET_STORE_ERROR_COUNT); 236 UMA_HISTOGRAM_ENUMERATION("GCM.ResetStoreError", error,
237 RESET_STORE_ERROR_COUNT);
237 } 238 }
238 239
239 } // namespace 240 } // namespace
240 241
241 GCMInternalsBuilder::GCMInternalsBuilder() {} 242 GCMInternalsBuilder::GCMInternalsBuilder() {}
242 GCMInternalsBuilder::~GCMInternalsBuilder() {} 243 GCMInternalsBuilder::~GCMInternalsBuilder() {}
243 244
244 std::unique_ptr<base::Clock> GCMInternalsBuilder::BuildClock() { 245 std::unique_ptr<base::Clock> GCMInternalsBuilder::BuildClock() {
245 return base::WrapUnique<base::Clock>(new base::DefaultClock()); 246 return base::WrapUnique<base::Clock>(new base::DefaultClock());
246 } 247 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 base::Bind(&GCMClientImpl::OnLoadCompleted, 388 base::Bind(&GCMClientImpl::OnLoadCompleted,
388 weak_ptr_factory_.GetWeakPtr())); 389 weak_ptr_factory_.GetWeakPtr()));
389 } else { 390 } else {
390 // In the case that the store does not exist, set |state_| back to 391 // In the case that the store does not exist, set |state_| back to
391 // INITIALIZED such that store loading could be triggered again when 392 // INITIALIZED such that store loading could be triggered again when
392 // Start() is called with IMMEDIATE_START. 393 // Start() is called with IMMEDIATE_START.
393 state_ = INITIALIZED; 394 state_ = INITIALIZED;
394 } 395 }
395 } else { 396 } else {
396 // Otherwise, destroy the store to try again. 397 // Otherwise, destroy the store to try again.
397 ResetStore(); 398 ResetStore(LOAD_FAILURE);
398 } 399 }
399 return; 400 return;
400 } 401 }
401 gcm_store_reset_ = false; 402 gcm_store_reset_ = false;
402 403
403 device_checkin_info_.android_id = result->device_android_id; 404 device_checkin_info_.android_id = result->device_android_id;
404 device_checkin_info_.secret = result->device_security_token; 405 device_checkin_info_.secret = result->device_security_token;
405 device_checkin_info_.last_checkin_accounts = result->last_checkin_accounts; 406 device_checkin_info_.last_checkin_accounts = result->last_checkin_accounts;
406 // A case where there were previously no accounts reported with checkin is 407 // A case where there were previously no accounts reported with checkin is
407 // considered to be the same as when the list of accounts is empty. It enables 408 // considered to be the same as when the list of accounts is empty. It enables
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 537 }
537 538
538 void GCMClientImpl::DestroyStoreWhenNotNeeded() { 539 void GCMClientImpl::DestroyStoreWhenNotNeeded() {
539 if (state_ != LOADED || start_mode_ != DELAYED_START) 540 if (state_ != LOADED || start_mode_ != DELAYED_START)
540 return; 541 return;
541 542
542 gcm_store_->Destroy(base::Bind(&GCMClientImpl::DestroyStoreCallback, 543 gcm_store_->Destroy(base::Bind(&GCMClientImpl::DestroyStoreCallback,
543 weak_ptr_factory_.GetWeakPtr())); 544 weak_ptr_factory_.GetWeakPtr()));
544 } 545 }
545 546
546 void GCMClientImpl::ResetStore() { 547 void GCMClientImpl::ResetStore(ResetReason reset_reason) {
547 // If already being reset, don't do it again. We want to prevent from 548 // If already being reset, don't do it again. We want to prevent from
548 // resetting and loading from the store again and again. 549 // resetting and loading from the store again and again.
549 if (gcm_store_reset_) { 550 if (gcm_store_reset_) {
550 RecordResetStoreErrorToUMA(INFINITE_STORE_RESET); 551 RecordResetStoreErrorToUMA(INFINITE_STORE_RESET);
551 state_ = UNINITIALIZED; 552 state_ = UNINITIALIZED;
552 return; 553 return;
553 } 554 }
554 gcm_store_reset_ = true; 555 gcm_store_reset_ = true;
556 UMA_HISTOGRAM_ENUMERATION("GCM.ResetStoreReason", reset_reason,
557 RESET_REASON_COUNT);
555 558
556 // Destroy the GCM store to start over. 559 // Destroy the GCM store to start over.
557 gcm_store_->Destroy(base::Bind(&GCMClientImpl::ResetStoreCallback, 560 gcm_store_->Destroy(base::Bind(&GCMClientImpl::ResetStoreCallback,
558 weak_ptr_factory_.GetWeakPtr())); 561 weak_ptr_factory_.GetWeakPtr()));
559 } 562 }
560 563
561 void GCMClientImpl::SetAccountTokens( 564 void GCMClientImpl::SetAccountTokens(
562 const std::vector<AccountTokenInfo>& account_tokens) { 565 const std::vector<AccountTokenInfo>& account_tokens) {
563 device_checkin_info_.account_tokens.clear(); 566 device_checkin_info_.account_tokens.clear();
564 for (std::vector<AccountTokenInfo>::const_iterator iter = 567 for (std::vector<AccountTokenInfo>::const_iterator iter =
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 702 }
700 703
701 void GCMClientImpl::OnCheckinCompleted( 704 void GCMClientImpl::OnCheckinCompleted(
702 net::HttpStatusCode response_code, 705 net::HttpStatusCode response_code,
703 const checkin_proto::AndroidCheckinResponse& checkin_response) { 706 const checkin_proto::AndroidCheckinResponse& checkin_response) {
704 checkin_request_.reset(); 707 checkin_request_.reset();
705 708
706 if (response_code == net::HTTP_UNAUTHORIZED || 709 if (response_code == net::HTTP_UNAUTHORIZED ||
707 response_code == net::HTTP_BAD_REQUEST) { 710 response_code == net::HTTP_BAD_REQUEST) {
708 LOG(ERROR) << "Checkin rejected. Resetting GCM Store."; 711 LOG(ERROR) << "Checkin rejected. Resetting GCM Store.";
709 ResetStore(); 712 ResetStore(CHECKIN_REJECTED);
710 return; 713 return;
711 } 714 }
712 715
713 DCHECK(checkin_response.has_android_id()); 716 DCHECK(checkin_response.has_android_id());
714 DCHECK(checkin_response.has_security_token()); 717 DCHECK(checkin_response.has_security_token());
715 CheckinInfo checkin_info; 718 CheckinInfo checkin_info;
716 checkin_info.android_id = checkin_response.android_id(); 719 checkin_info.android_id = checkin_response.android_id();
717 checkin_info.secret = checkin_response.security_token(); 720 checkin_info.secret = checkin_response.security_token();
718 721
719 if (state_ == INITIAL_DEVICE_CHECKIN) { 722 if (state_ == INITIAL_DEVICE_CHECKIN) {
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 bool GCMClientImpl::HasStandaloneRegisteredApp() const { 1436 bool GCMClientImpl::HasStandaloneRegisteredApp() const {
1434 if (registrations_.empty()) 1437 if (registrations_.empty())
1435 return false; 1438 return false;
1436 // Note that account mapper is not counted as a standalone app since it is 1439 // Note that account mapper is not counted as a standalone app since it is
1437 // automatically started when other app uses GCM. 1440 // automatically started when other app uses GCM.
1438 return registrations_.size() > 1 || 1441 return registrations_.size() > 1 ||
1439 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId); 1442 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId);
1440 } 1443 }
1441 1444
1442 } // namespace gcm 1445 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698