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

Side by Side Diff: content/browser/service_worker/service_worker_storage.cc

Issue 1030703003: ServiceWorker: Add UMA for storage recovery operation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_storage.h" 5 #include "content/browser/service_worker/service_worker_storage.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 } 1749 }
1750 1750
1751 void ServiceWorkerStorage::DidDeleteDatabase( 1751 void ServiceWorkerStorage::DidDeleteDatabase(
1752 const StatusCallback& callback, 1752 const StatusCallback& callback,
1753 ServiceWorkerDatabase::Status status) { 1753 ServiceWorkerDatabase::Status status) {
1754 DCHECK_EQ(DISABLED, state_); 1754 DCHECK_EQ(DISABLED, state_);
1755 if (status != ServiceWorkerDatabase::STATUS_OK) { 1755 if (status != ServiceWorkerDatabase::STATUS_OK) {
1756 // Give up the corruption recovery until the browser restarts. 1756 // Give up the corruption recovery until the browser restarts.
1757 LOG(ERROR) << "Failed to delete the database: " 1757 LOG(ERROR) << "Failed to delete the database: "
1758 << ServiceWorkerDatabase::StatusToString(status); 1758 << ServiceWorkerDatabase::StatusToString(status);
1759 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1760 ServiceWorkerMetrics::DELETE_DATABASE_ERROR);
1759 callback.Run(DatabaseStatusToStatusCode(status)); 1761 callback.Run(DatabaseStatusToStatusCode(status));
1760 return; 1762 return;
1761 } 1763 }
1762 DVLOG(1) << "Deleted ServiceWorkerDatabase successfully."; 1764 DVLOG(1) << "Deleted ServiceWorkerDatabase successfully.";
1763 1765
1764 // Delete the disk cache on the cache thread. 1766 // Delete the disk cache on the cache thread.
1765 // TODO(nhiroki): What if there is a bunch of files in the cache directory? 1767 // TODO(nhiroki): What if there is a bunch of files in the cache directory?
1766 // Deleting the directory could take a long time and restart could be delayed. 1768 // Deleting the directory could take a long time and restart could be delayed.
1767 // We should probably rename the directory and delete it later. 1769 // We should probably rename the directory and delete it later.
1768 PostTaskAndReplyWithResult( 1770 PostTaskAndReplyWithResult(
1769 database_task_manager_->GetTaskRunner(), 1771 database_task_manager_->GetTaskRunner(),
1770 FROM_HERE, 1772 FROM_HERE,
1771 base::Bind(&base::DeleteFile, GetDiskCachePath(), true), 1773 base::Bind(&base::DeleteFile, GetDiskCachePath(), true),
1772 base::Bind(&ServiceWorkerStorage::DidDeleteDiskCache, 1774 base::Bind(&ServiceWorkerStorage::DidDeleteDiskCache,
1773 weak_factory_.GetWeakPtr(), 1775 weak_factory_.GetWeakPtr(),
1774 callback)); 1776 callback));
1775 } 1777 }
1776 1778
1777 void ServiceWorkerStorage::DidDeleteDiskCache( 1779 void ServiceWorkerStorage::DidDeleteDiskCache(
1778 const StatusCallback& callback, bool result) { 1780 const StatusCallback& callback, bool result) {
1779 DCHECK_EQ(DISABLED, state_); 1781 DCHECK_EQ(DISABLED, state_);
1780 if (!result) { 1782 if (!result) {
1781 // Give up the corruption recovery until the browser restarts. 1783 // Give up the corruption recovery until the browser restarts.
1782 LOG(ERROR) << "Failed to delete the diskcache."; 1784 LOG(ERROR) << "Failed to delete the diskcache.";
1785 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1786 ServiceWorkerMetrics::DELETE_DISK_CACHE_ERROR);
1783 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1787 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1784 return; 1788 return;
1785 } 1789 }
1786 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1790 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1791 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1792 ServiceWorkerMetrics::DELETE_OK);
1787 callback.Run(SERVICE_WORKER_OK); 1793 callback.Run(SERVICE_WORKER_OK);
1788 } 1794 }
1789 1795
1790 } // namespace content 1796 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698