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

Side by Side Diff: components/offline_pages/archive_manager.cc

Issue 2006923005: [Offline Pages] Two-step expiration in storage manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 void DeleteArchivesImpl(const std::vector<base::FilePath>& file_paths, 35 void DeleteArchivesImpl(const std::vector<base::FilePath>& file_paths,
36 scoped_refptr<base::SequencedTaskRunner> task_runner, 36 scoped_refptr<base::SequencedTaskRunner> task_runner,
37 const base::Callback<void(bool)>& callback) { 37 const base::Callback<void(bool)>& callback) {
38 bool result = false; 38 bool result = false;
39 for (const auto& file_path : file_paths) { 39 for (const auto& file_path : file_paths) {
40 // Make sure delete happens on the left of || so that it is always executed. 40 // Make sure delete happens on the left of || so that it is always executed.
41 result = base::DeleteFile(file_path, false) || result; 41 result = base::DeleteFile(file_path, false) || result;
42 } 42 }
43 if (file_paths.size() == 0)
44 result = true;
43 task_runner->PostTask(FROM_HERE, base::Bind(callback, result)); 45 task_runner->PostTask(FROM_HERE, base::Bind(callback, result));
44 } 46 }
45 47
46 void GetAllArchivesImpl( 48 void GetAllArchivesImpl(
47 const base::FilePath& archive_dir, 49 const base::FilePath& archive_dir,
48 scoped_refptr<base::SequencedTaskRunner> task_runner, 50 scoped_refptr<base::SequencedTaskRunner> task_runner,
49 const base::Callback<void(const std::set<base::FilePath>&)>& callback) { 51 const base::Callback<void(const std::set<base::FilePath>&)>& callback) {
50 std::set<base::FilePath> archive_paths; 52 std::set<base::FilePath> archive_paths;
51 base::FileEnumerator file_enumerator(archive_dir, false, 53 base::FileEnumerator file_enumerator(archive_dir, false,
52 base::FileEnumerator::FILES); 54 base::FileEnumerator::FILES);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 117 }
116 118
117 void ArchiveManager::GetStorageStats( 119 void ArchiveManager::GetStorageStats(
118 const StorageStatsCallback& callback) const { 120 const StorageStatsCallback& callback) const {
119 task_runner_->PostTask( 121 task_runner_->PostTask(
120 FROM_HERE, base::Bind(GetStorageStatsImpl, archives_dir_, 122 FROM_HERE, base::Bind(GetStorageStatsImpl, archives_dir_,
121 base::ThreadTaskRunnerHandle::Get(), callback)); 123 base::ThreadTaskRunnerHandle::Get(), callback));
122 } 124 }
123 125
124 } // namespace offline_pages 126 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698