summaryrefslogtreecommitdiffstats
path: root/content/browser/background_sync
diff options
context:
space:
mode:
authoriclelland <iclelland@chromium.org>2015-07-22 08:40:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-22 15:40:36 +0000
commit19506ea177d6ba07d21228164fa8ef7161505b3c (patch)
tree13e521167db28c5d0cfa0c1f1748063343dd1aa1 /content/browser/background_sync
parent868100a8a0ffe3506b4adcf7b21e5e6c06fa84ce (diff)
downloadchromium_src-19506ea177d6ba07d21228164fa8ef7161505b3c.zip
chromium_src-19506ea177d6ba07d21228164fa8ef7161505b3c.tar.gz
chromium_src-19506ea177d6ba07d21228164fa8ef7161505b3c.tar.bz2
[Background Sync] Record number of batched sync events in UMA
BUG=490482 Review URL: https://codereview.chromium.org/1251523002 Cr-Commit-Position: refs/heads/master@{#339880}
Diffstat (limited to 'content/browser/background_sync')
-rw-r--r--content/browser/background_sync/background_sync_manager.cc61
-rw-r--r--content/browser/background_sync/background_sync_manager.h3
-rw-r--r--content/browser/background_sync/background_sync_metrics.cc7
-rw-r--r--content/browser/background_sync/background_sync_metrics.h6
4 files changed, 46 insertions, 31 deletions
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc
index 7903aa4..960c63f8 100644
--- a/content/browser/background_sync/background_sync_manager.cc
+++ b/content/browser/background_sync/background_sync_manager.cc
@@ -799,29 +799,37 @@ void BackgroundSyncManager::FireReadyEventsImpl(const base::Closure& callback) {
}
}
- base::TimeTicks start_time = base::TimeTicks::Now();
-
- // Fire the sync event of the ready registrations and run |callback| once
- // they're all done.
- base::Closure events_fired_barrier_closure =
- base::BarrierClosure(sw_id_and_keys_to_fire.size(), base::Bind(callback));
-
- // Record the total time taken after all events have run to completion.
- base::Closure events_completed_barrier_closure =
- base::BarrierClosure(sw_id_and_keys_to_fire.size(),
- base::Bind(&OnAllSyncEventsCompleted, start_time));
-
- for (const auto& sw_id_and_key : sw_id_and_keys_to_fire) {
- int64 service_worker_id = sw_id_and_key.first;
- const BackgroundSyncRegistration* registration =
- LookupRegistration(service_worker_id, sw_id_and_key.second);
-
- service_worker_context_->FindRegistrationForId(
- service_worker_id, sw_to_registrations_map_[service_worker_id].origin,
- base::Bind(&BackgroundSyncManager::FireReadyEventsDidFindRegistration,
- weak_ptr_factory_.GetWeakPtr(), sw_id_and_key.second,
- registration->id(), events_fired_barrier_closure,
- events_completed_barrier_closure));
+ // If there are no registrations currently ready, then just run |callback|.
+ // Otherwise, fire them all, and record the result when done.
+ if (sw_id_and_keys_to_fire.size() == 0) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ base::Bind(callback));
+ } else {
+ base::TimeTicks start_time = base::TimeTicks::Now();
+
+ // Fire the sync event of the ready registrations and run |callback| once
+ // they're all done.
+ base::Closure events_fired_barrier_closure = base::BarrierClosure(
+ sw_id_and_keys_to_fire.size(), base::Bind(callback));
+
+ // Record the total time taken after all events have run to completion.
+ base::Closure events_completed_barrier_closure =
+ base::BarrierClosure(sw_id_and_keys_to_fire.size(),
+ base::Bind(&OnAllSyncEventsCompleted, start_time,
+ sw_id_and_keys_to_fire.size()));
+
+ for (const auto& sw_id_and_key : sw_id_and_keys_to_fire) {
+ int64 service_worker_id = sw_id_and_key.first;
+ const BackgroundSyncRegistration* registration =
+ LookupRegistration(service_worker_id, sw_id_and_key.second);
+
+ service_worker_context_->FindRegistrationForId(
+ service_worker_id, sw_to_registrations_map_[service_worker_id].origin,
+ base::Bind(&BackgroundSyncManager::FireReadyEventsDidFindRegistration,
+ weak_ptr_factory_.GetWeakPtr(), sw_id_and_key.second,
+ registration->id(), events_fired_barrier_closure,
+ events_completed_barrier_closure));
+ }
}
SchedulePendingRegistrations();
@@ -948,10 +956,11 @@ void BackgroundSyncManager::EventCompleteDidStore(
// static
void BackgroundSyncManager::OnAllSyncEventsCompleted(
- const base::TimeTicks& start_time) {
+ const base::TimeTicks& start_time,
+ int number_of_batched_sync_events) {
// Record the combined time taken by all sync events.
- BackgroundSyncMetrics::RecordBatchSyncEventHandlingTime(
- base::TimeTicks::Now() - start_time);
+ BackgroundSyncMetrics::RecordBatchSyncEventComplete(
+ base::TimeTicks::Now() - start_time, number_of_batched_sync_events);
}
void BackgroundSyncManager::OnRegistrationDeletedImpl(
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h
index a235dac..ea0236f 100644
--- a/content/browser/background_sync/background_sync_manager.h
+++ b/content/browser/background_sync/background_sync_manager.h
@@ -267,7 +267,8 @@ class CONTENT_EXPORT BackgroundSyncManager
ServiceWorkerStatusCode status_code);
// Called when all sync events have completed.
- static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time);
+ static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time,
+ int number_of_batched_sync_events);
// OnRegistrationDeleted callbacks
void OnRegistrationDeletedImpl(int64 registration_id,
diff --git a/content/browser/background_sync/background_sync_metrics.cc b/content/browser/background_sync/background_sync_metrics.cc
index 97f20b2..7701798 100644
--- a/content/browser/background_sync/background_sync_metrics.cc
+++ b/content/browser/background_sync/background_sync_metrics.cc
@@ -22,13 +22,16 @@ void BackgroundSyncMetrics::RecordEventResult(SyncPeriodicity periodicity,
NOTREACHED();
}
-void BackgroundSyncMetrics::RecordBatchSyncEventHandlingTime(
- const base::TimeDelta& time) {
+void BackgroundSyncMetrics::RecordBatchSyncEventComplete(
+ const base::TimeDelta& time,
+ int number_of_batched_sync_events) {
// The total batch handling time should be under 5 minutes; we'll record up to
// 6 minutes, to be safe.
UMA_HISTOGRAM_CUSTOM_TIMES("BackgroundSync.Event.Time", time,
base::TimeDelta::FromMilliseconds(10),
base::TimeDelta::FromMinutes(6), 50);
+ UMA_HISTOGRAM_COUNTS_100("BackgroundSync.Event.BatchSize",
+ number_of_batched_sync_events);
}
void BackgroundSyncMetrics::CountRegister(
diff --git a/content/browser/background_sync/background_sync_metrics.h b/content/browser/background_sync/background_sync_metrics.h
index 5b74ed5e..290d9f9 100644
--- a/content/browser/background_sync/background_sync_metrics.h
+++ b/content/browser/background_sync/background_sync_metrics.h
@@ -31,8 +31,10 @@ class BackgroundSyncMetrics {
// Records the result of a single sync event firing.
static void RecordEventResult(SyncPeriodicity periodicity, bool result);
- // Records the time spent running a batch of sync events.
- static void RecordBatchSyncEventHandlingTime(const base::TimeDelta& time);
+ // Records the result of running a batch of sync events, including the total
+ // time spent, and the batch size.
+ static void RecordBatchSyncEventComplete(const base::TimeDelta& time,
+ int number_of_batched_sync_events);
// Records the result of trying to register a sync. |could_fire| indicates
// whether the conditions were sufficient for the sync to fire immediately at