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

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: update histograms.xml Created 5 years, 7 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 ffd5526db2bacc740b02337449ad71f26dcd5dba..7d927d291a9c688edb5d3a81789e62f134bf7a60 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"
@@ -13,6 +15,26 @@
namespace content {
+namespace {
+
+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
// DiskCache. This is owned by ServiceWorkerDiskCacheMigrator.
class ServiceWorkerDiskCacheMigrator::Task {
@@ -229,6 +251,7 @@ ServiceWorkerDiskCacheMigrator::~ServiceWorkerDiskCacheMigrator() {
void ServiceWorkerDiskCacheMigrator::Start(const StatusCallback& callback) {
callback_ = callback;
iterator_ = src_->disk_cache()->CreateIterator();
+ start_time_ = base::TimeTicks::Now();
ContinueMigratingResources();
}
@@ -305,6 +328,8 @@ void ServiceWorkerDiskCacheMigrator::OnResourceMigrated(
return;
}
+ ++number_of_migrated_resources_;
+
if (pending_task_) {
RunPendingTask();
ContinueMigratingResources();
@@ -319,7 +344,11 @@ void ServiceWorkerDiskCacheMigrator::OnResourceMigrated(
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