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

Unified Diff: content/browser/service_worker/service_worker_disk_cache_migrator.cc

Issue 1152543002: ServiceWorker: Migrate the script cache backend from BlockFile to Simple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporate falken@'s comments 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 side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698