| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/android/offline_pages/recent_tab_helper.h" | 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 pages_queue.pop(); | 145 pages_queue.pop(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 page_model_->DeletePagesByOfflineId( | 148 page_model_->DeletePagesByOfflineId( |
| 149 pages_to_purge, base::Bind(&RecentTabHelper::ContinueSnapshotAfterPurge, | 149 pages_to_purge, base::Bind(&RecentTabHelper::ContinueSnapshotAfterPurge, |
| 150 weak_ptr_factory_.GetWeakPtr())); | 150 weak_ptr_factory_.GetWeakPtr())); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void RecentTabHelper::ContinueSnapshotAfterPurge( | 153 void RecentTabHelper::ContinueSnapshotAfterPurge( |
| 154 OfflinePageModel::DeletePageResult result) { | 154 OfflinePageModel::DeletePageResult result) { |
| 155 // NOT_FOUND is because it's what we get when passing empty vector of ids. | 155 if (result != OfflinePageModel::DeletePageResult::SUCCESS) { |
| 156 // TODO(dimich): remove NOT_FOUND when bug 608057 is fixed. | |
| 157 if (result != OfflinePageModel::DeletePageResult::SUCCESS && | |
| 158 result != OfflinePageModel::DeletePageResult::NOT_FOUND) { | |
| 159 // If previous pages can't be deleted, don't add new ones. | 156 // If previous pages can't be deleted, don't add new ones. |
| 160 ReportSnapshotCompleted(); | 157 ReportSnapshotCompleted(); |
| 161 return; | 158 return; |
| 162 } | 159 } |
| 163 | 160 |
| 164 if (!IsSamePage()) { | 161 if (!IsSamePage()) { |
| 165 ReportSnapshotCompleted(); | 162 ReportSnapshotCompleted(); |
| 166 return; | 163 return; |
| 167 } | 164 } |
| 168 | 165 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 std::unique_ptr<TestArchiveFactory> test_archive_factory) { | 199 std::unique_ptr<TestArchiveFactory> test_archive_factory) { |
| 203 test_archive_factory_ = std::move(test_archive_factory); | 200 test_archive_factory_ = std::move(test_archive_factory); |
| 204 } | 201 } |
| 205 | 202 |
| 206 void RecentTabHelper::SetTaskRunnerForTest( | 203 void RecentTabHelper::SetTaskRunnerForTest( |
| 207 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 204 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 208 snapshot_controller_.reset(new SnapshotController(task_runner, this)); | 205 snapshot_controller_.reset(new SnapshotController(task_runner, this)); |
| 209 } | 206 } |
| 210 | 207 |
| 211 } // namespace offline_pages | 208 } // namespace offline_pages |
| OLD | NEW |