| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |