Renamed persistent tab restore service.
In preparation for another CL which makes persitence dependent on a policy pref.
Bug: 869580
Change-Id: I5fa64297c9c6dbddf121703686c41f1a52bae1d8
Reviewed-on: https://chromium-review.googlesource.com/c/1378229
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Marc-André Decoste <mad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616733}diff --git a/chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc b/chrome/browser/sessions/tab_restore_service_browsertest.cc
similarity index 85%
rename from chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc
rename to chrome/browser/sessions/tab_restore_service_browsertest.cc
index a3e5b394..7a8f8f6a 100644
--- a/chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc
+++ b/chrome/browser/sessions/tab_restore_service_browsertest.cc
@@ -6,7 +6,7 @@
// only Chrome OS or Ash?
#if defined(USE_AURA)
-#include "components/sessions/core/persistent_tab_restore_service.h"
+#include "components/sessions/core/tab_restore_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
@@ -15,9 +15,9 @@
using Window = sessions::TabRestoreService::Window;
-using PersistentTabRestoreServiceBrowserTest = InProcessBrowserTest;
+using TabRestoreServiceImplBrowserTest = InProcessBrowserTest;
-IN_PROC_BROWSER_TEST_F(PersistentTabRestoreServiceBrowserTest, RestoreApp) {
+IN_PROC_BROWSER_TEST_F(TabRestoreServiceImplBrowserTest, RestoreApp) {
Profile* profile = browser()->profile();
sessions::TabRestoreService* trs =
TabRestoreServiceFactory::GetForProfile(profile);
diff --git a/chrome/browser/sessions/tab_restore_service_factory.cc b/chrome/browser/sessions/tab_restore_service_factory.cc
index 4d39ed7a..75b493c 100644
--- a/chrome/browser/sessions/tab_restore_service_factory.cc
+++ b/chrome/browser/sessions/tab_restore_service_factory.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/chrome_tab_restore_service_client.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
-#include "components/sessions/core/persistent_tab_restore_service.h"
+#include "components/sessions/core/tab_restore_service_impl.h"
// static
sessions::TabRestoreService* TabRestoreServiceFactory::GetForProfile(
@@ -55,5 +55,5 @@
std::unique_ptr<sessions::TabRestoreServiceClient> client(
new ChromeTabRestoreServiceClient(profile));
- return new sessions::PersistentTabRestoreService(std::move(client), nullptr);
+ return new sessions::TabRestoreServiceImpl(std::move(client), nullptr);
}
diff --git a/chrome/browser/sessions/persistent_tab_restore_service_unittest.cc b/chrome/browser/sessions/tab_restore_service_unittest.cc
similarity index 87%
rename from chrome/browser/sessions/persistent_tab_restore_service_unittest.cc
rename to chrome/browser/sessions/tab_restore_service_unittest.cc
index 6fa475a4..7740683 100644
--- a/chrome/browser/sessions/persistent_tab_restore_service_unittest.cc
+++ b/chrome/browser/sessions/tab_restore_service_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/sessions/core/persistent_tab_restore_service.h"
+#include "components/sessions/core/tab_restore_service_impl.h"
#include <stddef.h>
@@ -52,12 +52,11 @@
// Create subclass that overrides TimeNow so that we can control the time used
// for closed tabs and windows.
-class PersistentTabRestoreTimeFactory
- : public sessions::TabRestoreService::TimeFactory {
+class TabRestoreTimeFactory : public sessions::TabRestoreService::TimeFactory {
public:
- PersistentTabRestoreTimeFactory() : time_(base::Time::Now()) {}
+ TabRestoreTimeFactory() : time_(base::Time::Now()) {}
- ~PersistentTabRestoreTimeFactory() override {}
+ ~TabRestoreTimeFactory() override {}
base::Time TimeNow() override { return time_; }
@@ -65,9 +64,9 @@
base::Time time_;
};
-class PersistentTabRestoreServiceTest : public ChromeRenderViewHostTestHarness {
+class TabRestoreServiceImplTest : public ChromeRenderViewHostTestHarness {
public:
- PersistentTabRestoreServiceTest()
+ TabRestoreServiceImplTest()
: url1_("http://1"),
url2_("http://2"),
url3_("http://3"),
@@ -78,7 +77,7 @@
window_id_(SessionID::FromSerializedValue(1)),
tab_id_(SessionID::FromSerializedValue(2)) {}
- ~PersistentTabRestoreServiceTest() override {}
+ ~TabRestoreServiceImplTest() override {}
SessionID tab_id() const { return tab_id_; }
SessionID window_id() const { return window_id_; }
@@ -92,8 +91,8 @@
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
live_tab_ = base::WrapUnique(new sessions::ContentLiveTab(web_contents()));
- time_factory_ = new PersistentTabRestoreTimeFactory();
- service_.reset(new sessions::PersistentTabRestoreService(
+ time_factory_ = new TabRestoreTimeFactory();
+ service_.reset(new sessions::TabRestoreServiceImpl(
std::make_unique<ChromeTabRestoreServiceClient>(profile()),
time_factory_));
}
@@ -109,9 +108,7 @@
return service_->mutable_entries();
}
- void PruneEntries() {
- service_->PruneEntries();
- }
+ void PruneEntries() { service_->PruneEntries(); }
void AddThreeNavigations() {
// Navigate to three URLs.
@@ -133,7 +130,7 @@
service_->Shutdown();
content::RunAllTasksUntilIdle();
service_.reset();
- service_.reset(new sessions::PersistentTabRestoreService(
+ service_.reset(new sessions::TabRestoreServiceImpl(
std::make_unique<ChromeTabRestoreServiceClient>(profile()),
time_factory_));
SynchronousLoadTabsFromLastSession();
@@ -190,8 +187,8 @@
GURL url3_;
std::string user_agent_override_;
std::unique_ptr<sessions::LiveTab> live_tab_;
- std::unique_ptr<sessions::PersistentTabRestoreService> service_;
- PersistentTabRestoreTimeFactory* time_factory_;
+ std::unique_ptr<sessions::TabRestoreServiceImpl> service_;
+ TabRestoreTimeFactory* time_factory_;
SessionID window_id_;
SessionID tab_id_;
};
@@ -222,7 +219,7 @@
} // namespace
-TEST_F(PersistentTabRestoreServiceTest, Basic) {
+TEST_F(TabRestoreServiceImplTest, Basic) {
AddThreeNavigations();
// Have the service record the tab.
@@ -243,8 +240,9 @@
EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url());
EXPECT_EQ("", tab->user_agent_override);
EXPECT_EQ(2, tab->current_navigation_index);
- EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
- tab->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ time_factory_->TimeNow().ToDeltaSinceWindowsEpoch().InMicroseconds(),
+ tab->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
NavigateToIndex(1);
@@ -266,19 +264,20 @@
EXPECT_EQ(url3_, tab->navigations[2].virtual_url());
EXPECT_EQ(user_agent_override_, tab->user_agent_override);
EXPECT_EQ(1, tab->current_navigation_index);
- EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
- tab->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ time_factory_->TimeNow().ToDeltaSinceWindowsEpoch().InMicroseconds(),
+ tab->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
}
// Make sure TabRestoreService doesn't create an entry for a tab with no
// navigations.
-TEST_F(PersistentTabRestoreServiceTest, DontCreateEmptyTab) {
+TEST_F(TabRestoreServiceImplTest, DontCreateEmptyTab) {
service_->CreateHistoricalTab(live_tab(), -1);
EXPECT_TRUE(service_->entries().empty());
}
// Tests restoring a single tab.
-TEST_F(PersistentTabRestoreServiceTest, Restore) {
+TEST_F(TabRestoreServiceImplTest, Restore) {
AddThreeNavigations();
// Have the service record the tab.
@@ -300,12 +299,13 @@
EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url());
EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url());
EXPECT_EQ(2, tab->current_navigation_index);
- EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
- tab->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ time_factory_->TimeNow().ToDeltaSinceWindowsEpoch().InMicroseconds(),
+ tab->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
}
// Tests restoring a tab with more than gMaxPersistNavigationCount entries.
-TEST_F(PersistentTabRestoreServiceTest, RestoreManyNavigations) {
+TEST_F(TabRestoreServiceImplTest, RestoreManyNavigations) {
AddThreeNavigations();
AddThreeNavigations();
AddThreeNavigations();
@@ -332,7 +332,7 @@
}
// Tests restoring a single pinned tab.
-TEST_F(PersistentTabRestoreServiceTest, RestorePinnedAndApp) {
+TEST_F(TabRestoreServiceImplTest, RestorePinnedAndApp) {
AddThreeNavigations();
// Have the service record the tab.
@@ -370,7 +370,7 @@
}
// Tests deleting entries.
-TEST_F(PersistentTabRestoreServiceTest, DeleteNavigationEntries) {
+TEST_F(TabRestoreServiceImplTest, DeleteNavigationEntries) {
SynchronousLoadTabsFromLastSession();
AddThreeNavigations();
@@ -402,7 +402,7 @@
}
// Tests deleting entries.
-TEST_F(PersistentTabRestoreServiceTest, DeleteCurrentEntry) {
+TEST_F(TabRestoreServiceImplTest, DeleteCurrentEntry) {
SynchronousLoadTabsFromLastSession();
AddThreeNavigations();
@@ -419,7 +419,7 @@
}
// Tests deleting entries.
-TEST_F(PersistentTabRestoreServiceTest, DeleteEntriesAndRecreate) {
+TEST_F(TabRestoreServiceImplTest, DeleteEntriesAndRecreate) {
SynchronousLoadTabsFromLastSession();
AddThreeNavigations();
@@ -455,7 +455,7 @@
}
// Make sure we persist entries to disk that have post data.
-TEST_F(PersistentTabRestoreServiceTest, DontPersistPostData) {
+TEST_F(TabRestoreServiceImplTest, DontPersistPostData) {
AddThreeNavigations();
controller().GetEntryAtIndex(0)->SetHasPostData(true);
controller().GetEntryAtIndex(1)->SetHasPostData(true);
@@ -474,18 +474,18 @@
const Entry* restored_entry = service_->entries().front().get();
ASSERT_EQ(sessions::TabRestoreService::TAB, restored_entry->type);
- const Tab* restored_tab =
- static_cast<const Tab*>(restored_entry);
+ const Tab* restored_tab = static_cast<const Tab*>(restored_entry);
// There should be 3 navs.
ASSERT_EQ(3U, restored_tab->navigations.size());
- EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
- restored_tab->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ time_factory_->TimeNow().ToDeltaSinceWindowsEpoch().InMicroseconds(),
+ restored_tab->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
}
// Make sure we don't persist entries to disk that have post data. This
// differs from DontPersistPostData1 in that all the navigations have post
// data, so that nothing should be persisted.
-TEST_F(PersistentTabRestoreServiceTest, DontLoadTwice) {
+TEST_F(TabRestoreServiceImplTest, DontLoadTwice) {
AddThreeNavigations();
// Have the service record the tab.
@@ -502,11 +502,11 @@
}
// Makes sure we load the previous session as necessary.
-TEST_F(PersistentTabRestoreServiceTest, LoadPreviousSession) {
+TEST_F(TabRestoreServiceImplTest, LoadPreviousSession) {
CreateSessionServiceWithOneWindow(false);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
EXPECT_FALSE(service_->IsLoaded());
@@ -523,36 +523,38 @@
sessions::TabRestoreService::Window* window =
static_cast<sessions::TabRestoreService::Window*>(entry2);
ASSERT_EQ(1U, window->tabs.size());
- EXPECT_EQ(0, window->timestamp.ToInternalValue());
+ EXPECT_EQ(0, window->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_EQ(0, window->selected_tab_index);
ASSERT_EQ(1U, window->tabs[0]->navigations.size());
EXPECT_EQ(0, window->tabs[0]->current_navigation_index);
- EXPECT_EQ(0, window->tabs[0]->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ 0,
+ window->tabs[0]->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_TRUE(url1_ == window->tabs[0]->navigations[0].virtual_url());
}
// Makes sure we don't attempt to load previous sessions after a restore.
-TEST_F(PersistentTabRestoreServiceTest, DontLoadAfterRestore) {
+TEST_F(TabRestoreServiceImplTest, DontLoadAfterRestore) {
CreateSessionServiceWithOneWindow(false);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
profile()->set_restored_last_session(true);
SynchronousLoadTabsFromLastSession();
- // Because we restored a session PersistentTabRestoreService shouldn't load
+ // Because we restored a session TabRestoreServiceImpl shouldn't load
// the tabs.
ASSERT_EQ(0U, service_->entries().size());
}
// Makes sure we don't attempt to load previous sessions after a clean exit.
-TEST_F(PersistentTabRestoreServiceTest, DontLoadAfterCleanExit) {
+TEST_F(TabRestoreServiceImplTest, DontLoadAfterCleanExit) {
CreateSessionServiceWithOneWindow(false);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
profile()->set_last_session_exited_cleanly(true);
@@ -561,11 +563,11 @@
ASSERT_EQ(0U, service_->entries().size());
}
-TEST_F(PersistentTabRestoreServiceTest, LoadPreviousSessionAndTabs) {
+TEST_F(TabRestoreServiceImplTest, LoadPreviousSessionAndTabs) {
CreateSessionServiceWithOneWindow(false);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
AddThreeNavigations();
@@ -583,10 +585,12 @@
static_cast<sessions::TabRestoreService::Window*>(entry);
ASSERT_EQ(1U, window->tabs.size());
EXPECT_EQ(0, window->selected_tab_index);
- EXPECT_EQ(0, window->timestamp.ToInternalValue());
+ EXPECT_EQ(0, window->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
ASSERT_EQ(1U, window->tabs[0]->navigations.size());
EXPECT_EQ(0, window->tabs[0]->current_navigation_index);
- EXPECT_EQ(0, window->tabs[0]->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ 0,
+ window->tabs[0]->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_TRUE(url1_ == window->tabs[0]->navigations[0].virtual_url());
// Then the closed tab.
@@ -596,8 +600,9 @@
ASSERT_FALSE(tab->pinned);
ASSERT_EQ(3U, tab->navigations.size());
EXPECT_EQ(2, tab->current_navigation_index);
- EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
- tab->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ time_factory_->TimeNow().ToDeltaSinceWindowsEpoch().InMicroseconds(),
+ tab->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url());
EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url());
EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url());
@@ -605,7 +610,7 @@
// Make sure window bounds and workspace are properly loaded from the session
// service.
-TEST_F(PersistentTabRestoreServiceTest, LoadWindowBoundsAndWorkspace) {
+TEST_F(TabRestoreServiceImplTest, LoadWindowBoundsAndWorkspace) {
constexpr gfx::Rect kBounds(10, 20, 640, 480);
constexpr ui::WindowShowState kShowState = ui::SHOW_STATE_MINIMIZED;
constexpr char kWorkspace[] = "workspace";
@@ -658,11 +663,11 @@
}
// Make sure pinned state is correctly loaded from session service.
-TEST_F(PersistentTabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) {
+TEST_F(TabRestoreServiceImplTest, LoadPreviousSessionAndTabsPinned) {
CreateSessionServiceWithOneWindow(true);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
AddThreeNavigations();
@@ -699,14 +704,14 @@
// Creates kMaxEntries + 1 windows in the session service and makes sure we only
// get back kMaxEntries on restore.
-TEST_F(PersistentTabRestoreServiceTest, ManyWindowsInSessionService) {
+TEST_F(TabRestoreServiceImplTest, ManyWindowsInSessionService) {
CreateSessionServiceWithOneWindow(false);
for (size_t i = 0; i < kMaxEntries; ++i)
AddWindowWithOneTabToSessionService(false);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
AddThreeNavigations();
@@ -725,16 +730,19 @@
static_cast<sessions::TabRestoreService::Window*>(entry);
ASSERT_EQ(1U, window->tabs.size());
EXPECT_EQ(0, window->selected_tab_index);
- EXPECT_EQ(0, window->timestamp.ToInternalValue());
+ EXPECT_EQ(0, window->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
ASSERT_EQ(1U, window->tabs[0]->navigations.size());
EXPECT_EQ(0, window->tabs[0]->current_navigation_index);
- EXPECT_EQ(0, window->tabs[0]->timestamp.ToInternalValue());
+ EXPECT_EQ(
+ 0,
+ window->tabs[0]->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_TRUE(url1_ == window->tabs[0]->navigations[0].virtual_url());
}
// Makes sure we restore timestamps correctly.
-TEST_F(PersistentTabRestoreServiceTest, TimestampSurvivesRestore) {
- base::Time tab_timestamp(base::Time::FromInternalValue(123456789));
+TEST_F(TabRestoreServiceImplTest, TimestampSurvivesRestore) {
+ base::Time tab_timestamp(base::Time::FromDeltaSinceWindowsEpoch(
+ base::TimeDelta::FromMicroseconds(123456789)));
AddThreeNavigations();
@@ -771,10 +779,10 @@
// And verify the entry.
Entry* restored_entry = service_->entries().front().get();
ASSERT_EQ(sessions::TabRestoreService::TAB, restored_entry->type);
- Tab* restored_tab =
- static_cast<Tab*>(restored_entry);
- EXPECT_EQ(tab_timestamp.ToInternalValue(),
- restored_tab->timestamp.ToInternalValue());
+ Tab* restored_tab = static_cast<Tab*>(restored_entry);
+ EXPECT_EQ(
+ tab_timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds(),
+ restored_tab->timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
ASSERT_EQ(old_navigations.size(), restored_tab->navigations.size());
for (size_t i = 0; i < restored_tab->navigations.size(); ++i) {
EXPECT_EQ(old_navigations[i].timestamp(),
@@ -783,7 +791,7 @@
}
// Makes sure we restore status codes correctly.
-TEST_F(PersistentTabRestoreServiceTest, StatusCodesSurviveRestore) {
+TEST_F(TabRestoreServiceImplTest, StatusCodesSurviveRestore) {
AddThreeNavigations();
// Have the service record the tab.
@@ -818,15 +826,14 @@
// And verify the entry.
Entry* restored_entry = service_->entries().front().get();
ASSERT_EQ(sessions::TabRestoreService::TAB, restored_entry->type);
- Tab* restored_tab =
- static_cast<Tab*>(restored_entry);
+ Tab* restored_tab = static_cast<Tab*>(restored_entry);
ASSERT_EQ(old_navigations.size(), restored_tab->navigations.size());
for (size_t i = 0; i < restored_tab->navigations.size(); ++i) {
EXPECT_EQ(200, restored_tab->navigations[i].http_status_code());
}
}
-TEST_F(PersistentTabRestoreServiceTest, PruneEntries) {
+TEST_F(TabRestoreServiceImplTest, PruneEntries) {
service_->ClearEntries();
ASSERT_TRUE(service_->entries().empty());
@@ -916,11 +923,11 @@
}
// Regression test for crbug.com/106082
-TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) {
+TEST_F(TabRestoreServiceImplTest, PruneIsCalled) {
CreateSessionServiceWithOneWindow(false);
- SessionServiceFactory::GetForProfile(profile())->
- MoveCurrentSessionToLastSession();
+ SessionServiceFactory::GetForProfile(profile())
+ ->MoveCurrentSessionToLastSession();
profile()->set_restored_last_session(true);
@@ -939,7 +946,7 @@
// Makes sure invoking LoadTabsFromLastSession() when the max number of entries
// have been added results in IsLoaded() returning true and notifies observers.
-TEST_F(PersistentTabRestoreServiceTest, GoToLoadedWhenHaveMaxEntries) {
+TEST_F(TabRestoreServiceImplTest, GoToLoadedWhenHaveMaxEntries) {
const size_t max_entries = kMaxEntries;
for (size_t i = 0; i < max_entries + 5; i++) {
NavigateAndCommit(
diff --git a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm
index 90d08a2..18018101 100644
--- a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm
+++ b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm
@@ -20,8 +20,8 @@
#include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/favicon_base/favicon_types.h"
-#include "components/sessions/core/persistent_tab_restore_service.h"
#include "components/sessions/core/serialized_navigation_entry_test_helper.h"
+#include "components/sessions/core/tab_restore_service_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
@@ -30,10 +30,10 @@
namespace {
-class MockTRS : public sessions::PersistentTabRestoreService {
+class MockTRS : public sessions::TabRestoreServiceImpl {
public:
MockTRS(Profile* profile)
- : sessions::PersistentTabRestoreService(
+ : sessions::TabRestoreServiceImpl(
base::WrapUnique(new ChromeTabRestoreServiceClient(profile)),
nullptr) {}
MOCK_CONST_METHOD0(entries, const sessions::TabRestoreService::Entries&());
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc
index f84a0d86..f744ab88 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc
@@ -32,9 +32,9 @@
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/menu_model_test.h"
#include "components/browser_sync/profile_sync_service.h"
-#include "components/sessions/core/persistent_tab_restore_service.h"
#include "components/sessions/core/serialized_navigation_entry_test_helper.h"
#include "components/sessions/core/session_types.h"
+#include "components/sessions/core/tab_restore_service_impl.h"
#include "components/sync/device_info/local_device_info_provider_mock.h"
#include "components/sync/driver/data_type_controller.h"
#include "components/sync/engine/data_type_activation_response.h"
@@ -158,7 +158,7 @@
static std::unique_ptr<KeyedService> GetTabRestoreService(
content::BrowserContext* browser_context) {
- return std::make_unique<sessions::PersistentTabRestoreService>(
+ return std::make_unique<sessions::TabRestoreServiceImpl>(
base::WrapUnique(new ChromeTabRestoreServiceClient(
Profile::FromBrowserContext(browser_context))),
nullptr);
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 8abe571..fe052e8 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -797,11 +797,11 @@
"../browser/search_engines/template_url_scraper_browsertest.cc",
"../browser/secure_origin_whitelist_browsertest.cc",
"../browser/sessions/better_session_restore_browsertest.cc",
- "../browser/sessions/persistent_tab_restore_service_browsertest.cc",
"../browser/sessions/session_restore_browsertest.cc",
"../browser/sessions/session_restore_browsertest_chromeos.cc",
"../browser/sessions/session_restore_observer_browsertest.cc",
"../browser/sessions/tab_restore_browsertest.cc",
+ "../browser/sessions/tab_restore_service_browsertest.cc",
"../browser/site_details_browsertest.cc",
"../browser/ui/bloated_renderer/bloated_renderer_tab_helper_browsertest.cc",
"../browser/ui/blocked_content/popup_tracker_browsertest.cc",
@@ -3183,7 +3183,7 @@
"../browser/search/promos/promo_service_unittest.cc",
"../browser/search/search_engine_base_url_tracker_unittest.cc",
"../browser/search/search_unittest.cc",
- "../browser/sessions/persistent_tab_restore_service_unittest.cc",
+ "../browser/sessions/tab_restore_service_unittest.cc",
"../browser/signin/signin_promo_unittest.cc",
"../browser/speech/extension_api/extension_manifests_tts_unittest.cc",
"../browser/speech/tts_controller_delegate_impl_unittest.cc",
diff --git a/components/sessions/BUILD.gn b/components/sessions/BUILD.gn
index 49dfb35b..78c524530 100644
--- a/components/sessions/BUILD.gn
+++ b/components/sessions/BUILD.gn
@@ -76,8 +76,6 @@
"core/live_tab.cc",
"core/live_tab.h",
"core/live_tab_context.h",
- "core/persistent_tab_restore_service.cc",
- "core/persistent_tab_restore_service.h",
"core/serialized_navigation_driver.h",
"core/serialized_navigation_entry.cc",
"core/serialized_navigation_entry.h",
@@ -101,6 +99,8 @@
"core/tab_restore_service_client.h",
"core/tab_restore_service_helper.cc",
"core/tab_restore_service_helper.h",
+ "core/tab_restore_service_impl.cc",
+ "core/tab_restore_service_impl.h",
"core/tab_restore_service_observer.h",
]
diff --git a/components/sessions/content/content_live_tab.h b/components/sessions/content/content_live_tab.h
index c4ff024..56f1322 100644
--- a/components/sessions/content/content_live_tab.h
+++ b/components/sessions/content/content_live_tab.h
@@ -16,7 +16,7 @@
class NavigationController;
}
-class PersistentTabRestoreServiceTest;
+class TabRestoreServiceImplTest;
namespace sessions {
@@ -48,7 +48,7 @@
private:
friend class base::SupportsUserData;
- friend class ::PersistentTabRestoreServiceTest;
+ friend class ::TabRestoreServiceImplTest;
explicit ContentLiveTab(content::WebContents* contents);
diff --git a/components/sessions/core/tab_restore_service_helper.h b/components/sessions/core/tab_restore_service_helper.h
index afae972..2667d1f3 100644
--- a/components/sessions/core/tab_restore_service_helper.h
+++ b/components/sessions/core/tab_restore_service_helper.h
@@ -20,15 +20,14 @@
namespace sessions {
-class TabRestoreService;
+class TabRestoreServiceImpl;
class TabRestoreServiceClient;
class LiveTabContext;
class TabRestoreServiceObserver;
class TimeFactory;
-// Helper class used to implement InMemoryTabRestoreService and
-// PersistentTabRestoreService. See tab_restore_service.h for method-level
-// comments.
+// Helper class used to implement TabRestoreService. See tab_restore_service.h
+// for method-level comments.
class SESSIONS_EXPORT TabRestoreServiceHelper
: public base::trace_event::MemoryDumpProvider {
public:
@@ -128,7 +127,7 @@
static bool ValidateEntry(const Entry& entry);
private:
- friend class PersistentTabRestoreService;
+ friend class TabRestoreServiceImpl;
// Populates the tab's navigations from the LiveTab, and its browser_id and
// pinned state from the context.
diff --git a/components/sessions/core/persistent_tab_restore_service.cc b/components/sessions/core/tab_restore_service_impl.cc
similarity index 87%
rename from components/sessions/core/persistent_tab_restore_service.cc
rename to components/sessions/core/tab_restore_service_impl.cc
index 07950eb..bc08a06 100644
--- a/components/sessions/core/persistent_tab_restore_service.cc
+++ b/components/sessions/core/tab_restore_service_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/sessions/core/persistent_tab_restore_service.h"
+#include "components/sessions/core/tab_restore_service_impl.h"
#include <stddef.h>
#include <stdint.h>
@@ -65,19 +65,19 @@
// Used to indicate what has loaded.
enum LoadState {
// Indicates we haven't loaded anything.
- NOT_LOADED = 1 << 0,
+ NOT_LOADED = 1 << 0,
// Indicates we've asked for the last sessions and tabs but haven't gotten the
// result back yet.
- LOADING = 1 << 2,
+ LOADING = 1 << 2,
// Indicates we finished loading the last tabs (but not necessarily the last
// session).
- LOADED_LAST_TABS = 1 << 3,
+ LOADED_LAST_TABS = 1 << 3,
// Indicates we finished loading the last session (but not necessarily the
// last tabs).
- LOADED_LAST_SESSION = 1 << 4
+ LOADED_LAST_SESSION = 1 << 4
};
// Identifier for commands written to file. The ordering in the file is as
@@ -314,7 +314,8 @@
std::unique_ptr<sessions::TabRestoreService::Window> window =
std::make_unique<sessions::TabRestoreService::Window>();
window->selected_tab_index = fields.selected_tab_index;
- window->timestamp = base::Time::FromInternalValue(fields.timestamp);
+ window->timestamp = base::Time::FromDeltaSinceWindowsEpoch(
+ base::TimeDelta::FromMicroseconds(fields.timestamp));
*window_id = SessionID::FromSerializedValue(fields.window_id);
*num_tabs = fields.num_tabs;
@@ -334,17 +335,18 @@
} // namespace
-// PersistentTabRestoreService::Delegate ---------------------------------------
+// TabRestoreServiceImpl::PersistenceDelegate
+// ---------------------------------------
// This restore service will create and own a BaseSessionService and implement
// the required BaseSessionServiceDelegate.
-class PersistentTabRestoreService::Delegate
+class TabRestoreServiceImpl::PersistenceDelegate
: public BaseSessionServiceDelegate,
public TabRestoreServiceHelper::Observer {
public:
- explicit Delegate(TabRestoreServiceClient* client);
+ explicit PersistenceDelegate(TabRestoreServiceClient* client);
- ~Delegate() override;
+ ~PersistenceDelegate() override;
// BaseSessionServiceDelegate:
bool ShouldUseDelayedSave() override;
@@ -466,10 +468,11 @@
// Used when loading previous tabs/session and open tabs/session.
base::CancelableTaskTracker cancelable_task_tracker_;
- DISALLOW_COPY_AND_ASSIGN(Delegate);
+ DISALLOW_COPY_AND_ASSIGN(PersistenceDelegate);
};
-PersistentTabRestoreService::Delegate::Delegate(TabRestoreServiceClient* client)
+TabRestoreServiceImpl::PersistenceDelegate::PersistenceDelegate(
+ TabRestoreServiceClient* client)
: client_(client),
base_session_service_(
new BaseSessionService(BaseSessionService::TAB_RESTORE,
@@ -480,16 +483,16 @@
entries_written_(0),
load_state_(NOT_LOADED) {}
-PersistentTabRestoreService::Delegate::~Delegate() {}
+TabRestoreServiceImpl::PersistenceDelegate::~PersistenceDelegate() {}
-bool PersistentTabRestoreService::Delegate::ShouldUseDelayedSave() {
+bool TabRestoreServiceImpl::PersistenceDelegate::ShouldUseDelayedSave() {
return true;
}
-void PersistentTabRestoreService::Delegate::OnWillSaveCommands() {
+void TabRestoreServiceImpl::PersistenceDelegate::OnWillSaveCommands() {
const Entries& entries = tab_restore_service_helper_->entries();
- int to_write_count = std::min(entries_to_write_,
- static_cast<int>(entries.size()));
+ int to_write_count =
+ std::min(entries_to_write_, static_cast<int>(entries.size()));
entries_to_write_ = 0;
if (entries_written_ + to_write_count > kEntriesPerReset) {
to_write_count = entries.size();
@@ -523,7 +526,7 @@
entries_written_ = 0;
}
-void PersistentTabRestoreService::Delegate::OnClearEntries() {
+void TabRestoreServiceImpl::PersistenceDelegate::OnClearEntries() {
// Mark all the tabs as closed so that we don't attempt to restore them.
const Entries& entries = tab_restore_service_helper_->entries();
for (auto i = entries.begin(); i != entries.end(); ++i)
@@ -540,7 +543,7 @@
CreateRestoredEntryCommand(SessionID::InvalidValue()));
}
-void PersistentTabRestoreService::Delegate::OnNavigationEntriesDeleted() {
+void TabRestoreServiceImpl::PersistenceDelegate::OnNavigationEntriesDeleted() {
// Rewrite all entries.
entries_to_write_ = tab_restore_service_helper_->entries().size();
@@ -552,7 +555,7 @@
CreateRestoredEntryCommand(SessionID::InvalidValue()));
}
-void PersistentTabRestoreService::Delegate::OnRestoreEntryById(
+void TabRestoreServiceImpl::PersistenceDelegate::OnRestoreEntryById(
SessionID id,
Entries::const_iterator entry_iterator) {
size_t index = 0;
@@ -566,13 +569,13 @@
base_session_service_->ScheduleCommand(CreateRestoredEntryCommand(id));
}
-void PersistentTabRestoreService::Delegate::OnAddEntry() {
+void TabRestoreServiceImpl::PersistenceDelegate::OnAddEntry() {
// Start the save timer, when it fires we'll generate the commands.
base_session_service_->StartSaveTimer();
entries_to_write_++;
}
-void PersistentTabRestoreService::Delegate::LoadTabsFromLastSession() {
+void TabRestoreServiceImpl::PersistenceDelegate::LoadTabsFromLastSession() {
if (load_state_ != NOT_LOADED)
return;
@@ -587,7 +590,8 @@
load_state_ = LOADING;
if (client_->HasLastSession()) {
client_->GetLastSession(
- base::Bind(&Delegate::OnGotPreviousSession, base::Unretained(this)),
+ base::BindRepeating(&PersistenceDelegate::OnGotPreviousSession,
+ base::Unretained(this)),
&cancelable_task_tracker_);
} else {
load_state_ |= LOADED_LAST_SESSION;
@@ -597,20 +601,21 @@
// this won't contain the tabs/window that were open at the point of the
// crash (the call to GetLastSession above requests those).
base_session_service_->ScheduleGetLastSessionCommands(
- base::Bind(&Delegate::OnGotLastSessionCommands, base::Unretained(this)),
+ base::BindRepeating(&PersistenceDelegate::OnGotLastSessionCommands,
+ base::Unretained(this)),
&cancelable_task_tracker_);
}
-void PersistentTabRestoreService::Delegate::DeleteLastSession() {
+void TabRestoreServiceImpl::PersistenceDelegate::DeleteLastSession() {
base_session_service_->DeleteLastSession();
}
-bool PersistentTabRestoreService::Delegate::IsLoaded() const {
+bool TabRestoreServiceImpl::PersistenceDelegate::IsLoaded() const {
return !(load_state_ & (NOT_LOADED | LOADING));
}
// static
-void PersistentTabRestoreService::Delegate::CreateEntriesFromWindows(
+void TabRestoreServiceImpl::PersistenceDelegate::CreateEntriesFromWindows(
std::vector<std::unique_ptr<sessions::SessionWindow>>* windows,
std::vector<std::unique_ptr<Entry>>* entries) {
for (const auto& session_window : *windows) {
@@ -620,11 +625,11 @@
}
}
-void PersistentTabRestoreService::Delegate::Shutdown() {
+void TabRestoreServiceImpl::PersistenceDelegate::Shutdown() {
base_session_service_->Save();
}
-void PersistentTabRestoreService::Delegate::ScheduleCommandsForWindow(
+void TabRestoreServiceImpl::PersistenceDelegate::ScheduleCommandsForWindow(
const Window& window) {
DCHECK(!window.tabs.empty());
int selected_tab = window.selected_tab_index;
@@ -657,7 +662,7 @@
}
}
-void PersistentTabRestoreService::Delegate::ScheduleCommandsForTab(
+void TabRestoreServiceImpl::PersistenceDelegate::ScheduleCommandsForTab(
const Tab& tab,
int selected_index) {
const std::vector<SerializedNavigationEntry>& navigations = tab.navigations;
@@ -701,17 +706,15 @@
for (int i = first_index_to_persist, wrote_count = 0;
wrote_count < 2 * gMaxPersistNavigationCount && i < max_index; ++i) {
if (client_->ShouldTrackURLForRestore(navigations[i].virtual_url())) {
- base_session_service_->ScheduleCommand(
- CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation,
- tab.id,
- navigations[i]));
+ base_session_service_->ScheduleCommand(CreateUpdateTabNavigationCommand(
+ kCommandUpdateTabNavigation, tab.id, navigations[i]));
}
}
}
// static
std::unique_ptr<SessionCommand>
-PersistentTabRestoreService::Delegate::CreateWindowCommand(
+TabRestoreServiceImpl::PersistenceDelegate::CreateWindowCommand(
SessionID window_id,
int selected_tab_index,
int num_tabs,
@@ -728,7 +731,7 @@
pickle.WriteInt(static_cast<int>(window_id.id()));
pickle.WriteInt(selected_tab_index);
pickle.WriteInt(num_tabs);
- pickle.WriteInt64(timestamp.ToInternalValue());
+ pickle.WriteInt64(timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds());
pickle.WriteInt(bounds.x());
pickle.WriteInt(bounds.y());
pickle.WriteInt(bounds.width());
@@ -748,15 +751,14 @@
}
// static
-std::unique_ptr<SessionCommand>
-PersistentTabRestoreService::Delegate::CreateSelectedNavigationInTabCommand(
- SessionID tab_id,
- int32_t index,
- base::Time timestamp) {
+std::unique_ptr<SessionCommand> TabRestoreServiceImpl::PersistenceDelegate::
+ CreateSelectedNavigationInTabCommand(SessionID tab_id,
+ int32_t index,
+ base::Time timestamp) {
SelectedNavigationInTabPayload2 payload;
payload.id = tab_id.id();
payload.index = index;
- payload.timestamp = timestamp.ToInternalValue();
+ payload.timestamp = timestamp.ToDeltaSinceWindowsEpoch().InMicroseconds();
std::unique_ptr<SessionCommand> command(
new SessionCommand(kCommandSelectedNavigationInTab, sizeof(payload)));
memcpy(command->contents(), &payload, sizeof(payload));
@@ -765,7 +767,7 @@
// static
std::unique_ptr<SessionCommand>
-PersistentTabRestoreService::Delegate::CreateRestoredEntryCommand(
+TabRestoreServiceImpl::PersistenceDelegate::CreateRestoredEntryCommand(
SessionID entry_id) {
RestoredEntryPayload payload = entry_id.id();
std::unique_ptr<SessionCommand> command(
@@ -774,8 +776,8 @@
return command;
}
-int PersistentTabRestoreService::Delegate::GetSelectedNavigationIndexToPersist(
- const Tab& tab) {
+int TabRestoreServiceImpl::PersistenceDelegate::
+ GetSelectedNavigationIndexToPersist(const Tab& tab) {
const std::vector<SerializedNavigationEntry>& navigations = tab.navigations;
int selected_index = tab.current_navigation_index;
int max_index = static_cast<int>(navigations.size());
@@ -802,7 +804,7 @@
return (selected_index == max_index) ? -1 : selected_index;
}
-void PersistentTabRestoreService::Delegate::OnGotLastSessionCommands(
+void TabRestoreServiceImpl::PersistenceDelegate::OnGotLastSessionCommands(
std::vector<std::unique_ptr<SessionCommand>> commands) {
std::vector<std::unique_ptr<TabRestoreService::Entry>> entries;
CreateEntriesFromCommands(commands, &entries);
@@ -814,7 +816,7 @@
LoadStateChanged();
}
-void PersistentTabRestoreService::Delegate::CreateEntriesFromCommands(
+void TabRestoreServiceImpl::PersistenceDelegate::CreateEntriesFromCommands(
const std::vector<std::unique_ptr<SessionCommand>>& commands,
std::vector<std::unique_ptr<Entry>>* loaded_entries) {
if (tab_restore_service_helper_->entries().size() == kMaxEntries)
@@ -901,8 +903,8 @@
RemoveEntryByID(SessionID::FromSerializedValue(payload.id), &entries);
entries.push_back(std::make_unique<Tab>());
current_tab = static_cast<Tab*>(entries.back().get());
- current_tab->timestamp =
- base::Time::FromInternalValue(payload.timestamp);
+ current_tab->timestamp = base::Time::FromDeltaSinceWindowsEpoch(
+ base::TimeDelta::FromMicroseconds(payload.timestamp));
}
current_tab->current_navigation_index = payload.index;
break;
@@ -915,9 +917,8 @@
}
current_tab->navigations.resize(current_tab->navigations.size() + 1);
SessionID tab_id = SessionID::InvalidValue();
- if (!RestoreUpdateTabNavigationCommand(command,
- ¤t_tab->navigations.back(),
- &tab_id)) {
+ if (!RestoreUpdateTabNavigationCommand(
+ command, ¤t_tab->navigations.back(), &tab_id)) {
return;
}
// When navigations are serialized, only gMaxPersistNavigationCount
@@ -961,8 +962,7 @@
}
SessionID tab_id = SessionID::InvalidValue();
std::string extension_app_id;
- if (!RestoreSetTabExtensionAppIDCommand(command,
- &tab_id,
+ if (!RestoreSetTabExtensionAppIDCommand(command, &tab_id,
&extension_app_id)) {
return;
}
@@ -977,8 +977,7 @@
}
SessionID tab_id = SessionID::InvalidValue();
std::string user_agent_override;
- if (!RestoreSetTabUserAgentOverrideCommand(command,
- &tab_id,
+ if (!RestoreSetTabUserAgentOverrideCommand(command, &tab_id,
&user_agent_override)) {
return;
}
@@ -998,7 +997,7 @@
}
// static
-void PersistentTabRestoreService::Delegate::ValidateAndDeleteEmptyEntries(
+void TabRestoreServiceImpl::PersistenceDelegate::ValidateAndDeleteEmptyEntries(
std::vector<std::unique_ptr<Entry>>* entries) {
std::vector<std::unique_ptr<Entry>> valid_entries;
@@ -1011,7 +1010,7 @@
entries->swap(valid_entries);
}
-void PersistentTabRestoreService::Delegate::OnGotPreviousSession(
+void TabRestoreServiceImpl::PersistenceDelegate::OnGotPreviousSession(
std::vector<std::unique_ptr<SessionWindow>> windows,
SessionID ignored_active_window) {
std::vector<std::unique_ptr<Entry>> entries;
@@ -1024,7 +1023,7 @@
LoadStateChanged();
}
-bool PersistentTabRestoreService::Delegate::ConvertSessionWindowToWindow(
+bool TabRestoreServiceImpl::PersistenceDelegate::ConvertSessionWindowToWindow(
SessionWindow* session_window,
Window* window) {
for (size_t i = 0; i < session_window->tabs.size(); ++i) {
@@ -1052,7 +1051,7 @@
return true;
}
-void PersistentTabRestoreService::Delegate::LoadStateChanged() {
+void TabRestoreServiceImpl::PersistenceDelegate::LoadStateChanged() {
if ((load_state_ & (LOADED_LAST_TABS | LOADED_LAST_SESSION)) !=
(LOADED_LAST_TABS | LOADED_LAST_SESSION)) {
// Still waiting on previous session or previous tabs.
@@ -1097,98 +1096,96 @@
tab_restore_service_helper_->NotifyLoaded();
}
-// PersistentTabRestoreService -------------------------------------------------
+// TabRestoreServiceImpl -------------------------------------------------
-PersistentTabRestoreService::PersistentTabRestoreService(
+TabRestoreServiceImpl::TabRestoreServiceImpl(
std::unique_ptr<TabRestoreServiceClient> client,
TimeFactory* time_factory)
: client_(std::move(client)),
- delegate_(new Delegate(client_.get())),
- helper_(this, delegate_.get(), client_.get(), time_factory) {
- delegate_->set_tab_restore_service_helper(&helper_);
+ persistence_delegate_(new PersistenceDelegate(client_.get())),
+ helper_(this, persistence_delegate_.get(), client_.get(), time_factory) {
+ persistence_delegate_->set_tab_restore_service_helper(&helper_);
}
-PersistentTabRestoreService::~PersistentTabRestoreService() {}
+TabRestoreServiceImpl::~TabRestoreServiceImpl() {}
-void PersistentTabRestoreService::AddObserver(
- TabRestoreServiceObserver* observer) {
+void TabRestoreServiceImpl::AddObserver(TabRestoreServiceObserver* observer) {
helper_.AddObserver(observer);
}
-void PersistentTabRestoreService::RemoveObserver(
+void TabRestoreServiceImpl::RemoveObserver(
TabRestoreServiceObserver* observer) {
helper_.RemoveObserver(observer);
}
-void PersistentTabRestoreService::CreateHistoricalTab(LiveTab* live_tab,
- int index) {
+void TabRestoreServiceImpl::CreateHistoricalTab(LiveTab* live_tab, int index) {
helper_.CreateHistoricalTab(live_tab, index);
}
-void PersistentTabRestoreService::BrowserClosing(LiveTabContext* context) {
+void TabRestoreServiceImpl::BrowserClosing(LiveTabContext* context) {
helper_.BrowserClosing(context);
}
-void PersistentTabRestoreService::BrowserClosed(LiveTabContext* context) {
+void TabRestoreServiceImpl::BrowserClosed(LiveTabContext* context) {
helper_.BrowserClosed(context);
}
-void PersistentTabRestoreService::ClearEntries() {
+void TabRestoreServiceImpl::ClearEntries() {
helper_.ClearEntries();
}
-void PersistentTabRestoreService::DeleteNavigationEntries(
+void TabRestoreServiceImpl::DeleteNavigationEntries(
const DeletionPredicate& predicate) {
DCHECK(IsLoaded());
helper_.DeleteNavigationEntries(predicate);
}
-const TabRestoreService::Entries& PersistentTabRestoreService::entries() const {
+const TabRestoreService::Entries& TabRestoreServiceImpl::entries() const {
return helper_.entries();
}
-std::vector<LiveTab*> PersistentTabRestoreService::RestoreMostRecentEntry(
+std::vector<LiveTab*> TabRestoreServiceImpl::RestoreMostRecentEntry(
LiveTabContext* context) {
return helper_.RestoreMostRecentEntry(context);
}
std::unique_ptr<TabRestoreService::Tab>
-PersistentTabRestoreService::RemoveTabEntryById(SessionID id) {
+TabRestoreServiceImpl::RemoveTabEntryById(SessionID id) {
return helper_.RemoveTabEntryById(id);
}
-std::vector<LiveTab*> PersistentTabRestoreService::RestoreEntryById(
+std::vector<LiveTab*> TabRestoreServiceImpl::RestoreEntryById(
LiveTabContext* context,
SessionID id,
WindowOpenDisposition disposition) {
return helper_.RestoreEntryById(context, id, disposition);
}
-bool PersistentTabRestoreService::IsLoaded() const {
- return delegate_->IsLoaded();
+bool TabRestoreServiceImpl::IsLoaded() const {
+ return persistence_delegate_->IsLoaded();
}
-void PersistentTabRestoreService::DeleteLastSession() {
- return delegate_->DeleteLastSession();
+void TabRestoreServiceImpl::DeleteLastSession() {
+ return persistence_delegate_->DeleteLastSession();
}
-bool PersistentTabRestoreService::IsRestoring() const {
+bool TabRestoreServiceImpl::IsRestoring() const {
return helper_.IsRestoring();
}
-void PersistentTabRestoreService::Shutdown() {
- return delegate_->Shutdown();
+void TabRestoreServiceImpl::Shutdown() {
+ return persistence_delegate_->Shutdown();
}
-void PersistentTabRestoreService::LoadTabsFromLastSession() {
- delegate_->LoadTabsFromLastSession();
+void TabRestoreServiceImpl::LoadTabsFromLastSession() {
+ persistence_delegate_->LoadTabsFromLastSession();
}
-TabRestoreService::Entries* PersistentTabRestoreService::mutable_entries() {
+TabRestoreService::Entries* TabRestoreServiceImpl::mutable_entries() {
return &helper_.entries_;
}
-void PersistentTabRestoreService::PruneEntries() {
+void TabRestoreServiceImpl::PruneEntries() {
helper_.PruneEntries();
}
diff --git a/components/sessions/core/persistent_tab_restore_service.h b/components/sessions/core/tab_restore_service_impl.h
similarity index 73%
rename from components/sessions/core/persistent_tab_restore_service.h
rename to components/sessions/core/tab_restore_service_impl.h
index 1ac2659..be4ee6e 100644
--- a/components/sessions/core/persistent_tab_restore_service.h
+++ b/components/sessions/core/tab_restore_service_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_SESSIONS_CORE_PERSISTENT_TAB_RESTORE_SERVICE_H_
-#define COMPONENTS_SESSIONS_CORE_PERSISTENT_TAB_RESTORE_SERVICE_H_
+#ifndef COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_IMPL_H_
+#define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_IMPL_H_
#include <memory>
#include <vector>
@@ -15,18 +15,18 @@
#include "components/sessions/core/tab_restore_service_client.h"
#include "components/sessions/core/tab_restore_service_helper.h"
-class PersistentTabRestoreServiceTest;
+class TabRestoreServiceImplTest;
namespace sessions {
// Tab restore service that persists data on disk.
-class SESSIONS_EXPORT PersistentTabRestoreService : public TabRestoreService {
+class SESSIONS_EXPORT TabRestoreServiceImpl : public TabRestoreService {
public:
// Does not take ownership of |time_factory|.
- PersistentTabRestoreService(std::unique_ptr<TabRestoreServiceClient> client,
- TimeFactory* time_factory);
+ TabRestoreServiceImpl(std::unique_ptr<TabRestoreServiceClient> client,
+ TimeFactory* time_factory);
- ~PersistentTabRestoreService() override;
+ ~TabRestoreServiceImpl() override;
// TabRestoreService:
void AddObserver(TabRestoreServiceObserver* observer) override;
@@ -51,21 +51,21 @@
void Shutdown() override;
private:
- friend class ::PersistentTabRestoreServiceTest;
+ friend class ::TabRestoreServiceImplTest;
- class Delegate;
+ class PersistenceDelegate;
// Exposed for testing.
Entries* mutable_entries();
void PruneEntries();
std::unique_ptr<TabRestoreServiceClient> client_;
- std::unique_ptr<Delegate> delegate_;
+ std::unique_ptr<PersistenceDelegate> persistence_delegate_;
TabRestoreServiceHelper helper_;
- DISALLOW_COPY_AND_ASSIGN(PersistentTabRestoreService);
+ DISALLOW_COPY_AND_ASSIGN(TabRestoreServiceImpl);
};
} // namespace sessions
-#endif // COMPONENTS_SESSIONS_CORE_PERSISTENT_TAB_RESTORE_SERVICE_H_
+#endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_IMPL_H_
diff --git a/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.cc b/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.cc
index a634abd..fa9847c 100644
--- a/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.cc
+++ b/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.cc
@@ -7,7 +7,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
-#include "components/sessions/core/persistent_tab_restore_service.h"
+#include "components/sessions/core/tab_restore_service_impl.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.h"
@@ -19,7 +19,7 @@
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromBrowserState(context);
- return std::make_unique<sessions::PersistentTabRestoreService>(
+ return std::make_unique<sessions::TabRestoreServiceImpl>(
base::WrapUnique(new IOSChromeTabRestoreServiceClient(browser_state)),
nullptr);
}