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

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

Issue 1167753002: Add more UMAs for Instance ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 5 years, 6 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/gcm_store_impl.h" 5 #include "google_apis/gcm/engine/gcm_store_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/profiler/scoped_tracker.h" 14 #include "base/profiler/scoped_tracker.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/strings/string_tokenizer.h" 19 #include "base/strings/string_tokenizer.h"
20 #include "base/strings/string_util.h"
20 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "base/tracked_objects.h" 23 #include "base/tracked_objects.h"
23 #include "google_apis/gcm/base/encryptor.h" 24 #include "google_apis/gcm/base/encryptor.h"
24 #include "google_apis/gcm/base/mcs_message.h" 25 #include "google_apis/gcm/base/mcs_message.h"
25 #include "google_apis/gcm/base/mcs_util.h" 26 #include "google_apis/gcm/base/mcs_util.h"
26 #include "google_apis/gcm/protocol/mcs.pb.h" 27 #include "google_apis/gcm/protocol/mcs.pb.h"
27 #include "third_party/leveldatabase/env_chromium.h" 28 #include "third_party/leveldatabase/env_chromium.h"
28 #include "third_party/leveldatabase/src/include/leveldb/db.h" 29 #include "third_party/leveldatabase/src/include/leveldb/db.h"
29 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 30 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 LoadStatus load_status = OpenStoreAndLoadData(result.get()); 330 LoadStatus load_status = OpenStoreAndLoadData(result.get());
330 UMA_HISTOGRAM_ENUMERATION("GCM.LoadStatus", load_status, LOAD_STATUS_COUNT); 331 UMA_HISTOGRAM_ENUMERATION("GCM.LoadStatus", load_status, LOAD_STATUS_COUNT);
331 if (load_status != LOADING_SUCCEEDED) { 332 if (load_status != LOADING_SUCCEEDED) {
332 result->Reset(); 333 result->Reset();
333 foreground_task_runner_->PostTask(FROM_HERE, 334 foreground_task_runner_->PostTask(FROM_HERE,
334 base::Bind(callback, 335 base::Bind(callback,
335 base::Passed(&result))); 336 base::Passed(&result)));
336 return; 337 return;
337 } 338 }
338 339
340 // |result->registrations| contains both GCM registrations and InstanceID
341 // tokens. Count them separately.
342 int gcm_registration_count = 0;
343 int instance_id_token_count = 0;
344 for (auto iter = result->registrations.begin();
345 iter != result->registrations.end();
346 ++iter) {
Alexei Svitkine (slow) 2015/06/04 18:59:32 Nit: Use C++ for loop: for (const auto& entry : r
jianli 2015/06/04 20:50:21 Done.
347 if (StartsWithASCII(iter->first, "iid-", true))
348 instance_id_token_count++;
349 else
350 gcm_registration_count++;
351 }
352
339 // Only record histograms if GCM had already been set up for this device. 353 // Only record histograms if GCM had already been set up for this device.
340 if (result->device_android_id != 0 && result->device_security_token != 0) { 354 if (result->device_android_id != 0 && result->device_security_token != 0) {
341 int64 file_size = 0; 355 int64 file_size = 0;
342 if (base::GetFileSize(path_, &file_size)) { 356 if (base::GetFileSize(path_, &file_size)) {
343 UMA_HISTOGRAM_COUNTS("GCM.StoreSizeKB", 357 UMA_HISTOGRAM_COUNTS("GCM.StoreSizeKB",
344 static_cast<int>(file_size / 1024)); 358 static_cast<int>(file_size / 1024));
345 } 359 }
346 UMA_HISTOGRAM_COUNTS("GCM.RestoredRegistrations", 360
347 result->registrations.size()); 361 UMA_HISTOGRAM_COUNTS("GCM.RestoredRegistrations", gcm_registration_count);
348 UMA_HISTOGRAM_COUNTS("GCM.RestoredOutgoingMessages", 362 UMA_HISTOGRAM_COUNTS("GCM.RestoredOutgoingMessages",
349 result->outgoing_messages.size()); 363 result->outgoing_messages.size());
350 UMA_HISTOGRAM_COUNTS("GCM.RestoredIncomingMessages", 364 UMA_HISTOGRAM_COUNTS("GCM.RestoredIncomingMessages",
351 result->incoming_messages.size()); 365 result->incoming_messages.size());
366
367 UMA_HISTOGRAM_COUNTS("InstanceID.RestoredTokens", instance_id_token_count);
368 UMA_HISTOGRAM_COUNTS("InstanceID.RestoredIDs",
369 result->instance_id_data.size());
352 } 370 }
353 371
354 DVLOG(1) << "Succeeded in loading " << result->registrations.size() 372 DVLOG(1) << "Succeeded in loading "
355 << " registrations, " 373 << gcm_registration_count << " GCM registrations, "
356 << result->incoming_messages.size() 374 << result->incoming_messages.size()
357 << " unacknowledged incoming messages and " 375 << " unacknowledged incoming messages "
358 << result->outgoing_messages.size() 376 << result->outgoing_messages.size()
359 << " unacknowledged outgoing messages."; 377 << " unacknowledged outgoing messages, "
378 << result->instance_id_data.size() << " Instance IDs, "
379 << instance_id_token_count << " InstanceID tokens.";
360 result->success = true; 380 result->success = true;
361 foreground_task_runner_->PostTask(FROM_HERE, 381 foreground_task_runner_->PostTask(FROM_HERE,
362 base::Bind(callback, 382 base::Bind(callback,
363 base::Passed(&result))); 383 base::Passed(&result)));
364 return; 384 return;
365 } 385 }
366 386
367 void GCMStoreImpl::Backend::Close() { 387 void GCMStoreImpl::Backend::Close() {
368 DVLOG(1) << "Closing GCM store."; 388 DVLOG(1) << "Closing GCM store.";
369 db_.reset(); 389 db_.reset();
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 removed_message_counts.begin(); 1458 removed_message_counts.begin();
1439 iter != removed_message_counts.end(); ++iter) { 1459 iter != removed_message_counts.end(); ++iter) {
1440 DCHECK_NE(app_message_counts_.count(iter->first), 0U); 1460 DCHECK_NE(app_message_counts_.count(iter->first), 0U);
1441 app_message_counts_[iter->first] -= iter->second; 1461 app_message_counts_[iter->first] -= iter->second;
1442 DCHECK_GE(app_message_counts_[iter->first], 0); 1462 DCHECK_GE(app_message_counts_[iter->first], 0);
1443 } 1463 }
1444 callback.Run(true); 1464 callback.Run(true);
1445 } 1465 }
1446 1466
1447 } // namespace gcm 1467 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698