diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 15:07:39 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 15:07:39 +0000 |
commit | d70fb3654b968d378139d71942ee2cc5b73c6996 (patch) | |
tree | ea13da6f758418f5c470c3932e58c3ceefe5a682 | |
parent | e4e7376ab3b4a03c326db14ab54ea5621b771738 (diff) | |
download | chromium_src-d70fb3654b968d378139d71942ee2cc5b73c6996.zip chromium_src-d70fb3654b968d378139d71942ee2cc5b73c6996.tar.gz chromium_src-d70fb3654b968d378139d71942ee2cc5b73c6996.tar.bz2 |
[Sync] Foreign session -> Synced session
Rename the foreign session tracker and foreign session objects to reflect that
they are synced sessions, which may include non-foreign sessions. Add support for
tracking the local session in the synced session tracker (which the session model
associator will eventually make use of).
BUG=85766
TEST=session sync unit tests
Review URL: http://codereview.chromium.org/6995145
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89186 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 369 insertions, 356 deletions
diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc index eae3ba2..59ca5b9 100644 --- a/chrome/browser/sessions/session_types.cc +++ b/chrome/browser/sessions/session_types.cc @@ -120,12 +120,12 @@ SessionWindow::~SessionWindow() { STLDeleteElements(&tabs); } -// ForeignSession -------------------------------------------------------------- +// SyncedSession -------------------------------------------------------------- -ForeignSession::ForeignSession() : foreign_session_tag("invalid") { +SyncedSession::SyncedSession() : session_tag("invalid") { } -ForeignSession::~ForeignSession() { +SyncedSession::~SyncedSession() { STLDeleteElements(&windows); } diff --git a/chrome/browser/sessions/session_types.h b/chrome/browser/sessions/session_types.h index dfef3cc..d597379 100644 --- a/chrome/browser/sessions/session_types.h +++ b/chrome/browser/sessions/session_types.h @@ -196,14 +196,14 @@ struct SessionWindow { DISALLOW_COPY_AND_ASSIGN(SessionWindow); }; -// Defines a foreign session for session sync. A foreign session is a session -// on a remote chrome instance. -struct ForeignSession { - ForeignSession(); - ~ForeignSession(); +// Defines a synced session for use by session sync. A synced session is a +// list of windows along with a unique session identifer (tag). +struct SyncedSession { + SyncedSession(); + ~SyncedSession(); // Unique tag for each session. - std::string foreign_session_tag; + std::string session_tag; std::vector<SessionWindow*> windows; }; diff --git a/chrome/browser/sync/glue/foreign_session_tracker.cc b/chrome/browser/sync/glue/foreign_session_tracker.cc deleted file mode 100644 index e9bc9c6..0000000 --- a/chrome/browser/sync/glue/foreign_session_tracker.cc +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/glue/foreign_session_tracker.h" -#include "chrome/browser/sync/glue/session_model_associator.h" - -namespace browser_sync { - - -ForeignSessionTracker::ForeignSessionTracker() { -} - -ForeignSessionTracker::~ForeignSessionTracker() { - clear(); -} - -bool ForeignSessionTracker::LookupAllForeignSessions( - std::vector<const ForeignSession*>* sessions) { - DCHECK(sessions); - // Fill vector of sessions from our foreign session map. - for (ForeignSessionMap::const_iterator i = - foreign_session_map_.begin(); i != foreign_session_map_.end(); ++i) { - // Only include sessions with open tabs. - ForeignSession* foreign_session = i->second; - if (!foreign_session->windows.empty() && - !SessionModelAssociator::SessionWindowHasNoTabsToSync( - *foreign_session->windows[0])) { - sessions->push_back(foreign_session); - } - } - - return !sessions->empty(); -} - -bool ForeignSessionTracker::LookupSessionWindows( - const std::string& foreign_session_tag, - std::vector<SessionWindow*>* windows) { - DCHECK(windows); - ForeignSessionMap::iterator iter = foreign_session_map_.find( - foreign_session_tag); - if (iter == foreign_session_map_.end()) - return false; - *windows = iter->second->windows; - return true; -} - -bool ForeignSessionTracker::LookupSessionTab( - const std::string& tag, - SessionID::id_type tab_id, - const SessionTab** tab) { - DCHECK(tab); - if (foreign_tab_map_.find(tag) == foreign_tab_map_.end()) { - // We have no record of this session. - *tab = NULL; - return false; - } - if (foreign_tab_map_[tag]->find(tab_id) == foreign_tab_map_[tag]->end()) { - // We have no record of this tab. - *tab = NULL; - return false; - } - *tab = (*foreign_tab_map_[tag])[tab_id]; - return true; -} - -ForeignSession* ForeignSessionTracker::GetForeignSession( - const std::string& foreign_session_tag) { - scoped_ptr<ForeignSession> foreign_session; - if (foreign_session_map_.find(foreign_session_tag) != - foreign_session_map_.end()) { - foreign_session.reset(foreign_session_map_[foreign_session_tag]); - } else { - foreign_session.reset(new ForeignSession); - foreign_session->foreign_session_tag = foreign_session_tag; - foreign_session_map_[foreign_session_tag] = foreign_session.get(); - } - DCHECK(foreign_session.get()); - return foreign_session.release(); -} - -bool ForeignSessionTracker::DeleteForeignSession( - const std::string& foreign_session_tag) { - ForeignSessionMap::iterator iter = - foreign_session_map_.find(foreign_session_tag); - if (iter != foreign_session_map_.end()) { - delete iter->second; // Delete the ForeignSession object. - foreign_session_map_.erase(iter); - return true; - } else { - return false; - } -} - -SessionTab* ForeignSessionTracker::GetSessionTab( - const std::string& foreign_session_tag, - SessionID::id_type tab_id, - bool has_window) { - if (foreign_tab_map_.find(foreign_session_tag) == foreign_tab_map_.end()) - foreign_tab_map_[foreign_session_tag] = new IDToSessionTabMap; - scoped_ptr<SessionTab> tab; - IDToSessionTabMap::iterator iter = - foreign_tab_map_[foreign_session_tag]->find(tab_id); - if (iter != foreign_tab_map_[foreign_session_tag]->end()) { - tab.reset(iter->second); - if (has_window) // This tab is linked to a window, so it's not an orphan. - unmapped_tabs_.erase(tab.get()); - VLOG(1) << "Associating " << foreign_session_tag << "'s seen tab " << - tab_id << " at " << tab.get(); - } else { - tab.reset(new SessionTab()); - (*foreign_tab_map_[foreign_session_tag])[tab_id] = tab.get(); - if (!has_window) // This tab is not linked to a window, it's an orphan. - unmapped_tabs_.insert(tab.get()); - VLOG(1) << "Associating " << foreign_session_tag << "'s new tab " << - tab_id << " at " << tab.get(); - } - DCHECK(tab.get()); - return tab.release(); -} - -void ForeignSessionTracker::clear() { - // Delete ForeignSession objects (which also deletes all their windows/tabs). - STLDeleteContainerPairSecondPointers(foreign_session_map_.begin(), - foreign_session_map_.end()); - foreign_session_map_.clear(); - - // Delete IDToSessTab maps. Does not delete the SessionTab objects, because - // they should already be referenced through foreign_session_map_. - STLDeleteContainerPairSecondPointers(foreign_tab_map_.begin(), - foreign_tab_map_.end()); - foreign_tab_map_.clear(); - - // Go through and delete any tabs we had allocated but had not yet placed into - // a ForeignSessionobject. - STLDeleteContainerPointers(unmapped_tabs_.begin(), unmapped_tabs_.end()); - unmapped_tabs_.clear(); -} - -} // namespace browser_sync diff --git a/chrome/browser/sync/glue/foreign_session_tracker.h b/chrome/browser/sync/glue/foreign_session_tracker.h deleted file mode 100644 index 5076d8f..0000000 --- a/chrome/browser/sync/glue/foreign_session_tracker.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SYNC_GLUE_FOREIGN_SESSION_TRACKER_H_ -#define CHROME_BROWSER_SYNC_GLUE_FOREIGN_SESSION_TRACKER_H_ -#pragma once - -#include <map> -#include <set> -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/memory/scoped_vector.h" -#include "chrome/browser/sessions/session_id.h" -#include "chrome/browser/sessions/session_types.h" - -namespace browser_sync { - -// Class to manage foreign sessions. The tracker will own all ForeignSession -// and SessionTab objects it creates, and deletes them appropriately on -// destruction. -class ForeignSessionTracker { - public: - ForeignSessionTracker(); - ~ForeignSessionTracker(); - - // Fill a preallocated vector with all foreign sessions we're tracking. - // Returns true if we had foreign sessions to fill it with, false otherwise. - bool LookupAllForeignSessions(std::vector<const ForeignSession*>* sessions); - - // Attempts to look up the session windows associatd with the foreign session - // given by |foreign_session_tag|. - // If lookup succeeds: - // - Fills windows with the SessionWindow pointers, returns true. - // Else - // - Returns false. - bool LookupSessionWindows(const std::string& foreign_session_tag, - std::vector<SessionWindow*>* windows); - - // Attempts to look up the foreign tab associated with the given tag and tab - // id. - // If lookup succeeds: - // - Sets tab to point to the SessionTab, and returns true. - // Else - // - Returns false, tab is set to NULL. - bool LookupSessionTab(const std::string& foreign_session_tag, - SessionID::id_type tab_id, - const SessionTab** tab); - - // Returns a pointer to the ForeignSession object associated with - // foreign_session_tag. If none exists, creates one and returns its pointer. - ForeignSession* GetForeignSession(const std::string& foreign_session_tag); - - // Deletes the foreign session associated with |foreign_session_tag| if it - // exists. - // Returns true if the session existed and was deleted, false otherwise. - bool DeleteForeignSession(const std::string& foreign_session_tag); - - // Returns a pointer to the SessionTab object associated with |tab_id| for - // the session specified with |foreign_session_tag|. If none exists, creates - // one and returns its pointer. - // |has_window| determines if newly created tabs are added to the pool of - // orphaned tabs (thos which can't be reached by traversing foreign sessions). - SessionTab* GetSessionTab(const std::string& foreign_session_tag, - SessionID::id_type tab_id, - bool has_window); - - // Free the memory for all dynamically allocated objects and clear the - // tracking structures. - void clear(); - - inline bool empty() { - return foreign_tab_map_.empty() && foreign_session_map_.empty(); - } - - inline size_t num_foreign_sessions() { - return foreign_session_map_.size(); - } - - inline size_t num_foreign_tabs(const std::string& foreign_session_tag) { - if (foreign_tab_map_.find(foreign_session_tag) != foreign_tab_map_.end()) { - return foreign_tab_map_[foreign_session_tag]->size(); - } else { - return 0; - } - } - private: - // Datatypes for accessing foreign tab data. - typedef std::map<SessionID::id_type, SessionTab*> IDToSessionTabMap; - typedef std::map<std::string, IDToSessionTabMap*> ForeignTabMap; - typedef std::map<std::string, ForeignSession*> ForeignSessionMap; - - // Per foreign client mapping of their tab id's to their SessionTab objects. - ForeignTabMap foreign_tab_map_; - - // Map of foreign sessions, accessed by the foreign client id. - ForeignSessionMap foreign_session_map_; - - // The set of foreign tabs that we have seen, and created SessionTab objects - // for, but have not yet mapped to ForeignSessions. These are temporarily - // orphaned tabs, and won't be deleted if we delete foreign_session_map_. - std::set<SessionTab*> unmapped_tabs_; - - DISALLOW_COPY_AND_ASSIGN(ForeignSessionTracker); -}; - -} // namespace browser_sync - -#endif // CHROME_BROWSER_SYNC_GLUE_FOREIGN_SESSION_TRACKER_H_ diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc index 67992c8..4f2812c 100644 --- a/chrome/browser/sync/glue/session_model_associator.cc +++ b/chrome/browser/sync/glue/session_model_associator.cc @@ -372,7 +372,7 @@ bool SessionModelAssociator::AssociateModels() { DCHECK(CalledOnValidThread()); // Ensure that we disassociated properly, otherwise memory might leak. - DCHECK(foreign_session_tracker_.empty()); + DCHECK(synced_session_tracker_.empty()); DCHECK_EQ(0U, tab_pool_.capacity()); local_session_syncid_ = sync_api::kInvalidId; @@ -417,7 +417,7 @@ bool SessionModelAssociator::AssociateModels() { bool SessionModelAssociator::DisassociateModels() { DCHECK(CalledOnValidThread()); - foreign_session_tracker_.clear(); + synced_session_tracker_.clear(); tab_map_.clear(); tab_pool_.clear(); local_session_syncid_ = sync_api::kInvalidId; @@ -507,9 +507,9 @@ bool SessionModelAssociator::AssociateForeignSpecifics( // Header data contains window information and ordered tab id's for each // window. - // Load (or create) the ForeignSession object for this client. - ForeignSession* foreign_session = - foreign_session_tracker_.GetForeignSession(foreign_session_tag); + // Load (or create) the SyncedSession object for this client. + SyncedSession* foreign_session = + synced_session_tracker_.GetSession(foreign_session_tag); const sync_pb::SessionHeader& header = specifics.header(); foreign_session->windows.reserve(header.window_size()); @@ -526,7 +526,7 @@ bool SessionModelAssociator::AssociateForeignSpecifics( window_s, modification_time, foreign_session->windows[i], - &foreign_session_tracker_); + &synced_session_tracker_); } // Remove any remaining windows (in case windows were closed) for (; i < foreign_session->windows.size(); ++i) { @@ -537,9 +537,9 @@ bool SessionModelAssociator::AssociateForeignSpecifics( const sync_pb::SessionTab& tab_s = specifics.tab(); SessionID::id_type tab_id = tab_s.tab_id(); SessionTab* tab = - foreign_session_tracker_.GetSessionTab(foreign_session_tag, - tab_id, - false); + synced_session_tracker_.GetSessionTab(foreign_session_tag, + tab_id, + false); PopulateSessionTabFromSpecifics(tab_s, modification_time, tab); } else { NOTREACHED(); @@ -552,7 +552,7 @@ bool SessionModelAssociator::AssociateForeignSpecifics( void SessionModelAssociator::DisassociateForeignSession( const std::string& foreign_session_tag) { DCHECK(CalledOnValidThread()); - foreign_session_tracker_.DeleteForeignSession(foreign_session_tag); + synced_session_tracker_.DeleteSession(foreign_session_tag); } // Static @@ -561,7 +561,7 @@ void SessionModelAssociator::PopulateSessionWindowFromSpecifics( const sync_pb::SessionWindow& specifics, int64 mtime, SessionWindow* session_window, - ForeignSessionTracker* tracker) { + SyncedSessionTracker* tracker) { if (specifics.has_window_id()) session_window->window_id.set_id(specifics.window_id()); if (specifics.has_selected_tab_index()) @@ -758,16 +758,16 @@ void SessionModelAssociator::TabNodePool::FreeTabNode(int64 sync_id) { } bool SessionModelAssociator::GetAllForeignSessions( - std::vector<const ForeignSession*>* sessions) { + std::vector<const SyncedSession*>* sessions) { DCHECK(CalledOnValidThread()); - return foreign_session_tracker_.LookupAllForeignSessions(sessions); + return synced_session_tracker_.LookupAllForeignSessions(sessions); } bool SessionModelAssociator::GetForeignSession( const std::string& tag, std::vector<SessionWindow*>* windows) { DCHECK(CalledOnValidThread()); - return foreign_session_tracker_.LookupSessionWindows(tag, windows); + return synced_session_tracker_.LookupSessionWindows(tag, windows); } bool SessionModelAssociator::GetForeignTab( @@ -775,7 +775,7 @@ bool SessionModelAssociator::GetForeignTab( const SessionID::id_type tab_id, const SessionTab** tab) { DCHECK(CalledOnValidThread()); - return foreign_session_tracker_.LookupSessionTab(tag, tab_id, tab); + return synced_session_tracker_.LookupSessionTab(tag, tab_id, tab); } // Static diff --git a/chrome/browser/sync/glue/session_model_associator.h b/chrome/browser/sync/glue/session_model_associator.h index a66a146..694b6b7 100644 --- a/chrome/browser/sync/glue/session_model_associator.h +++ b/chrome/browser/sync/glue/session_model_associator.h @@ -22,7 +22,7 @@ #include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_types.h" #include "chrome/browser/sync/engine/syncapi.h" -#include "chrome/browser/sync/glue/foreign_session_tracker.h" +#include "chrome/browser/sync/glue/synced_session_tracker.h" #include "chrome/browser/sync/glue/model_associator.h" #include "chrome/browser/sync/protocol/session_specifics.pb.h" #include "chrome/browser/sync/syncable/model_type.h" @@ -145,10 +145,10 @@ class SessionModelAssociator // Builds a list of all foreign sessions. // Caller does NOT own ForeignSession objects. - bool GetAllForeignSessions(std::vector<const ForeignSession*>* sessions); + bool GetAllForeignSessions(std::vector<const SyncedSession*>* sessions); // Loads all windows for foreign session with session tag |tag|. - // Caller does NOT own ForeignSession objects. + // Caller does NOT own SyncedSession objects. bool GetForeignSession(const std::string& tag, std::vector<SessionWindow*>* windows); @@ -297,7 +297,7 @@ class SessionModelAssociator typedef std::map<SessionID::id_type, TabLinks> TabLinksMap; // Delete all foreign session/window/tab objects allocated dynamically. - // This is comprised of ForeignSession*, IDToSessionTabMap*, and any orphaned + // This is comprised of SyncedSession*, IDToSessionTabMap*, and any orphaned // SessionTab*'s. void DeleteForeignSessions(); @@ -338,7 +338,7 @@ class SessionModelAssociator const sync_pb::SessionWindow& window, const int64 mtime, SessionWindow* session_window, - ForeignSessionTracker* tracker); + SyncedSessionTracker* tracker); // Used to populate a session tab from the session specifics tab provided. static void PopulateSessionTabFromSpecifics(const sync_pb::SessionTab& tab, @@ -398,7 +398,7 @@ class SessionModelAssociator // Mapping of current open (local) tabs to their sync identifiers. TabLinksMap tab_map_; - ForeignSessionTracker foreign_session_tracker_; + SyncedSessionTracker synced_session_tracker_; // Weak pointer. ProfileSyncService* sync_service_; diff --git a/chrome/browser/sync/glue/session_model_associator_unittest.cc b/chrome/browser/sync/glue/session_model_associator_unittest.cc index e04b02a..b6c5986 100644 --- a/chrome/browser/sync/glue/session_model_associator_unittest.cc +++ b/chrome/browser/sync/glue/session_model_associator_unittest.cc @@ -14,7 +14,7 @@ #include "testing/gtest/include/gtest/gtest.h" using browser_sync::SessionModelAssociator; -using browser_sync::ForeignSessionTracker; +using browser_sync::SyncedSessionTracker; namespace browser_sync { typedef testing::Test SessionModelAssociatorTest; @@ -58,8 +58,8 @@ TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) { window_s.set_selected_tab_index(1); std::string tag = "tag"; - ForeignSessionTracker tracker; - ForeignSession* session = tracker.GetForeignSession(tag); + SyncedSessionTracker tracker; + SyncedSession* session = tracker.GetSession(tag); SessionWindow* win = new SessionWindow(); session->windows.push_back(win); SessionModelAssociator::PopulateSessionWindowFromSpecifics( @@ -67,8 +67,8 @@ TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) { ASSERT_EQ(1U, win->tabs.size()); ASSERT_EQ(1, win->selected_tab_index); ASSERT_EQ(1, win->type); - ASSERT_EQ(1U, tracker.num_foreign_sessions()); - ASSERT_EQ(1U, tracker.num_foreign_tabs(std::string("tag"))); + ASSERT_EQ(1U, tracker.num_synced_sessions()); + ASSERT_EQ(1U, tracker.num_synced_tabs(std::string("tag"))); // We do this so that when the destructor for the tracker is called, it will // be able to delete the session, window, and tab. We can't delete these @@ -104,41 +104,41 @@ TEST_F(SessionModelAssociatorTest, PopulateSessionTab) { ASSERT_EQ(GURL("http://foo/1"), tab.navigations[0].virtual_url()); } -TEST_F(SessionModelAssociatorTest, ForeignSessionTracker) { +TEST_F(SessionModelAssociatorTest, SyncedSessionTracker) { const std::string tag1 = "tag"; const std::string tag2 = "tag2"; const std::string tag3 = "tag3"; - ForeignSessionTracker tracker; + SyncedSessionTracker tracker; ASSERT_TRUE(tracker.empty()); - ASSERT_EQ(0U, tracker.num_foreign_sessions()); - ASSERT_EQ(0U, tracker.num_foreign_tabs(tag1)); + ASSERT_EQ(0U, tracker.num_synced_sessions()); + ASSERT_EQ(0U, tracker.num_synced_tabs(tag1)); SessionTab* tab = tracker.GetSessionTab(tag1, 0, false); - ASSERT_EQ(1U, tracker.num_foreign_tabs(tag1)); - ASSERT_EQ(0U, tracker.num_foreign_sessions()); + ASSERT_EQ(1U, tracker.num_synced_tabs(tag1)); + ASSERT_EQ(0U, tracker.num_synced_sessions()); SessionTab* tab2 = tracker.GetSessionTab(tag1, 0, false); - ASSERT_EQ(1U, tracker.num_foreign_tabs(tag1)); - ASSERT_EQ(0U, tracker.num_foreign_sessions()); + ASSERT_EQ(1U, tracker.num_synced_tabs(tag1)); + ASSERT_EQ(0U, tracker.num_synced_sessions()); ASSERT_EQ(tab, tab2); tab2 = tracker.GetSessionTab(tag2, 0, false); - ASSERT_EQ(1U, tracker.num_foreign_tabs(tag1)); - ASSERT_EQ(1U, tracker.num_foreign_tabs(tag2)); - ASSERT_EQ(0U, tracker.num_foreign_sessions()); + ASSERT_EQ(1U, tracker.num_synced_tabs(tag1)); + ASSERT_EQ(1U, tracker.num_synced_tabs(tag2)); + ASSERT_EQ(0U, tracker.num_synced_sessions()); - ASSERT_FALSE(tracker.DeleteForeignSession(tag1)); - ASSERT_FALSE(tracker.DeleteForeignSession(tag3)); + ASSERT_FALSE(tracker.DeleteSession(tag1)); + ASSERT_FALSE(tracker.DeleteSession(tag3)); - ForeignSession* session = tracker.GetForeignSession(tag1); - ForeignSession* session2 = tracker.GetForeignSession(tag2); - ForeignSession* session3 = tracker.GetForeignSession(tag3); - ASSERT_EQ(3U, tracker.num_foreign_sessions()); + SyncedSession* session = tracker.GetSession(tag1); + SyncedSession* session2 = tracker.GetSession(tag2); + SyncedSession* session3 = tracker.GetSession(tag3); + ASSERT_EQ(3U, tracker.num_synced_sessions()); ASSERT_TRUE(session); ASSERT_TRUE(session2); ASSERT_TRUE(session3); ASSERT_NE(session, session2); ASSERT_NE(session2, session3); - ASSERT_TRUE(tracker.DeleteForeignSession(tag3)); - ASSERT_EQ(2U, tracker.num_foreign_sessions()); + ASSERT_TRUE(tracker.DeleteSession(tag3)); + ASSERT_EQ(2U, tracker.num_synced_sessions()); const SessionTab *tab_ptr; ASSERT_TRUE(tracker.LookupSessionTab(tag1, 0, &tab_ptr)); @@ -149,13 +149,13 @@ TEST_F(SessionModelAssociatorTest, ForeignSessionTracker) { ASSERT_EQ(0U, windows.size()); // The sessions don't have valid windows, lookup should not succeed. - std::vector<const ForeignSession*> sessions; + std::vector<const SyncedSession*> sessions; ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions)); tracker.clear(); - ASSERT_EQ(0U, tracker.num_foreign_tabs(tag1)); - ASSERT_EQ(0U, tracker.num_foreign_tabs(tag2)); - ASSERT_EQ(0U, tracker.num_foreign_sessions()); + ASSERT_EQ(0U, tracker.num_synced_tabs(tag1)); + ASSERT_EQ(0U, tracker.num_synced_tabs(tag2)); + ASSERT_EQ(0U, tracker.num_synced_sessions()); } } // namespace browser_sync diff --git a/chrome/browser/sync/glue/synced_session_tracker.cc b/chrome/browser/sync/glue/synced_session_tracker.cc new file mode 100644 index 0000000..7e5ce3c --- /dev/null +++ b/chrome/browser/sync/glue/synced_session_tracker.cc @@ -0,0 +1,140 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/glue/synced_session_tracker.h" +#include "chrome/browser/sync/glue/session_model_associator.h" + +namespace browser_sync { + + +SyncedSessionTracker::SyncedSessionTracker() { +} + +SyncedSessionTracker::~SyncedSessionTracker() { + clear(); +} + +bool SyncedSessionTracker::LookupAllForeignSessions( + std::vector<const SyncedSession*>* sessions) { + DCHECK(sessions); + // Fill vector of sessions from our synced session map. + for (SyncedSessionMap::const_iterator i = + synced_session_map_.begin(); i != synced_session_map_.end(); ++i) { + // Only include foreign sessions with open tabs. + SyncedSession* foreign_session = i->second; + if (i->first != local_session_tag_ && + !foreign_session->windows.empty() && + !SessionModelAssociator::SessionWindowHasNoTabsToSync( + *foreign_session->windows[0])) { + sessions->push_back(foreign_session); + } + } + + return !sessions->empty(); +} + +bool SyncedSessionTracker::LookupSessionWindows( + const std::string& session_tag, + std::vector<SessionWindow*>* windows) { + DCHECK(windows); + SyncedSessionMap::iterator iter = synced_session_map_.find(session_tag); + if (iter == synced_session_map_.end()) + return false; + *windows = iter->second->windows; + return true; +} + +bool SyncedSessionTracker::LookupSessionTab( + const std::string& tag, + SessionID::id_type tab_id, + const SessionTab** tab) { + DCHECK(tab); + if (synced_tab_map_.find(tag) == synced_tab_map_.end()) { + // We have no record of this session. + *tab = NULL; + return false; + } + if (synced_tab_map_[tag]->find(tab_id) == synced_tab_map_[tag]->end()) { + // We have no record of this tab. + *tab = NULL; + return false; + } + *tab = (*synced_tab_map_[tag])[tab_id]; + return true; +} + +SyncedSession* SyncedSessionTracker::GetSession( + const std::string& session_tag) { + scoped_ptr<SyncedSession> synced_session; + if (synced_session_map_.find(session_tag) != + synced_session_map_.end()) { + synced_session.reset(synced_session_map_[session_tag]); + } else { + synced_session.reset(new SyncedSession); + synced_session->session_tag = session_tag; + synced_session_map_[session_tag] = synced_session.get(); + } + DCHECK(synced_session.get()); + return synced_session.release(); +} + +bool SyncedSessionTracker::DeleteSession( + const std::string& session_tag) { + SyncedSessionMap::iterator iter = + synced_session_map_.find(session_tag); + if (iter != synced_session_map_.end()) { + delete iter->second; // Delete the SyncedSession object. + synced_session_map_.erase(iter); + return true; + } else { + return false; + } +} + +SessionTab* SyncedSessionTracker::GetSessionTab( + const std::string& session_tag, + SessionID::id_type tab_id, + bool has_window) { + if (synced_tab_map_.find(session_tag) == synced_tab_map_.end()) + synced_tab_map_[session_tag] = new IDToSessionTabMap; + scoped_ptr<SessionTab> tab; + IDToSessionTabMap::iterator iter = + synced_tab_map_[session_tag]->find(tab_id); + if (iter != synced_tab_map_[session_tag]->end()) { + tab.reset(iter->second); + if (has_window) // This tab is linked to a window, so it's not an orphan. + unmapped_tabs_.erase(tab.get()); + VLOG(1) << "Associating " << session_tag << "'s seen tab " << + tab_id << " at " << tab.get(); + } else { + tab.reset(new SessionTab()); + (*synced_tab_map_[session_tag])[tab_id] = tab.get(); + if (!has_window) // This tab is not linked to a window, it's an orphan. + unmapped_tabs_.insert(tab.get()); + VLOG(1) << "Associating " << session_tag << "'s new tab " << + tab_id << " at " << tab.get(); + } + DCHECK(tab.get()); + return tab.release(); +} + +void SyncedSessionTracker::clear() { + // Delete SyncedSession objects (which also deletes all their windows/tabs). + STLDeleteContainerPairSecondPointers(synced_session_map_.begin(), + synced_session_map_.end()); + synced_session_map_.clear(); + + // Delete IDToSessTab maps. Does not delete the SessionTab objects, because + // they should already be referenced through synced_session_map_. + STLDeleteContainerPairSecondPointers(synced_tab_map_.begin(), + synced_tab_map_.end()); + synced_tab_map_.clear(); + + // Go through and delete any tabs we had allocated but had not yet placed into + // a SyncedSessionobject. + STLDeleteContainerPointers(unmapped_tabs_.begin(), unmapped_tabs_.end()); + unmapped_tabs_.clear(); +} + +} // namespace browser_sync diff --git a/chrome/browser/sync/glue/synced_session_tracker.h b/chrome/browser/sync/glue/synced_session_tracker.h new file mode 100644 index 0000000..c0088bd --- /dev/null +++ b/chrome/browser/sync/glue/synced_session_tracker.h @@ -0,0 +1,125 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_ +#define CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_ +#pragma once + +#include <map> +#include <set> +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/scoped_vector.h" +#include "chrome/browser/sessions/session_id.h" +#include "chrome/browser/sessions/session_types.h" + +namespace browser_sync { + +// Class to manage synced sessions. The tracker will own all SyncedSession +// and SessionTab objects it creates, and deletes them appropriately on +// destruction. +// Note: SyncedSession objects are created for all synced sessions, including +// the local session (whose tag we maintain separately). +class SyncedSessionTracker { + public: + SyncedSessionTracker(); + ~SyncedSessionTracker(); + + // 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). + // Returns true if we had foreign sessions to fill it with, false otherwise. + bool LookupAllForeignSessions(std::vector<const SyncedSession*>* sessions); + + // Attempts to look up the session windows associatd with the session given + // by |session_tag|. + // If lookup succeeds: + // - Fills windows with the SessionWindow pointers, returns true. + // Else + // - Returns false. + bool LookupSessionWindows(const std::string& session_tag, + std::vector<SessionWindow*>* windows); + + // Attempts to look up the tab associated with the given tag and tab id. + // If lookup succeeds: + // - Sets tab to point to the SessionTab, and returns true. + // Else + // - Returns false, tab is set to NULL. + bool LookupSessionTab(const std::string& session_tag, + SessionID::id_type tab_id, + const SessionTab** tab); + + // Returns a pointer to the SyncedSession object associated with session_tag. + // If none exists, creates one and returns its pointer. + 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); + + // Returns a pointer to the SessionTab object associated with |tab_id| for + // the session specified with |session_tag|. If none exists, creates one and + // returns its pointer. + // |has_window| determines if newly created tabs are added to the pool of + // orphaned tabs (those which can't be reached by traversing sessions). + SessionTab* GetSessionTab(const std::string& session_tag, + SessionID::id_type tab_id, + bool has_window); + + // Free the memory for all dynamically allocated objects and clear the + // tracking structures. + void clear(); + + inline bool empty() { + return synced_tab_map_.empty() && synced_session_map_.empty(); + } + + // Includes both foreign sessions and the local session. + inline size_t num_synced_sessions() { + return synced_session_map_.size(); + } + + // Returns the number of tabs associated with the specified session tag. + inline size_t num_synced_tabs(const std::string& session_tag) { + if (synced_tab_map_.find(session_tag) != synced_tab_map_.end()) { + return synced_tab_map_[session_tag]->size(); + } else { + return 0; + } + } + private: + // Datatypes for accessing session data. + typedef std::map<SessionID::id_type, SessionTab*> IDToSessionTabMap; + typedef std::map<std::string, IDToSessionTabMap*> SyncedTabMap; + typedef std::map<std::string, SyncedSession*> SyncedSessionMap; + + // Per client mapping of tab id's to their SessionTab objects. + // Key: session tag. + // Value: Tab id to SessionTab map pointer. + SyncedTabMap synced_tab_map_; + + // Per client mapping synced session objects. + // Key: session tag. + // Value: SyncedSession object pointer. + SyncedSessionMap synced_session_map_; + + // The set of tabs that we have seen, and created SessionTab objects for, but + // have not yet mapped to SyncedSessions. These are temporarily orphaned + // tabs, and won't be deleted if we delete synced_session_map_. + std::set<SessionTab*> unmapped_tabs_; + + // The tag for this machine's local session, so we can distinguish the foreign + // sessions. + std::string local_session_tag_; + + DISALLOW_COPY_AND_ASSIGN(SyncedSessionTracker); +}; + +} // namespace browser_sync + +#endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_TRACKER_H_ diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc index 8f79f67..dac1129 100644 --- a/chrome/browser/sync/profile_sync_service_session_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc @@ -231,7 +231,7 @@ TEST_F(ProfileSyncServiceSessionTest, MAYBE_WriteFilledSessionToNode) { ASSERT_NE(sync_api::kInvalidId, sync_id); // Check that this machine's data is not included in the foreign windows. - std::vector<const ForeignSession*> foreign_sessions; + std::vector<const SyncedSession*> foreign_sessions; model_associator_->GetAllForeignSessions(&foreign_sessions); ASSERT_EQ(foreign_sessions.size(), 0U); @@ -303,14 +303,14 @@ TEST_F(ProfileSyncServiceSessionTest, WriteForeignSessionToNode) { } // Check that the foreign session was associated and retrieve the data. - std::vector<const ForeignSession*> foreign_sessions; + std::vector<const SyncedSession*> foreign_sessions; model_associator_->GetAllForeignSessions(&foreign_sessions); ASSERT_EQ(1U, foreign_sessions.size()); - ASSERT_EQ(machine_tag, foreign_sessions[0]->foreign_session_tag); + ASSERT_EQ(machine_tag, foreign_sessions[0]->session_tag); ASSERT_EQ(1U, foreign_sessions[0]->windows.size()); ASSERT_EQ(1U, foreign_sessions[0]->windows[0]->tabs.size()); ASSERT_EQ(1U, foreign_sessions[0]->windows[0]->tabs[0]->navigations.size()); - ASSERT_EQ(foreign_sessions[0]->foreign_session_tag, machine_tag); + ASSERT_EQ(foreign_sessions[0]->session_tag, machine_tag); ASSERT_EQ(1, foreign_sessions[0]->windows[0]->selected_tab_index); ASSERT_EQ(1, foreign_sessions[0]->windows[0]->type); ASSERT_EQ(13, foreign_sessions[0]->windows[0]->tabs[0]->tab_visual_index); diff --git a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc index 33d6801..d16b9e1 100644 --- a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc +++ b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc @@ -87,14 +87,14 @@ SessionModelAssociator* ForeignSessionHandler::GetModelAssociator() { void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) { SessionModelAssociator* associator = GetModelAssociator(); - std::vector<const ForeignSession*> sessions; + std::vector<const SyncedSession*> sessions; if (associator == NULL) { // Called before associator created, exit. return; } - // Note: we don't own the ForeignSessions themselves. + // Note: we don't own the SyncedSessions themselves. if (!associator->GetAllForeignSessions(&sessions)) { LOG(ERROR) << "ForeignSessionHandler failed to get session data from" "SessionModelAssociator."; @@ -102,10 +102,10 @@ void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) { } int added_count = 0; ListValue session_list; - for (std::vector<const ForeignSession*>::const_iterator i = + for (std::vector<const SyncedSession*>::const_iterator i = sessions.begin(); i != sessions.end() && added_count < kMaxSessionsToShow; ++i) { - const ForeignSession* foreign_session = *i; + const SyncedSession* foreign_session = *i; scoped_ptr<ListValue> window_list(new ListValue()); for (std::vector<SessionWindow*>::const_iterator it = foreign_session->windows.begin(); it != foreign_session->windows.end(); @@ -113,8 +113,7 @@ void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) { SessionWindow* window = *it; scoped_ptr<DictionaryValue> window_data(new DictionaryValue()); if (SessionWindowToValue(*window, window_data.get())) { - window_data->SetString("sessionTag", - foreign_session->foreign_session_tag); + window_data->SetString("sessionTag", foreign_session->session_tag); // Give ownership to |list_value|. window_list->Append(window_data.release()); diff --git a/chrome/browser/ui/webui/sessions_ui.cc b/chrome/browser/ui/webui/sessions_ui.cc index 58599fa..ccedc85 100644 --- a/chrome/browser/ui/webui/sessions_ui.cc +++ b/chrome/browser/ui/webui/sessions_ui.cc @@ -117,15 +117,15 @@ class SessionsDOMHandler : public WebUIMessageHandler { ListValue* window_list); // Appends each entry in |sessions| to |session_list| as a DictonaryValue. - void GetSessionList(const std::vector<const ForeignSession*>& sessions, + void GetSessionList(const std::vector<const SyncedSession*>& sessions, ListValue* session_list); // Traverses all tabs in |sessions| and adds them to |all_tabs|. - void GetAllTabs(const std::vector<const ForeignSession*>& sessions, + void GetAllTabs(const std::vector<const SyncedSession*>& sessions, std::vector<SessionTab*>* all_tabs); // Creates a "magic" list of tabs from all the sessions. - void CreateMagicTabList(const std::vector<const ForeignSession*>& sessions, + void CreateMagicTabList(const std::vector<const SyncedSession*>& sessions, ListValue* tab_list); DISALLOW_COPY_AND_ASSIGN(SessionsDOMHandler); @@ -204,13 +204,13 @@ void SessionsDOMHandler::GetWindowList( } void SessionsDOMHandler::GetSessionList( - const std::vector<const ForeignSession*>& sessions, + const std::vector<const SyncedSession*>& sessions, ListValue* session_list) { - for (std::vector<const ForeignSession*>::const_iterator it = + for (std::vector<const SyncedSession*>::const_iterator it = sessions.begin(); it != sessions.end(); ++it) { - const ForeignSession* session = *it; + const SyncedSession* session = *it; scoped_ptr<DictionaryValue> session_data(new DictionaryValue()); - session_data->SetString("tag", session->foreign_session_tag); + session_data->SetString("tag", session->session_tag); scoped_ptr<ListValue> window_list(new ListValue()); GetWindowList(session->windows, window_list.get()); session_data->Set("windows", window_list.release()); @@ -219,7 +219,7 @@ void SessionsDOMHandler::GetSessionList( } void SessionsDOMHandler::GetAllTabs( - const std::vector<const ForeignSession*>& sessions, + const std::vector<const SyncedSession*>& sessions, std::vector<SessionTab*>* all_tabs) { for (size_t i = 0; i < sessions.size(); i++) { const std::vector<SessionWindow*>& windows = sessions[i]->windows; @@ -236,7 +236,7 @@ bool CompareTabsByTimestamp(SessionTab* lhs, SessionTab* rhs) { } void SessionsDOMHandler::CreateMagicTabList( - const std::vector<const ForeignSession*>& sessions, + const std::vector<const SyncedSession*>& sessions, ListValue* tab_list) { std::vector<SessionTab*> all_tabs; GetAllTabs(sessions, &all_tabs); @@ -259,7 +259,7 @@ void SessionsDOMHandler::UpdateUI() { browser_sync::SessionModelAssociator* associator = GetModelAssociator(); // Make sure the associator has been created. if (associator) { - std::vector<const ForeignSession*> sessions; + std::vector<const SyncedSession*> sessions; if (associator->GetAllForeignSessions(&sessions)) { GetSessionList(sessions, &session_list); CreateMagicTabList(sessions, &magic_list); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 180fc70..fe5c058 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1975,8 +1975,6 @@ 'browser/sync/glue/extension_sync_traits.h', 'browser/sync/glue/extension_util.cc', 'browser/sync/glue/extension_util.h', - 'browser/sync/glue/foreign_session_tracker.cc', - 'browser/sync/glue/foreign_session_tracker.h', 'browser/sync/glue/frontend_data_type_controller.cc', 'browser/sync/glue/frontend_data_type_controller.h', 'browser/sync/glue/generic_change_processor.cc', @@ -2008,6 +2006,8 @@ 'browser/sync/glue/syncable_service_adapter.h', 'browser/sync/glue/sync_backend_host.cc', 'browser/sync/glue/sync_backend_host.h', + 'browser/sync/glue/synced_session_tracker.cc', + 'browser/sync/glue/synced_session_tracker.h', 'browser/sync/glue/theme_change_processor.cc', 'browser/sync/glue/theme_change_processor.h', 'browser/sync/glue/theme_data_type_controller.cc', diff --git a/chrome/test/live_sync/live_sessions_sync_test.cc b/chrome/test/live_sync/live_sessions_sync_test.cc index 9960c19..da04a59 100644 --- a/chrome/test/live_sync/live_sessions_sync_test.cc +++ b/chrome/test/live_sync/live_sessions_sync_test.cc @@ -75,7 +75,7 @@ void TestSessionService::DoReadWindows() { void TestSessionService::OnGotSession(int handle, std::vector<SessionWindow*>* windows) { - scoped_ptr<ForeignSession> foreign_session(new ForeignSession()); + scoped_ptr<SyncedSession> foreign_session(new SyncedSession()); for (size_t w = 0; w < windows->size(); ++w) { const SessionWindow& window = *windows->at(w); scoped_ptr<SessionWindow> new_window(new SessionWindow()); @@ -179,7 +179,7 @@ int LiveSessionsSyncTest::GetNumWindows(int index) { } int LiveSessionsSyncTest::GetNumForeignSessions(int index) { - std::vector<const ForeignSession*> sessions; + std::vector<const SyncedSession*> sessions; if (!GetProfile(index)->GetProfileSyncService()-> GetSessionModelAssociator()->GetAllForeignSessions(&sessions)) return 0; @@ -188,7 +188,7 @@ int LiveSessionsSyncTest::GetNumForeignSessions(int index) { bool LiveSessionsSyncTest::GetSessionData( int index, - std::vector<const ForeignSession*>* sessions) { + std::vector<const SyncedSession*>* sessions) { if (!GetProfile(index)->GetProfileSyncService()-> GetSessionModelAssociator()->GetAllForeignSessions(sessions)) return false; @@ -221,8 +221,8 @@ void LiveSessionsSyncTest::SortSessionWindows( // static bool LiveSessionsSyncTest::CompareForeignSessions( - const ForeignSession* lhs, - const ForeignSession* rhs) { + const SyncedSession* lhs, + const SyncedSession* rhs) { if (!lhs || !rhs || lhs->windows.size() < 1 || @@ -235,7 +235,7 @@ bool LiveSessionsSyncTest::CompareForeignSessions( } void LiveSessionsSyncTest::SortForeignSessions( - std::vector<const ForeignSession*>* sessions) { + std::vector<const SyncedSession*>* sessions) { std::sort(sessions->begin(), sessions->end(), LiveSessionsSyncTest::CompareForeignSessions); } @@ -283,7 +283,7 @@ bool LiveSessionsSyncTest::WindowsMatch( bool LiveSessionsSyncTest::CheckForeignSessionsAgainst( int index, const std::vector<std::vector<SessionWindow*>* >& windows) { - std::vector<const ForeignSession*> sessions; + std::vector<const SyncedSession*> sessions; if (!GetSessionData(index, &sessions)) return false; if ((size_t)(num_clients()-1) != sessions.size()) diff --git a/chrome/test/live_sync/live_sessions_sync_test.h b/chrome/test/live_sync/live_sessions_sync_test.h index d15e726..317adbe 100644 --- a/chrome/test/live_sync/live_sessions_sync_test.h +++ b/chrome/test/live_sync/live_sessions_sync_test.h @@ -63,7 +63,7 @@ class TestSessionService // at destruction time so that complex tests can keep comparing against old // SessionWindow data. Note that since we're constantly creating new foreign // sessions, we don't have to worry about duplicates. - ScopedVector<ForeignSession> foreign_sessions_; + ScopedVector<SyncedSession> foreign_sessions_; // Barrier for saving session. base::WaitableEvent done_saving_; @@ -130,7 +130,7 @@ class LiveSessionsSyncTest : public LiveSyncTest { // Fills the sessions vector with the model associator's foreign session data. // Caller owns |sessions|, but not ForeignSession objects within. - bool GetSessionData(int index, std::vector<const ForeignSession*>* sessions) + bool GetSessionData(int index, std::vector<const SyncedSession*>* sessions) WARN_UNUSED_RESULT; // Compare session windows based on their first tab's url. @@ -144,11 +144,11 @@ class LiveSessionsSyncTest : public LiveSyncTest { // Compares a foreign session based on the first session window. // Returns true based on the comparison of the session windows. static bool CompareForeignSessions( - const ForeignSession* lhs, - const ForeignSession* rhs); + const SyncedSession* lhs, + const SyncedSession* rhs); // Sort a foreign session vector using our custom foreign session comparator. - void SortForeignSessions(std::vector<const ForeignSession*>* sessions); + void SortForeignSessions(std::vector<const SyncedSession*>* sessions); // Compares two tab navigations base on the parameters we sync. // (Namely, we don't sync state or type mask) diff --git a/chrome/test/live_sync/single_client_live_sessions_sync_test.cc b/chrome/test/live_sync/single_client_live_sessions_sync_test.cc index 4cefc6d..cbbf1b7 100644 --- a/chrome/test/live_sync/single_client_live_sessions_sync_test.cc +++ b/chrome/test/live_sync/single_client_live_sessions_sync_test.cc @@ -20,7 +20,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientLiveSessionsSyncTest, Sanity) { "Waiting for session change.")); // Get foreign session data from client 0. - std::vector<const ForeignSession*> sessions; + std::vector<const SyncedSession*> sessions; ASSERT_FALSE(GetSessionData(0, &sessions)); ASSERT_EQ(0U, sessions.size()); diff --git a/chrome/test/live_sync/two_client_live_sessions_sync_test.cc b/chrome/test/live_sync/two_client_live_sessions_sync_test.cc index 6e0c09a..954b141 100644 --- a/chrome/test/live_sync/two_client_live_sessions_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_sessions_sync_test.cc @@ -26,7 +26,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, SingleClientChanged) { ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); // Get foreign session data from client 1. - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(1, &sessions1)); // Verify client 1's foreign session matches client 0 current window. @@ -62,7 +62,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, // Get foreign session data from client 1. ASSERT_TRUE(IsEncrypted(1)); - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(1, &sessions1)); // Verify client 1's foreign session matches client 0 current window. @@ -102,8 +102,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, BothChanged) { ASSERT_TRUE(AwaitQuiescence()); // Get foreign session data from client 0 and 1. - std::vector<const ForeignSession*> sessions0; - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions0; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(0, &sessions0)); ASSERT_TRUE(GetSessionData(1, &sessions1)); @@ -144,7 +144,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, ASSERT_TRUE(IsEncrypted(0)); ASSERT_TRUE(IsEncrypted(1)); // Get foreign session data from client 0 and 1. - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(1, &sessions1)); // Verify client 1's foreign session matches client 0's current window and @@ -188,7 +188,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, ASSERT_TRUE(IsEncrypted(0)); ASSERT_TRUE(IsEncrypted(1)); // Get foreign session data from client 0 and 1. - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(1, &sessions1)); // Verify client 1's foreign session matches client 0's current window and @@ -237,8 +237,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, ASSERT_TRUE(IsEncrypted(1)); // The session data from client 1 got overwritten. As a result, client 0 // should have no foreign session data. - std::vector<const ForeignSession*> sessions0; - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions0; + std::vector<const SyncedSession*> sessions1; ASSERT_FALSE(GetSessionData(0, &sessions0)); ASSERT_FALSE(GetSessionData(1, &sessions1)); } @@ -279,8 +279,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, ASSERT_TRUE(IsEncrypted(1)); // Client 0's foreign data should match client 1's local data. Client 1's // foreign data is empty because client 0 did not open any tabs. - std::vector<const ForeignSession*> sessions0; - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions0; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(0, &sessions0)); ASSERT_FALSE(GetSessionData(1, &sessions1)); ASSERT_EQ(1U, sessions0.size()); @@ -327,8 +327,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, ASSERT_TRUE(IsEncrypted(0)); ASSERT_TRUE(IsEncrypted(1)); // Get foreign session data from client 0 and 1. - std::vector<const ForeignSession*> sessions0; - std::vector<const ForeignSession*> sessions1; + std::vector<const SyncedSession*> sessions0; + std::vector<const SyncedSession*> sessions1; ASSERT_TRUE(GetSessionData(0, &sessions0)); ASSERT_TRUE(GetSessionData(1, &sessions1)); |