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

Side by Side Diff: components/sync_sessions/synced_session_tracker.h

Issue 2791183003: [Sync] Restore previous session if no tabbed windows present (Closed)
Patch Set: Self review Created 3 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef COMPONENTS_SYNC_SESSIONS_SYNCED_SESSION_TRACKER_H_ 5 #ifndef COMPONENTS_SYNC_SESSIONS_SYNCED_SESSION_TRACKER_H_
6 #define COMPONENTS_SYNC_SESSIONS_SYNCED_SESSION_TRACKER_H_ 6 #define COMPONENTS_SYNC_SESSIONS_SYNCED_SESSION_TRACKER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 // Resets the tracking information for the session specified by |session_tag|. 90 // Resets the tracking information for the session specified by |session_tag|.
91 // This involves clearing all the windows and tabs from the session, while 91 // This involves clearing all the windows and tabs from the session, while
92 // keeping pointers saved in the synced_window_map_ and synced_tab_map_. Once 92 // keeping pointers saved in the synced_window_map_ and synced_tab_map_. Once
93 // reset, all calls to PutWindowInSession and PutTabInWindow will denote that 93 // reset, all calls to PutWindowInSession and PutTabInWindow will denote that
94 // the requested windows and tabs are owned and add them back to their 94 // the requested windows and tabs are owned and add them back to their
95 // session. The next call to CleanupSession(...) will delete those windows and 95 // session. The next call to CleanupSession(...) will delete those windows and
96 // tabs not owned. 96 // tabs not owned.
97 void ResetSessionTracking(const std::string& session_tag); 97 void ResetSessionTracking(const std::string& session_tag);
98 98
99 // Deletes those windows and tabs associated with |session_tag| that are no
100 // longer owned. See ResetSessionTracking(...)..
101 void CleanupSession(const std::string& session_tag);
102
99 // Adds the window with id |window_id| to the session specified by 103 // Adds the window with id |window_id| to the session specified by
100 // |session_tag|. If none existed for that session, creates one. Similarly, if 104 // |session_tag|. If none existed for that session, creates one. Similarly, if
101 // the session did not exist yet, creates it. Ownership of the SessionWindow 105 // the session did not exist yet, creates it. Ownership of the SessionWindow
102 // remains within the SyncedSessionTracker. 106 // remains within the SyncedSessionTracker.
107 // Attempting to add a window to a session multiple times will have no effect.
103 void PutWindowInSession(const std::string& session_tag, 108 void PutWindowInSession(const std::string& session_tag,
104 SessionID::id_type window_id); 109 SessionID::id_type window_id);
105 110
106 // Adds the tab with id |tab_id| to the window |window_id|. If none existed 111 // Adds the tab with id |tab_id| to the window |window_id|. If none existed
107 // for that session, creates one. Ownership of the SessionTab remains within 112 // for that session, creates one. Ownership of the SessionTab remains within
108 // the SyncedSessionTracker. 113 // the SyncedSessionTracker.
109 // 114 //
110 // Note: GetSession(..) must have already been called with |session_tag| to 115 // Note: GetSession(..) must have already been called with |session_tag| to
111 // ensure we having mapping information for this session. 116 // ensure we having mapping information for this session.
112 void PutTabInWindow(const std::string& session_tag, 117 void PutTabInWindow(const std::string& session_tag,
(...skipping 25 matching lines...) Expand all
138 // parent this tab. Regardless, when the header is updated then cleanup will 143 // parent this tab. Regardless, when the header is updated then cleanup will
139 // remove the actual tab data. However, this method always needs to be called 144 // remove the actual tab data. However, this method always needs to be called
140 // upon foreign tab deletion, otherwise LookupTabNodeIds(...) may return 145 // upon foreign tab deletion, otherwise LookupTabNodeIds(...) may return
141 // already deleted tab node ids. 146 // already deleted tab node ids.
142 void DeleteForeignTab(const std::string& session_tag, int tab_node_id); 147 void DeleteForeignTab(const std::string& session_tag, int tab_node_id);
143 148
144 // Deletes the session associated with |session_tag| if it exists. 149 // Deletes the session associated with |session_tag| if it exists.
145 // Returns true if the session existed and was deleted, false otherwise. 150 // Returns true if the session existed and was deleted, false otherwise.
146 bool DeleteForeignSession(const std::string& session_tag); 151 bool DeleteForeignSession(const std::string& session_tag);
147 152
148 // Deletes those windows and tabs associated with |session_tag| that are no
149 // longer owned. See ResetSessionTracking(...)..
150 void CleanupForeignSession(const std::string& session_tag);
151
152 // **** Methods specific to the local session. **** 153 // **** Methods specific to the local session. ****
153 154
154 // Set the local session tag. Must be called before any other local session 155 // Set the local session tag. Must be called before any other local session
155 // methods are invoked. 156 // methods are invoked.
156 void SetLocalSessionTag(const std::string& local_session_tag); 157 void SetLocalSessionTag(const std::string& local_session_tag);
157 158
158 // Similar to CleanupForeignSession, but also marks any unmapped tabs as free 159 // Similar to CleanupForeignSession, but also marks any unmapped tabs as free
159 // in the tab node pool and fills |deleted_node_ids| with the set of locally 160 // in the tab node pool and fills |deleted_node_ids| with the set of locally
160 // free tab nodes to be deleted. 161 // free tab nodes to be deleted.
161 void CleanupLocalTabs(std::set<int>* deleted_node_ids); 162 void CleanupLocalTabs(std::set<int>* deleted_node_ids);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 248
248 // Pool of used/available sync nodes associated with local tabs. 249 // Pool of used/available sync nodes associated with local tabs.
249 TabNodePool local_tab_pool_; 250 TabNodePool local_tab_pool_;
250 251
251 DISALLOW_COPY_AND_ASSIGN(SyncedSessionTracker); 252 DISALLOW_COPY_AND_ASSIGN(SyncedSessionTracker);
252 }; 253 };
253 254
254 } // namespace sync_sessions 255 } // namespace sync_sessions
255 256
256 #endif // COMPONENTS_SYNC_SESSIONS_SYNCED_SESSION_TRACKER_H_ 257 #endif // COMPONENTS_SYNC_SESSIONS_SYNCED_SESSION_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698