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

Side by Side Diff: chrome/browser/android/offline_pages/recent_tab_helper.cc

Issue 2023293002: OfflinePageModel cleanups - improved CanSavePage() and moved static kInvalidOfflineId to impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: synced 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 (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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // - compute the set of old 'last_n' pages that have to be purged 85 // - compute the set of old 'last_n' pages that have to be purged
86 // - delete the pages found in the previous step 86 // - delete the pages found in the previous step
87 // - snapshot the current web contents 87 // - snapshot the current web contents
88 // Along the chain, the original URL is passed and compared, to detect 88 // Along the chain, the original URL is passed and compared, to detect
89 // possible navigation and cancel snapshot in that case. 89 // possible navigation and cancel snapshot in that case.
90 void RecentTabHelper::StartSnapshot() { 90 void RecentTabHelper::StartSnapshot() {
91 if (never_do_snapshots_) 91 if (never_do_snapshots_)
92 return; 92 return;
93 93
94 GURL url = web_contents()->GetLastCommittedURL(); 94 GURL url = web_contents()->GetLastCommittedURL();
95 bool can_save = page_model_->CanSavePage(url); 95 bool can_save = OfflinePageModel::CanSaveURL(url);
96 UMA_HISTOGRAM_BOOLEAN("OfflinePages.CanSaveRecentPage", can_save); 96 UMA_HISTOGRAM_BOOLEAN("OfflinePages.CanSaveRecentPage", can_save);
97 if (!can_save) 97 if (!can_save)
98 return; 98 return;
99 99
100 snapshot_url_ = url; 100 snapshot_url_ = url;
101 101
102 // TODO(dimich): Implement automatic cleanup as per design doc, based on 102 // TODO(dimich): Implement automatic cleanup as per design doc, based on
103 // storage limits and page age. 103 // storage limits and page age.
104 // This algorithm (remove pages before making sure the save was successful) 104 // This algorithm (remove pages before making sure the save was successful)
105 // prefers keeping the storage use low and under control by potentially 105 // prefers keeping the storage use low and under control by potentially
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 std::unique_ptr<TestArchiveFactory> test_archive_factory) { 201 std::unique_ptr<TestArchiveFactory> test_archive_factory) {
202 test_archive_factory_ = std::move(test_archive_factory); 202 test_archive_factory_ = std::move(test_archive_factory);
203 } 203 }
204 204
205 void RecentTabHelper::SetTaskRunnerForTest( 205 void RecentTabHelper::SetTaskRunnerForTest(
206 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 206 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
207 snapshot_controller_.reset(new SnapshotController(task_runner, this)); 207 snapshot_controller_.reset(new SnapshotController(task_runner, this));
208 } 208 }
209 209
210 } // namespace offline_pages 210 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_offliner.cc ('k') | components/offline_pages/offline_page_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698