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

Side by Side Diff: chrome/browser/sync/glue/synced_session_tracker.h

Issue 10917231: Revamp TabNavigation class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac Created 8 years, 3 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
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 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 std::vector<const SessionWindow*>* windows) const; 49 std::vector<const SessionWindow*>* windows) const;
50 50
51 // Attempts to look up the tab associated with the given tag and tab id. 51 // Attempts to look up the tab associated with the given tag and tab id.
52 // Ownership of the SessionTab remains within the SyncedSessionTracker. 52 // Ownership of the SessionTab remains within the SyncedSessionTracker.
53 // If lookup succeeds: 53 // If lookup succeeds:
54 // - Sets tab to point to the SessionTab, and returns true. 54 // - Sets tab to point to the SessionTab, and returns true.
55 // Else 55 // Else
56 // - Returns false, tab is set to NULL. 56 // - Returns false, tab is set to NULL.
57 bool LookupSessionTab(const std::string& session_tag, 57 bool LookupSessionTab(const std::string& session_tag,
58 SessionID::id_type tab_id, 58 SessionID::id_type tab_id,
59 const SyncedSessionTab** tab) const; 59 const SessionTab** tab) const;
60 60
61 // Returns a pointer to the SyncedSession object associated with 61 // Returns a pointer to the SyncedSession object associated with
62 // |session_tag|. If none exists, creates one. Ownership of the 62 // |session_tag|. If none exists, creates one. Ownership of the
63 // SyncedSession remains within the SyncedSessionTracker. 63 // SyncedSession remains within the SyncedSessionTracker.
64 SyncedSession* GetSession(const std::string& session_tag); 64 SyncedSession* GetSession(const std::string& session_tag);
65 65
66 // Deletes the session associated with |session_tag| if it exists. 66 // Deletes the session associated with |session_tag| if it exists.
67 // Returns true if the session existed and was deleted, false otherwise. 67 // Returns true if the session existed and was deleted, false otherwise.
68 bool DeleteSession(const std::string& session_tag); 68 bool DeleteSession(const std::string& session_tag);
69 69
(...skipping 26 matching lines...) Expand all
96 // Note: GetSession(..) must have already been called with |session_tag| to 96 // Note: GetSession(..) must have already been called with |session_tag| to
97 // ensure we having mapping information for this session. 97 // ensure we having mapping information for this session.
98 void PutTabInWindow(const std::string& session_tag, 98 void PutTabInWindow(const std::string& session_tag,
99 SessionID::id_type window_id, 99 SessionID::id_type window_id,
100 SessionID::id_type tab_id, 100 SessionID::id_type tab_id,
101 size_t tab_index); 101 size_t tab_index);
102 102
103 // Returns a pointer to the SessionTab object associated with |tab_id| for 103 // Returns a pointer to the SessionTab object associated with |tab_id| for
104 // the session specified with |session_tag|. If none exists, creates one. 104 // the session specified with |session_tag|. If none exists, creates one.
105 // Ownership of the SessionTab remains within the SyncedSessionTracker. 105 // Ownership of the SessionTab remains within the SyncedSessionTracker.
106 SyncedSessionTab* GetTab(const std::string& session_tag, 106 SessionTab* GetTab(const std::string& session_tag,
107 SessionID::id_type tab_id); 107 SessionID::id_type tab_id);
108 108
109 // Free the memory for all dynamically allocated objects and clear the 109 // Free the memory for all dynamically allocated objects and clear the
110 // tracking structures. 110 // tracking structures.
111 void Clear(); 111 void Clear();
112 112
113 bool Empty() const { 113 bool Empty() const {
114 return synced_tab_map_.empty() && synced_session_map_.empty(); 114 return synced_tab_map_.empty() && synced_session_map_.empty();
115 } 115 }
116 116
117 // Includes both foreign sessions and the local session. 117 // Includes both foreign sessions and the local session.
(...skipping 13 matching lines...) Expand all
131 private: 131 private:
132 // Datatypes for accessing session data. Neither of the *Wrappers actually 132 // Datatypes for accessing session data. Neither of the *Wrappers actually
133 // have ownership of the Windows/Tabs, they just provide id-based access to 133 // have ownership of the Windows/Tabs, they just provide id-based access to
134 // them. The ownership remains within its containing session (for windows and 134 // them. The ownership remains within its containing session (for windows and
135 // mapped tabs, unmapped tabs are owned by the unmapped_tabs_ container). 135 // mapped tabs, unmapped tabs are owned by the unmapped_tabs_ container).
136 // Note, we pair pointers with bools so that we can track what is owned and 136 // Note, we pair pointers with bools so that we can track what is owned and
137 // what can be deleted (see ResetSessionTracking(..) and CleanupSession(..) 137 // what can be deleted (see ResetSessionTracking(..) and CleanupSession(..)
138 // above). 138 // above).
139 struct SessionTabWrapper { 139 struct SessionTabWrapper {
140 SessionTabWrapper() : tab_ptr(NULL), owned(false) {} 140 SessionTabWrapper() : tab_ptr(NULL), owned(false) {}
141 SessionTabWrapper(SyncedSessionTab* tab_ptr, bool owned) 141 SessionTabWrapper(SessionTab* tab_ptr, bool owned)
142 : tab_ptr(tab_ptr), 142 : tab_ptr(tab_ptr),
143 owned(owned) {} 143 owned(owned) {}
144 SyncedSessionTab* tab_ptr; 144 SessionTab* tab_ptr;
145 bool owned; 145 bool owned;
146 }; 146 };
147 typedef std::map<SessionID::id_type, SessionTabWrapper> IDToSessionTabMap; 147 typedef std::map<SessionID::id_type, SessionTabWrapper> IDToSessionTabMap;
148 typedef std::map<std::string, IDToSessionTabMap> SyncedTabMap; 148 typedef std::map<std::string, IDToSessionTabMap> SyncedTabMap;
149 149
150 struct SessionWindowWrapper { 150 struct SessionWindowWrapper {
151 SessionWindowWrapper() : window_ptr(NULL), owned(false) {} 151 SessionWindowWrapper() : window_ptr(NULL), owned(false) {}
152 SessionWindowWrapper(SessionWindow* window_ptr, bool owned) 152 SessionWindowWrapper(SessionWindow* window_ptr, bool owned)
153 : window_ptr(window_ptr), 153 : window_ptr(window_ptr),
154 owned(owned) {} 154 owned(owned) {}
(...skipping 22 matching lines...) Expand all
177 177
178 // Per client mapping synced session objects. 178 // Per client mapping synced session objects.
179 // Key: session tag. 179 // Key: session tag.
180 // Value: SyncedSession object pointer. 180 // Value: SyncedSession object pointer.
181 SyncedSessionMap synced_session_map_; 181 SyncedSessionMap synced_session_map_;
182 182
183 // The set of tabs that we have seen, and created SessionTab objects for, but 183 // The set of tabs that we have seen, and created SessionTab objects for, but
184 // have not yet mapped to SyncedSessions. These are temporarily orphaned 184 // have not yet mapped to SyncedSessions. These are temporarily orphaned
185 // tabs, and won't be deleted if we delete synced_session_map_, but are still 185 // tabs, and won't be deleted if we delete synced_session_map_, but are still
186 // owned by the SyncedSessionTracker itself (and deleted on Clear()). 186 // owned by the SyncedSessionTracker itself (and deleted on Clear()).
187 std::set<SyncedSessionTab*> unmapped_tabs_; 187 std::set<SessionTab*> unmapped_tabs_;
188 188
189 // The tag for this machine's local session, so we can distinguish the foreign 189 // The tag for this machine's local session, so we can distinguish the foreign
190 // sessions. 190 // sessions.
191 std::string local_session_tag_; 191 std::string local_session_tag_;
192 192
193 DISALLOW_COPY_AND_ASSIGN(SyncedSessionTracker); 193 DISALLOW_COPY_AND_ASSIGN(SyncedSessionTracker);
194 }; 194 };
195 195
196 } // namespace browser_sync 196 } // namespace browser_sync
197 197
198 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_ 198 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/synced_session.cc ('k') | chrome/browser/sync/glue/synced_session_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698