OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cstring> // memcpy | 7 #include <cstring> // memcpy |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/task/cancelable_task_tracker.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "chrome/browser/common/cancelable_request.h" | 20 #include "chrome/browser/common/cancelable_request.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/sessions/base_session_service.h" | 22 #include "chrome/browser/sessions/base_session_service.h" |
22 #include "chrome/browser/sessions/session_command.h" | 23 #include "chrome/browser/sessions/session_command.h" |
23 #include "chrome/browser/sessions/session_service.h" | 24 #include "chrome/browser/sessions/session_service.h" |
24 #include "chrome/browser/sessions/session_service_factory.h" | 25 #include "chrome/browser/sessions/session_service_factory.h" |
25 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 26 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
26 #include "chrome/common/cancelable_task_tracker.h" | |
27 #include "content/public/browser/session_storage_namespace.h" | 27 #include "content/public/browser/session_storage_namespace.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Only written if the tab is pinned. | 31 // Only written if the tab is pinned. |
32 typedef bool PinnedStatePayload; | 32 typedef bool PinnedStatePayload; |
33 | 33 |
34 typedef int32 RestoredEntryPayload; | 34 typedef int32 RestoredEntryPayload; |
35 | 35 |
36 typedef std::map<SessionID::id_type, TabRestoreService::Entry*> IDToEntry; | 36 typedef std::map<SessionID::id_type, TabRestoreService::Entry*> IDToEntry; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 // Whether we've loaded the last session. | 225 // Whether we've loaded the last session. |
226 int load_state_; | 226 int load_state_; |
227 | 227 |
228 // Results from previously closed tabs/sessions is first added here. When the | 228 // Results from previously closed tabs/sessions is first added here. When the |
229 // results from both us and the session restore service have finished loading | 229 // results from both us and the session restore service have finished loading |
230 // LoadStateChanged is invoked, which adds these entries to entries_. | 230 // LoadStateChanged is invoked, which adds these entries to entries_. |
231 ScopedVector<Entry> staging_entries_; | 231 ScopedVector<Entry> staging_entries_; |
232 | 232 |
233 // Used when loading previous tabs/session and open tabs/session. | 233 // Used when loading previous tabs/session and open tabs/session. |
234 CancelableTaskTracker cancelable_task_tracker_; | 234 base::CancelableTaskTracker cancelable_task_tracker_; |
235 | 235 |
236 DISALLOW_COPY_AND_ASSIGN(Delegate); | 236 DISALLOW_COPY_AND_ASSIGN(Delegate); |
237 }; | 237 }; |
238 | 238 |
239 PersistentTabRestoreService::Delegate::Delegate(Profile* profile) | 239 PersistentTabRestoreService::Delegate::Delegate(Profile* profile) |
240 : BaseSessionService(BaseSessionService::TAB_RESTORE, profile, | 240 : BaseSessionService(BaseSessionService::TAB_RESTORE, profile, |
241 base::FilePath()), | 241 base::FilePath()), |
242 tab_restore_service_helper_(NULL), | 242 tab_restore_service_helper_(NULL), |
243 entries_to_write_(0), | 243 entries_to_write_(0), |
244 entries_written_(0), | 244 entries_written_(0), |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 } | 984 } |
985 | 985 |
986 void PersistentTabRestoreService::PruneEntries() { | 986 void PersistentTabRestoreService::PruneEntries() { |
987 helper_.PruneEntries(); | 987 helper_.PruneEntries(); |
988 } | 988 } |
989 | 989 |
990 BrowserContextKeyedService* TabRestoreServiceFactory::BuildServiceInstanceFor( | 990 BrowserContextKeyedService* TabRestoreServiceFactory::BuildServiceInstanceFor( |
991 content::BrowserContext* profile) const { | 991 content::BrowserContext* profile) const { |
992 return new PersistentTabRestoreService(static_cast<Profile*>(profile), NULL); | 992 return new PersistentTabRestoreService(static_cast<Profile*>(profile), NULL); |
993 } | 993 } |
OLD | NEW |