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

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

Issue 1142873004: ServiceWorker: DeleteAndStartOver should delete the DiskCache on the disk cache thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 callback.Run(DatabaseStatusToStatusCode(status)); 1787 callback.Run(DatabaseStatusToStatusCode(status));
1788 return; 1788 return;
1789 } 1789 }
1790 DVLOG(1) << "Deleted ServiceWorkerDatabase successfully."; 1790 DVLOG(1) << "Deleted ServiceWorkerDatabase successfully.";
1791 1791
1792 // Delete the disk cache on the cache thread. 1792 // Delete the disk cache on the cache thread.
1793 // TODO(nhiroki): What if there is a bunch of files in the cache directory? 1793 // TODO(nhiroki): What if there is a bunch of files in the cache directory?
1794 // Deleting the directory could take a long time and restart could be delayed. 1794 // Deleting the directory could take a long time and restart could be delayed.
1795 // We should probably rename the directory and delete it later. 1795 // We should probably rename the directory and delete it later.
1796 PostTaskAndReplyWithResult( 1796 PostTaskAndReplyWithResult(
1797 database_task_manager_->GetTaskRunner(), 1797 disk_cache_thread_.get(), FROM_HERE,
1798 FROM_HERE,
1799 base::Bind(&base::DeleteFile, GetDiskCachePath(), true), 1798 base::Bind(&base::DeleteFile, GetDiskCachePath(), true),
1800 base::Bind(&ServiceWorkerStorage::DidDeleteDiskCache, 1799 base::Bind(&ServiceWorkerStorage::DidDeleteDiskCache,
1801 weak_factory_.GetWeakPtr(), 1800 weak_factory_.GetWeakPtr(), callback));
1802 callback));
1803 } 1801 }
1804 1802
1805 void ServiceWorkerStorage::DidDeleteDiskCache( 1803 void ServiceWorkerStorage::DidDeleteDiskCache(
1806 const StatusCallback& callback, bool result) { 1804 const StatusCallback& callback, bool result) {
1807 DCHECK_EQ(DISABLED, state_); 1805 DCHECK_EQ(DISABLED, state_);
1808 if (!result) { 1806 if (!result) {
1809 // Give up the corruption recovery until the browser restarts. 1807 // Give up the corruption recovery until the browser restarts.
1810 LOG(ERROR) << "Failed to delete the diskcache."; 1808 LOG(ERROR) << "Failed to delete the diskcache.";
1811 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1809 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1812 ServiceWorkerMetrics::DELETE_DISK_CACHE_ERROR); 1810 ServiceWorkerMetrics::DELETE_DISK_CACHE_ERROR);
1813 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1811 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1814 return; 1812 return;
1815 } 1813 }
1816 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1814 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1817 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1815 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1818 ServiceWorkerMetrics::DELETE_OK); 1816 ServiceWorkerMetrics::DELETE_OK);
1819 callback.Run(SERVICE_WORKER_OK); 1817 callback.Run(SERVICE_WORKER_OK);
1820 } 1818 }
1821 1819
1822 } // namespace content 1820 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698