| Index: components/sync_sessions/synced_session_tracker.h
|
| diff --git a/components/sync_sessions/synced_session_tracker.h b/components/sync_sessions/synced_session_tracker.h
|
| index ccd47839e24c49d53f7a750fe48736d8875f7d48..35123d76a9ce54e67999f31071da0feac5128723 100644
|
| --- a/components/sync_sessions/synced_session_tracker.h
|
| +++ b/components/sync_sessions/synced_session_tracker.h
|
| @@ -40,7 +40,8 @@
|
| explicit SyncedSessionTracker(SyncSessionsClient* sessions_client);
|
| ~SyncedSessionTracker();
|
|
|
| - // **** Synced session/tab query methods. ****
|
| + // We track and distinguish the local session from foreign sessions.
|
| + void SetLocalSessionTag(const std::string& local_session_tag);
|
|
|
| // Fill a preallocated vector with all foreign sessions we're tracking (skips
|
| // the local session object). SyncedSession ownership remains within the
|
| @@ -49,11 +50,6 @@
|
| // Returns true if we had foreign sessions to fill it with, false otherwise.
|
| bool LookupAllForeignSessions(std::vector<const SyncedSession*>* sessions,
|
| SessionLookup lookup) const;
|
| -
|
| - // Fills |tab_node_ids| with the tab node ids (see GetTab) for all the tabs*
|
| - // associated with the session having tag |session_tag|.
|
| - void LookupForeignTabNodeIds(const std::string& session_tag,
|
| - std::set<int>* tab_node_ids) const;
|
|
|
| // Attempts to look up the session windows associatd with the session given
|
| // by |session_tag|. Ownership of SessionWindows stays within the
|
| @@ -80,12 +76,14 @@
|
| // this won't create-if-not-present.
|
| bool LookupLocalSession(const SyncedSession** output) const;
|
|
|
| - // **** Methods for manipulating synced sessions and tabs. ****
|
| -
|
| // Returns a pointer to the SyncedSession object associated with
|
| // |session_tag|. If none exists, creates one. Ownership of the
|
| // SyncedSession remains within the SyncedSessionTracker.
|
| SyncedSession* GetSession(const std::string& session_tag);
|
| +
|
| + // Deletes the session associated with |session_tag| if it exists.
|
| + // Returns true if the session existed and was deleted, false otherwise.
|
| + bool DeleteSession(const std::string& session_tag);
|
|
|
| // Resets the tracking information for the session specified by |session_tag|.
|
| // This involves clearing all the windows and tabs from the session, while
|
| @@ -96,42 +94,6 @@
|
| // tabs not owned.
|
| void ResetSessionTracking(const std::string& session_tag);
|
|
|
| - // Adds the window with id |window_id| to the session specified by
|
| - // |session_tag|. If none existed for that session, creates one. Similarly, if
|
| - // the session did not exist yet, creates it. Ownership of the SessionWindow
|
| - // remains within the SyncedSessionTracker.
|
| - void PutWindowInSession(const std::string& session_tag,
|
| - SessionID::id_type window_id);
|
| -
|
| - // Adds the tab with id |tab_id| to the window |window_id|. If none existed
|
| - // for that session, creates one. Ownership of the SessionTab remains within
|
| - // the SyncedSessionTracker.
|
| - //
|
| - // Note: GetSession(..) must have already been called with |session_tag| to
|
| - // ensure we having mapping information for this session.
|
| - void PutTabInWindow(const std::string& session_tag,
|
| - SessionID::id_type window_id,
|
| - SessionID::id_type tab_id);
|
| -
|
| - // Adds |tab_node_id| to the session specified by |session_tag|, creating that
|
| - // session if necessary. This is necessary to ensure that each session has an
|
| - // up to date list of tab nodes linked to it for session deletion purposes.
|
| - // Note that this won't update the local tab pool, even if the local session
|
| - // tag is passed. The tab pool is only updated with new tab nodes when they're
|
| - // associated with a tab id (see ReassociateLocalTabNode or
|
| - // GetTabNodeFromLocalTabId).
|
| - void OnTabNodeSeen(const std::string& session_tag, int tab_node_id);
|
| -
|
| - // Returns a pointer to the SessionTab object associated with
|
| - // |tab_id| for the session specified with |session_tag|.
|
| - // Note: Ownership of the SessionTab remains within the SyncedSessionTracker.
|
| - // TODO(zea): Replace SessionTab with a Sync specific wrapper.
|
| - // crbug.com/662597
|
| - sessions::SessionTab* GetTab(const std::string& session_tag,
|
| - SessionID::id_type tab_id);
|
| -
|
| - // **** Methods specific to foreign sessions. ****
|
| -
|
| // Tracks the deletion of a foreign tab by removing the given |tab_node_id|
|
| // from the parent session. Doesn't actually remove any tab objects because
|
| // the header may have or may not have already been updated to no longer
|
| @@ -141,41 +103,40 @@
|
| // already deleted tab node ids.
|
| void DeleteForeignTab(const std::string& session_tag, int tab_node_id);
|
|
|
| - // Deletes the session associated with |session_tag| if it exists.
|
| - // Returns true if the session existed and was deleted, false otherwise.
|
| - bool DeleteForeignSession(const std::string& session_tag);
|
| -
|
| // Deletes those windows and tabs associated with |session_tag| that are no
|
| - // longer owned. See ResetSessionTracking(...)..
|
| - void CleanupForeignSession(const std::string& session_tag);
|
| -
|
| - // **** Methods specific to the local session. ****
|
| -
|
| - // Set the local session tag. Must be called before any other local session
|
| - // methods are invoked.
|
| - void SetLocalSessionTag(const std::string& local_session_tag);
|
| -
|
| - // Similar to CleanupForeignSession, but also marks any unmapped tabs as free
|
| - // in the tab node pool and fills |deleted_node_ids| with the set of locally
|
| - // free tab nodes to be deleted.
|
| - void CleanupLocalTabs(std::set<int>* deleted_node_ids);
|
| -
|
| - // Fills |tab_node_id| with a tab node for |tab_id|. Returns true if an
|
| - // existing tab node was found, false if there was none and one had to be
|
| - // created.
|
| - bool GetTabNodeFromLocalTabId(SessionID::id_type tab_id, int* tab_node_id);
|
| -
|
| - // Returns whether |tab_node_id| refers to a valid tab node that is associated
|
| - // with a tab.
|
| - bool IsLocalTabNodeAssociated(int tab_node_id);
|
| -
|
| - // Reassociates the tab denoted by |tab_node_id| with a new tab id, preserving
|
| - // any previous SessionTab object the node was associated with. This is useful
|
| - // on restart when sync needs to reassociate tabs from a previous session with
|
| - // newly restored tabs (and can be used in conjunction with PutTabInWindow).
|
| - void ReassociateLocalTab(int tab_node_id, SessionID::id_type new_tab_id);
|
| -
|
| - // **** Methods for querying/manipulating overall state ****.
|
| + // longer owned. See ResetSessionTracking(...).
|
| + void CleanupSession(const std::string& session_tag);
|
| +
|
| + // Adds the window with id |window_id| to the session specified by
|
| + // |session_tag|. If none existed for that session, creates one. Similarly, if
|
| + // the session did not exist yet, creates it. Ownership of the SessionWindow
|
| + // remains within the SyncedSessionTracker.
|
| + void PutWindowInSession(const std::string& session_tag,
|
| + SessionID::id_type window_id);
|
| +
|
| + // Adds the tab with id |tab_id| to the window |window_id|. If none existed
|
| + // for that session, creates one. Ownership of the SessionTab remains within
|
| + // the SyncedSessionTracker.
|
| + //
|
| + // Note: GetSession(..) must have already been called with |session_tag| to
|
| + // ensure we having mapping information for this session.
|
| + void PutTabInWindow(const std::string& session_tag,
|
| + SessionID::id_type window_id,
|
| + SessionID::id_type tab_id,
|
| + size_t tab_index);
|
| +
|
| + // Returns a pointer to the SessionTab object associated with |tab_id| for
|
| + // the session specified with |session_tag|. If none exists, creates one.
|
| + // Ownership of the SessionTab remains within the SyncedSessionTracker.
|
| + // |tab_node_id| must be a valid node id for the node backing this tab.
|
| + sessions::SessionTab* GetTab(const std::string& session_tag,
|
| + SessionID::id_type tab_id,
|
| + int tab_node_id);
|
| +
|
| + // Fills |tab_node_ids| with the tab node ids (see GetTab) for all the tabs*
|
| + // associated with the session having tag |session_tag|.
|
| + void LookupTabNodeIds(const std::string& session_tag,
|
| + std::set<int>* tab_node_ids);
|
|
|
| // Free the memory for all dynamically allocated objects and clear the
|
| // tracking structures.
|
| @@ -198,25 +159,21 @@
|
| }
|
| }
|
|
|
| - // Returns whether a tab is unmapped or not.
|
| - bool IsTabUnmappedForTesting(SessionID::id_type tab_id);
|
| -
|
| private:
|
| - friend class SessionsSyncManagerTest;
|
| - friend class SyncedSessionTrackerTest;
|
| -
|
| - // Implementation of CleanupForeignSession/CleanupLocalTabs.
|
| - void CleanupSessionImpl(const std::string& session_tag);
|
| + // Implementation for GetTab(...) above, permits invalid tab_node_id.
|
| + sessions::SessionTab* GetTabImpl(const std::string& session_tag,
|
| + SessionID::id_type tab_id,
|
| + int tab_node_id);
|
|
|
| // The client of the sync sessions datatype.
|
| SyncSessionsClient* const sessions_client_;
|
|
|
| - // The mapping of tab/window to their SessionTab/SessionWindow objects.
|
| + // The mapping of tab/window ids to their SessionTab/SessionWindow objects.
|
| // The SessionTab/SessionWindow objects referred to may be owned either by the
|
| // session in the |synced_session_map_| or be temporarily unmapped and live in
|
| // the |unmapped_tabs_|/|unmapped_windows_| collections.
|
| //
|
| - // Map: session tag -> (tab/window -> SessionTab*/SessionWindow*)
|
| + // Map: session tag -> (tab/window id -> SessionTab*/SessionWindow*)
|
| std::map<std::string, std::map<SessionID::id_type, sessions::SessionTab*>>
|
| synced_tab_map_;
|
| std::map<std::string, std::map<SessionID::id_type, sessions::SessionWindow*>>
|
| @@ -246,9 +203,6 @@
|
| // sessions.
|
| std::string local_session_tag_;
|
|
|
| - // Pool of used/available sync nodes associated with local tabs.
|
| - TabNodePool local_tab_pool_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(SyncedSessionTracker);
|
| };
|
|
|
|
|