Index: content/browser/service_worker/service_worker_disk_cache_migrator.cc |
diff --git a/content/browser/service_worker/service_worker_disk_cache_migrator.cc b/content/browser/service_worker/service_worker_disk_cache_migrator.cc |
index df67b78003abfc0ea3be3ee0108e20a0478eb8e5..1cd8b87db8ab9e1c52080878bcf2038507bc7e68 100644 |
--- a/content/browser/service_worker/service_worker_disk_cache_migrator.cc |
+++ b/content/browser/service_worker/service_worker_disk_cache_migrator.cc |
@@ -5,7 +5,9 @@ |
#include "content/browser/service_worker/service_worker_disk_cache_migrator.h" |
#include "base/memory/ref_counted.h" |
+#include "base/metrics/histogram_macros.h" |
#include "base/strings/string_number_conversions.h" |
+#include "base/time/time.h" |
#include "content/common/service_worker/service_worker_types.h" |
#include "net/base/io_buffer.h" |
#include "net/base/net_errors.h" |
@@ -18,6 +20,22 @@ namespace { |
// Disk cache entry data indices (Copied from appcache_diskcache.cc). |
enum { kResponseInfoIndex, kResponseContentIndex, kResponseMetadataIndex }; |
+void RecordMigrationResult(ServiceWorkerStatusCode status) { |
+ UMA_HISTOGRAM_ENUMERATION("ServiceWorker.DiskCacheMigrator.MigrationResult", |
+ status, SERVICE_WORKER_ERROR_MAX_VALUE); |
+} |
+ |
+void RecordNumberOfMigratedResources(size_t migrated_resources) { |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "ServiceWorker.DiskCacheMigrator.NumberOfMigratedResources", |
+ migrated_resources, 1, 1000, 50); |
+} |
+ |
+void RecordMigrationTime(const base::TimeDelta& time) { |
+ UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.DiskCacheMigrator.MigrationTime", |
+ time); |
+} |
+ |
} // namespace |
// A task to move a cached resource from the src DiskCache to the dest |
@@ -238,6 +256,7 @@ ServiceWorkerDiskCacheMigrator::~ServiceWorkerDiskCacheMigrator() { |
void ServiceWorkerDiskCacheMigrator::Start(const StatusCallback& callback) { |
callback_ = callback; |
iterator_ = src_->disk_cache()->CreateIterator(); |
+ start_time_ = base::TimeTicks::Now(); |
OpenNextEntry(); |
} |
@@ -321,6 +340,8 @@ void ServiceWorkerDiskCacheMigrator::OnEntryMigrated( |
return; |
} |
+ ++number_of_migrated_resources_; |
+ |
if (pending_task_) { |
RunPendingTask(); |
OpenNextEntry(); |
@@ -336,7 +357,11 @@ void ServiceWorkerDiskCacheMigrator::OnEntryMigrated( |
void ServiceWorkerDiskCacheMigrator::Complete(ServiceWorkerStatusCode status) { |
DCHECK(inflight_tasks_.IsEmpty()); |
- // TODO(nhiroki): Add UMA for the result of migration. |
+ if (status == SERVICE_WORKER_OK) { |
+ RecordMigrationTime(base::TimeTicks().Now() - start_time_); |
+ RecordNumberOfMigratedResources(number_of_migrated_resources_); |
+ } |
+ RecordMigrationResult(status); |
callback_.Run(status); |
} |