| 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 | |
| 9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/sessions/chrome_tab_restore_service_client.h" | 18 #include "chrome/browser/sessions/chrome_tab_restore_service_client.h" |
| 19 #include "chrome/browser/sessions/session_service.h" | 19 #include "chrome/browser/sessions/session_service.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 SerializedNavigationEntryTestHelper::CreateNavigation( | 152 SerializedNavigationEntryTestHelper::CreateNavigation( |
| 153 url1_.spec(), "title")); | 153 url1_.spec(), "title")); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Creates a SessionService and assigns it to the Profile. The SessionService | 156 // Creates a SessionService and assigns it to the Profile. The SessionService |
| 157 // is configured with a single window with a single tab pointing at url1_ by | 157 // is configured with a single window with a single tab pointing at url1_ by |
| 158 // way of AddWindowWithOneTabToSessionService. If |pinned| is true, the | 158 // way of AddWindowWithOneTabToSessionService. If |pinned| is true, the |
| 159 // tab is marked as pinned in the session service. | 159 // tab is marked as pinned in the session service. |
| 160 void CreateSessionServiceWithOneWindow(bool pinned) { | 160 void CreateSessionServiceWithOneWindow(bool pinned) { |
| 161 scoped_ptr<SessionService> session_service(new SessionService(profile())); | 161 scoped_ptr<SessionService> session_service(new SessionService(profile())); |
| 162 SessionServiceFactory::SetForTestProfile(profile(), session_service.Pass()); | 162 SessionServiceFactory::SetForTestProfile(profile(), |
| 163 std::move(session_service)); |
| 163 | 164 |
| 164 AddWindowWithOneTabToSessionService(pinned); | 165 AddWindowWithOneTabToSessionService(pinned); |
| 165 | 166 |
| 166 // Set this, otherwise previous session won't be loaded. | 167 // Set this, otherwise previous session won't be loaded. |
| 167 profile()->set_last_session_exited_cleanly(false); | 168 profile()->set_last_session_exited_cleanly(false); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void SynchronousLoadTabsFromLastSession() { | 171 void SynchronousLoadTabsFromLastSession() { |
| 171 // Ensures that the load is complete before continuing. | 172 // Ensures that the load is complete before continuing. |
| 172 service_->LoadTabsFromLastSession(); | 173 service_->LoadTabsFromLastSession(); |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 777 |
| 777 EXPECT_FALSE(service_->IsLoaded()); | 778 EXPECT_FALSE(service_->IsLoaded()); |
| 778 TestTabRestoreServiceObserver observer; | 779 TestTabRestoreServiceObserver observer; |
| 779 service_->AddObserver(&observer); | 780 service_->AddObserver(&observer); |
| 780 EXPECT_EQ(max_entries, service_->entries().size()); | 781 EXPECT_EQ(max_entries, service_->entries().size()); |
| 781 SynchronousLoadTabsFromLastSession(); | 782 SynchronousLoadTabsFromLastSession(); |
| 782 EXPECT_TRUE(observer.got_loaded()); | 783 EXPECT_TRUE(observer.got_loaded()); |
| 783 EXPECT_TRUE(service_->IsLoaded()); | 784 EXPECT_TRUE(service_->IsLoaded()); |
| 784 service_->RemoveObserver(&observer); | 785 service_->RemoveObserver(&observer); |
| 785 } | 786 } |
| OLD | NEW |