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

Side by Side Diff: chrome/browser/sessions/session_restore_delegate.cc

Issue 1131373003: [Session restore] Add MRU logic to loading of background pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/sessions/session_restore_delegate.h" 5 #include "chrome/browser/sessions/session_restore_delegate.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "chrome/browser/sessions/session_restore_stats_collector.h" 8 #include "chrome/browser/sessions/session_restore_stats_collector.h"
9 #include "chrome/browser/sessions/tab_loader.h" 9 #include "chrome/browser/sessions/tab_loader.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 15 matching lines...) Expand all
26 for (size_t i = 0; i < arraysize(kReloadableUrlPrefixes); ++i) { 26 for (size_t i = 0; i < arraysize(kReloadableUrlPrefixes); ++i) {
27 if (!strncmp(url.spec().c_str(), kReloadableUrlPrefixes[i], 27 if (!strncmp(url.spec().c_str(), kReloadableUrlPrefixes[i],
28 strlen(kReloadableUrlPrefixes[i]))) 28 strlen(kReloadableUrlPrefixes[i])))
29 return true; 29 return true;
30 } 30 }
31 return false; 31 return false;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 SessionRestoreDelegate::RestoredTab::RestoredTab(content::WebContents* contents, 36 SessionRestoreDelegate::RestoredTab::RestoredTab(
37 bool is_active, 37 content::WebContents* contents,
38 bool is_app, 38 bool is_active,
39 bool is_pinned) 39 bool is_app,
40 bool is_pinned,
41 base::TimeTicks last_activation_time)
40 : contents_(contents), 42 : contents_(contents),
41 is_active_(is_active), 43 is_active_(is_active),
42 is_app_(is_app), 44 is_app_(is_app),
43 is_internal_page_(IsInternalPage(contents->GetLastCommittedURL())), 45 is_internal_page_(IsInternalPage(contents->GetLastCommittedURL())),
44 is_pinned_(is_pinned) { 46 is_pinned_(is_pinned),
47 last_activation_time_(last_activation_time) {
45 } 48 }
46 49
47 bool SessionRestoreDelegate::RestoredTab::operator<( 50 bool SessionRestoreDelegate::RestoredTab::operator<(
48 const RestoredTab& right) const { 51 const RestoredTab& right) const {
49 // Tab with internal web UI like NTP or Settings are good choices to 52 // Tab with internal web UI like NTP or Settings are good choices to
50 // defer loading. 53 // defer loading.
51 if (is_internal_page_ != right.is_internal_page_) 54 if (is_internal_page_ != right.is_internal_page_)
52 return !is_internal_page_; 55 return !is_internal_page_;
53 // Pinned tabs should be loaded first. 56 // Pinned tabs should be loaded first.
54 if (is_pinned_ != right.is_pinned_) 57 if (is_pinned_ != right.is_pinned_)
55 return is_pinned_; 58 return is_pinned_;
56 // Apps should be loaded before normal tabs. 59 // Apps should be loaded before normal tabs.
57 if (is_app_ != right.is_app_) 60 if (is_app_ != right.is_app_)
58 return is_app_; 61 return is_app_;
59 // TODO(georgesak): Add criterion based on recency. 62 // Restore using MRU. Behind an experiment for now.
63 if (SessionRestore::GetSmartRestoreMode() ==
64 SessionRestore::SMART_RESTORE_MODE_MRU)
65 return last_activation_time_ > right.last_activation_time_;
60 return false; 66 return false;
61 } 67 }
62 68
63 // static 69 // static
64 void SessionRestoreDelegate::RestoreTabs( 70 void SessionRestoreDelegate::RestoreTabs(
65 const std::vector<RestoredTab>& tabs, 71 const std::vector<RestoredTab>& tabs,
66 const base::TimeTicks& restore_started) { 72 const base::TimeTicks& restore_started) {
67 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started); 73 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started);
68 TabLoader::RestoreTabs(tabs, restore_started); 74 TabLoader::RestoreTabs(tabs, restore_started);
69 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698