Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/sessions/persistent_tab_restore_service.h

Issue 10989027: Split TabRestoreService into InMemoryTRS and PersistentTRS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split TRS into InMemoryTRS and PersistentTRS Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <vector>
sky 2012/10/17 21:49:31 Make sure you svn cp so that history is preserved.
Philippe 2012/10/18 09:41:41 I'm using git which doesn't provide a way to keep
Philippe 2012/10/18 09:54:06 I think I was wrong on this point. git cl upload
6
7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/time.h"
11 #include "chrome/browser/sessions/base_session_service.h"
12 #include "chrome/browser/sessions/in_memory_tab_restore_service.h"
13
14 class Profile;
15
16 class PersistentTabRestoreService : public BaseSessionService,
sky 2012/10/17 21:49:31 Doesn't this result in diamond inheritance? Persis
Philippe 2012/10/18 09:41:41 Sure.
17 public InMemoryTabRestoreService {
18 public:
19 // Creates a new TabRestoreService and provides an object that provides the
20 // current time. The TabRestoreService does not take ownership of the
21 // |time_factory_|.
22 PersistentTabRestoreService(Profile* profile,
23 TimeFactory* time_factory = NULL);
24
25 PersistentTabRestoreService();
26 virtual ~PersistentTabRestoreService();
27
28 private:
29 // BaseSessionService:
30 virtual void Save() OVERRIDE;
31
32 // InMemoryTabRestoreService:
33 virtual bool IsLoaded() const OVERRIDE;
34 virtual void Shutdown() OVERRIDE;
35 virtual void OnClearEntries() OVERRIDE;
36 virtual void OnRestoreEntryById(
37 SessionID::id_type id,
38 Entries::const_iterator entry_iterator) OVERRIDE;
39 virtual void OnAddEntry() OVERRIDE;
40
41 // Returns the index to persist as the selected index. This is the same
42 // as |tab.current_navigation_index| unless the entry at
43 // |tab.current_navigation_index| shouldn't be persisted. Returns -1 if
44 // no valid navigation to persist.
45 int GetSelectedNavigationIndexToPersist(const Tab& tab);
46
47 // Schedules the commands for a tab close. |selected_index| gives the
48 // index of the selected navigation.
49 void ScheduleCommandsForTab(const Tab& tab, int selected_index);
50
51 // Schedules the commands for a window close.
52 void ScheduleCommandsForWindow(const Window& window);
53
54 // Callback from SessionService when we've received the windows from the
55 // previous session. This creates and add entries to |staging_entries_|
56 // and invokes LoadStateChanged. |ignored_active_window| is ignored because
57 // we don't need to restore activation.
58 void OnGotPreviousSession(Handle handle,
59 std::vector<SessionWindow*>* windows,
60 SessionID::id_type ignored_active_window);
61
62 // Invoked when we've loaded the session commands that identify the
63 // previously closed tabs. This creates entries, adds them to
64 // staging_entries_, and invokes LoadState.
65 void OnGotLastSessionCommands(
66 Handle handle,
67 scoped_refptr<InternalGetCommandsRequest> request);
68
69 // Populates |loaded_entries| with Entries from |request|.
70 void CreateEntriesFromCommands(
71 scoped_refptr<InternalGetCommandsRequest> request,
72 std::vector<Entry*>* loaded_entries);
73
74 // Creates and add entries to |entries| for each of the windows in |windows|.
75 void CreateEntriesFromWindows(std::vector<SessionWindow*>* windows,
76 std::vector<Entry*>* entries);
77
78 // If |id_to_entry| contains an entry for |id| the corresponding entry is
79 // deleted and removed from both |id_to_entry| and |entries|. This is used
80 // when creating entries from the backend file.
81 void RemoveEntryByID(SessionID::id_type id,
82 IDToEntry* id_to_entry,
83 std::vector<TabRestoreService::Entry*>* entries);
84
85 // Validates all entries in |entries|, deleting any with no navigations.
86 // This also deletes any entries beyond the max number of entries we can
87 // hold.
88 static void ValidateAndDeleteEmptyEntries(std::vector<Entry*>* entries);
89
90 virtual void LoadTabsFromLastSession() OVERRIDE;
91
92 void LoadStateChanged();
93
94 // The number of entries to write.
95 int entries_to_write_;
96
97 // Number of entries we've written.
98 int entries_written_;
99
100 // Whether we've loaded the last session.
101 int load_state_;
102
103 // Results from previously closed tabs/sessions is first added here. When
104 // the results from both us and the session restore service have finished
105 // loading LoadStateChanged is invoked, which adds these entries to
106 // entries_.
107 std::vector<Entry*> staging_entries_;
108
109 // Used when loading previous tabs/session.
110 CancelableRequestConsumer load_consumer_;
111
112 DISALLOW_COPY_AND_ASSIGN(PersistentTabRestoreService);
113 };
OLDNEW
« no previous file with comments | « chrome/browser/sessions/in_memory_tab_restore_service.cc ('k') | chrome/browser/sessions/persistent_tab_restore_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698