| 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 "chrome/browser/sessions/persistent_tab_restore_service.h" | 5 #include "chrome/browser/sessions/persistent_tab_restore_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 protected: | 74 protected: |
| 75 enum { | 75 enum { |
| 76 kMaxEntries = TabRestoreServiceHelper::kMaxEntries, | 76 kMaxEntries = TabRestoreServiceHelper::kMaxEntries, |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // testing::Test: | 79 // testing::Test: |
| 80 void SetUp() override { | 80 void SetUp() override { |
| 81 ChromeRenderViewHostTestHarness::SetUp(); | 81 ChromeRenderViewHostTestHarness::SetUp(); |
| 82 time_factory_ = new PersistentTabRestoreTimeFactory(); | 82 time_factory_ = new PersistentTabRestoreTimeFactory(); |
| 83 service_.reset(new PersistentTabRestoreService( | 83 service_.reset(new PersistentTabRestoreService( |
| 84 profile(), | |
| 85 make_scoped_ptr(new ChromeTabRestoreServiceClient(profile())), | 84 make_scoped_ptr(new ChromeTabRestoreServiceClient(profile())), |
| 86 time_factory_)); | 85 time_factory_)); |
| 87 } | 86 } |
| 88 | 87 |
| 89 void TearDown() override { | 88 void TearDown() override { |
| 90 service_->Shutdown(); | 89 service_->Shutdown(); |
| 91 service_.reset(); | 90 service_.reset(); |
| 92 delete time_factory_; | 91 delete time_factory_; |
| 93 ChromeRenderViewHostTestHarness::TearDown(); | 92 ChromeRenderViewHostTestHarness::TearDown(); |
| 94 } | 93 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 115 WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 114 WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| 116 } | 115 } |
| 117 | 116 |
| 118 void RecreateService() { | 117 void RecreateService() { |
| 119 // Must set service to null first so that it is destroyed before the new | 118 // Must set service to null first so that it is destroyed before the new |
| 120 // one is created. | 119 // one is created. |
| 121 service_->Shutdown(); | 120 service_->Shutdown(); |
| 122 content::RunAllBlockingPoolTasksUntilIdle(); | 121 content::RunAllBlockingPoolTasksUntilIdle(); |
| 123 service_.reset(); | 122 service_.reset(); |
| 124 service_.reset(new PersistentTabRestoreService( | 123 service_.reset(new PersistentTabRestoreService( |
| 125 profile(), | |
| 126 make_scoped_ptr(new ChromeTabRestoreServiceClient(profile())), | 124 make_scoped_ptr(new ChromeTabRestoreServiceClient(profile())), |
| 127 time_factory_)); | 125 time_factory_)); |
| 128 SynchronousLoadTabsFromLastSession(); | 126 SynchronousLoadTabsFromLastSession(); |
| 129 } | 127 } |
| 130 | 128 |
| 131 // Adds a window with one tab and url to the profile's session service. | 129 // Adds a window with one tab and url to the profile's session service. |
| 132 // If |pinned| is true, the tab is marked as pinned in the session service. | 130 // If |pinned| is true, the tab is marked as pinned in the session service. |
| 133 void AddWindowWithOneTabToSessionService(bool pinned) { | 131 void AddWindowWithOneTabToSessionService(bool pinned) { |
| 134 SessionService* session_service = | 132 SessionService* session_service = |
| 135 SessionServiceFactory::GetForProfile(profile()); | 133 SessionServiceFactory::GetForProfile(profile()); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 760 |
| 763 EXPECT_FALSE(service_->IsLoaded()); | 761 EXPECT_FALSE(service_->IsLoaded()); |
| 764 TestTabRestoreServiceObserver observer; | 762 TestTabRestoreServiceObserver observer; |
| 765 service_->AddObserver(&observer); | 763 service_->AddObserver(&observer); |
| 766 EXPECT_EQ(max_entries, service_->entries().size()); | 764 EXPECT_EQ(max_entries, service_->entries().size()); |
| 767 SynchronousLoadTabsFromLastSession(); | 765 SynchronousLoadTabsFromLastSession(); |
| 768 EXPECT_TRUE(observer.got_loaded()); | 766 EXPECT_TRUE(observer.got_loaded()); |
| 769 EXPECT_TRUE(service_->IsLoaded()); | 767 EXPECT_TRUE(service_->IsLoaded()); |
| 770 service_->RemoveObserver(&observer); | 768 service_->RemoveObserver(&observer); |
| 771 } | 769 } |
| OLD | NEW |