| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/sessions/core/persistent_tab_restore_service.h" | 5 #include "components/sessions/core/persistent_tab_restore_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 enum { | 82 enum { |
| 83 kMaxEntries = sessions::TabRestoreServiceHelper::kMaxEntries, | 83 kMaxEntries = sessions::TabRestoreServiceHelper::kMaxEntries, |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // testing::Test: | 86 // testing::Test: |
| 87 void SetUp() override { | 87 void SetUp() override { |
| 88 ChromeRenderViewHostTestHarness::SetUp(); | 88 ChromeRenderViewHostTestHarness::SetUp(); |
| 89 live_tab_ = base::WrapUnique(new sessions::ContentLiveTab(web_contents())); | 89 live_tab_ = base::WrapUnique(new sessions::ContentLiveTab(web_contents())); |
| 90 time_factory_ = new PersistentTabRestoreTimeFactory(); | 90 time_factory_ = new PersistentTabRestoreTimeFactory(); |
| 91 service_.reset(new sessions::PersistentTabRestoreService( | 91 service_.reset(new sessions::PersistentTabRestoreService( |
| 92 base::WrapUnique(new ChromeTabRestoreServiceClient(profile())), | 92 base::MakeUnique<ChromeTabRestoreServiceClient>(profile()), |
| 93 time_factory_)); | 93 time_factory_)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TearDown() override { | 96 void TearDown() override { |
| 97 service_->Shutdown(); | 97 service_->Shutdown(); |
| 98 service_.reset(); | 98 service_.reset(); |
| 99 delete time_factory_; | 99 delete time_factory_; |
| 100 ChromeRenderViewHostTestHarness::TearDown(); | 100 ChromeRenderViewHostTestHarness::TearDown(); |
| 101 } | 101 } |
| 102 | 102 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 122 WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 122 WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void RecreateService() { | 125 void RecreateService() { |
| 126 // Must set service to null first so that it is destroyed before the new | 126 // Must set service to null first so that it is destroyed before the new |
| 127 // one is created. | 127 // one is created. |
| 128 service_->Shutdown(); | 128 service_->Shutdown(); |
| 129 content::RunAllBlockingPoolTasksUntilIdle(); | 129 content::RunAllBlockingPoolTasksUntilIdle(); |
| 130 service_.reset(); | 130 service_.reset(); |
| 131 service_.reset(new sessions::PersistentTabRestoreService( | 131 service_.reset(new sessions::PersistentTabRestoreService( |
| 132 base::WrapUnique(new ChromeTabRestoreServiceClient(profile())), | 132 base::MakeUnique<ChromeTabRestoreServiceClient>(profile()), |
| 133 time_factory_)); | 133 time_factory_)); |
| 134 SynchronousLoadTabsFromLastSession(); | 134 SynchronousLoadTabsFromLastSession(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Adds a window with one tab and url to the profile's session service. | 137 // Adds a window with one tab and url to the profile's session service. |
| 138 // If |pinned| is true, the tab is marked as pinned in the session service. | 138 // If |pinned| is true, the tab is marked as pinned in the session service. |
| 139 void AddWindowWithOneTabToSessionService(bool pinned) { | 139 void AddWindowWithOneTabToSessionService(bool pinned) { |
| 140 SessionService* session_service = | 140 SessionService* session_service = |
| 141 SessionServiceFactory::GetForProfile(profile()); | 141 SessionServiceFactory::GetForProfile(profile()); |
| 142 SessionID tab_id; | 142 SessionID tab_id; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 784 |
| 785 EXPECT_FALSE(service_->IsLoaded()); | 785 EXPECT_FALSE(service_->IsLoaded()); |
| 786 TestTabRestoreServiceObserver observer; | 786 TestTabRestoreServiceObserver observer; |
| 787 service_->AddObserver(&observer); | 787 service_->AddObserver(&observer); |
| 788 EXPECT_EQ(max_entries, service_->entries().size()); | 788 EXPECT_EQ(max_entries, service_->entries().size()); |
| 789 SynchronousLoadTabsFromLastSession(); | 789 SynchronousLoadTabsFromLastSession(); |
| 790 EXPECT_TRUE(observer.got_loaded()); | 790 EXPECT_TRUE(observer.got_loaded()); |
| 791 EXPECT_TRUE(service_->IsLoaded()); | 791 EXPECT_TRUE(service_->IsLoaded()); |
| 792 service_->RemoveObserver(&observer); | 792 service_->RemoveObserver(&observer); |
| 793 } | 793 } |
| OLD | NEW |