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

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

Issue 2705453003: Last_n: disable on Svelte devices. (Closed)
Patch Set: Created 3 years, 10 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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/sys_info.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" 19 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h"
19 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 20 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
20 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 21 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
21 #include "chrome/browser/android/offline_pages/offline_page_utils.h" 22 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
22 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 23 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
23 #include "components/offline_pages/core/background/request_coordinator.h" 24 #include "components/offline_pages/core/background/request_coordinator.h"
24 #include "components/offline_pages/core/client_namespace_constants.h" 25 #include "components/offline_pages/core/client_namespace_constants.h"
25 #include "components/offline_pages/core/offline_page_feature.h" 26 #include "components/offline_pages/core/offline_page_feature.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 // Expected snapshot quality should the saving succeed. This value is only 82 // Expected snapshot quality should the saving succeed. This value is only
82 // valid for successfully saved snapshots. 83 // valid for successfully saved snapshots.
83 SnapshotController::PageQuality expected_page_quality = 84 SnapshotController::PageQuality expected_page_quality =
84 SnapshotController::PageQuality::POOR; 85 SnapshotController::PageQuality::POOR;
85 }; 86 };
86 87
87 RecentTabHelper::RecentTabHelper(content::WebContents* web_contents) 88 RecentTabHelper::RecentTabHelper(content::WebContents* web_contents)
88 : content::WebContentsObserver(web_contents), 89 : content::WebContentsObserver(web_contents),
89 delegate_(new DefaultDelegate()), 90 delegate_(new DefaultDelegate()),
91 is_low_end_device_(base::SysInfo::IsLowEndDevice()),
90 weak_ptr_factory_(this) { 92 weak_ptr_factory_(this) {
91 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
92 } 94 }
93 95
94 RecentTabHelper::~RecentTabHelper() { 96 RecentTabHelper::~RecentTabHelper() {
95 } 97 }
96 98
97 void RecentTabHelper::SetDelegate( 99 void RecentTabHelper::SetDelegate(
98 std::unique_ptr<RecentTabHelper::Delegate> delegate) { 100 std::unique_ptr<RecentTabHelper::Delegate> delegate) {
99 DCHECK(delegate); 101 DCHECK(delegate);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Check for conditions that would cause us not to snapshot. 207 // Check for conditions that would cause us not to snapshot.
206 bool can_save = !navigation_handle->IsErrorPage() && 208 bool can_save = !navigation_handle->IsErrorPage() &&
207 OfflinePageModel::CanSaveURL(snapshot_url_) && 209 OfflinePageModel::CanSaveURL(snapshot_url_) &&
208 OfflinePageUtils::GetOfflinePageFromWebContents( 210 OfflinePageUtils::GetOfflinePageFromWebContents(
209 web_contents()) == nullptr; 211 web_contents()) == nullptr;
210 212
211 UMA_HISTOGRAM_BOOLEAN("OfflinePages.CanSaveRecentPage", can_save); 213 UMA_HISTOGRAM_BOOLEAN("OfflinePages.CanSaveRecentPage", can_save);
212 214
213 if (!can_save) 215 if (!can_save)
214 snapshot_controller_->Stop(); 216 snapshot_controller_->Stop();
215 last_n_listen_to_tab_hidden_ = can_save && IsOffliningRecentPagesEnabled(); 217 last_n_listen_to_tab_hidden_ =
218 can_save && !is_low_end_device_ && IsOffliningRecentPagesEnabled();
216 last_n_latest_saved_quality_ = PageQuality::POOR; 219 last_n_latest_saved_quality_ = PageQuality::POOR;
217 } 220 }
218 221
219 void RecentTabHelper::DocumentAvailableInMainFrame() { 222 void RecentTabHelper::DocumentAvailableInMainFrame() {
220 EnsureInitialized(); 223 EnsureInitialized();
221 snapshot_controller_->DocumentAvailableInMainFrame(); 224 snapshot_controller_->DocumentAvailableInMainFrame();
222 } 225 }
223 226
224 void RecentTabHelper::DocumentOnLoadCompletedInMainFrame() { 227 void RecentTabHelper::DocumentOnLoadCompletedInMainFrame() {
225 EnsureInitialized(); 228 EnsureInitialized();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 427 }
425 428
426 void RecentTabHelper::CancelInFlightSnapshots() { 429 void RecentTabHelper::CancelInFlightSnapshots() {
427 weak_ptr_factory_.InvalidateWeakPtrs(); 430 weak_ptr_factory_.InvalidateWeakPtrs();
428 downloads_ongoing_snapshot_info_.reset(); 431 downloads_ongoing_snapshot_info_.reset();
429 downloads_latest_saved_snapshot_info_.reset(); 432 downloads_latest_saved_snapshot_info_.reset();
430 last_n_ongoing_snapshot_info_.reset(); 433 last_n_ongoing_snapshot_info_.reset();
431 } 434 }
432 435
433 } // namespace offline_pages 436 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698