Use SessionIDs by value instead of underlying type
No behavioral changes: we start a migration in SessionID's API to better
control their lifetime and avoid collisions. We now encourage client
code to pass SessionID instances by value and only rarely use
SessionID::id_type.
As a first example, sync codebase is migrated to the new API. A lot more
occurrences exist beyond sync, and will be addressed in follow-up
patches.
The new API also introduces the notion of invalid session IDs, which is
internally represented as -1: we do this because it's very common
throughout the codebase, and it seems preferrable to provide this
functionality on the SessionID class itself.
Bug: 823798
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I3516f6f49068b2102b780824dea90135c010e42c
Reviewed-on: https://chromium-review.googlesource.com/972041
Reviewed-by: Karan Bhatia <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Rohit Rao <[email protected]>
Reviewed-by: Bernhard Bauer <[email protected]>
Commit-Queue: Mikel Astiz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#546434}
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java
index 33c2fa4..7b2a80d 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java
@@ -244,9 +244,9 @@
private SessionWindow makeSessionWindow(int numTabs) {
SessionWindow.Builder windowBuilder =
- SessionWindow.newBuilder().setWindowId(0).setSelectedTabIndex(0);
+ SessionWindow.newBuilder().setWindowId(1).setSelectedTabIndex(0);
for (int i = 0; i < numTabs; i++) {
- windowBuilder.addTab(i); // Updates |windowBuilder| internal state.
+ windowBuilder.addTab(i + 1); // Updates |windowBuilder| internal state.
}
return windowBuilder.build();
}
@@ -270,7 +270,7 @@
.setSessionTag(tag)
.setTabNodeId(id)
.setTab(SessionTab.newBuilder()
- .setTabId(id)
+ .setTabId(id + 1)
.setCurrentNavigationIndex(0)
.addNavigation(TabNavigation.newBuilder()
.setVirtualUrl(url)
diff --git a/chrome/browser/android/foreign_session_helper.cc b/chrome/browser/android/foreign_session_helper.cc
index 9d07929..3ed8093 100644
--- a/chrome/browser/android/foreign_session_helper.cc
+++ b/chrome/browser/android/foreign_session_helper.cc
@@ -287,7 +287,7 @@
const sessions::SessionTab* session_tab;
if (!open_tabs->GetForeignTab(ConvertJavaStringToUTF8(env, session_tag),
- session_tab_id,
+ SessionID::FromSerializedValue(session_tab_id),
&session_tab)) {
LOG(ERROR) << "Failed to load foreign tab.";
return false;
diff --git a/chrome/browser/extensions/api/sessions/sessions_api.cc b/chrome/browser/extensions/api/sessions/sessions_api.cc
index 872c24eb..cc0b280 100644
--- a/chrome/browser/extensions/api/sessions/sessions_api.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_api.cc
@@ -496,7 +496,7 @@
const sessions::SessionTab* tab = NULL;
if (open_tabs->GetForeignTab(session_id.session_tag(),
- session_id.id(),
+ SessionID::FromSerializedValue(session_id.id()),
&tab)) {
TabStripModel* tab_strip = browser->tab_strip_model();
content::WebContents* contents = tab_strip->GetActiveWebContents();
diff --git a/chrome/browser/sync/glue/synced_tab_delegate_android.cc b/chrome/browser/sync/glue/synced_tab_delegate_android.cc
index bd16757..fbabe432 100644
--- a/chrome/browser/sync/glue/synced_tab_delegate_android.cc
+++ b/chrome/browser/sync/glue/synced_tab_delegate_android.cc
@@ -25,19 +25,19 @@
SyncedTabDelegateAndroid::~SyncedTabDelegateAndroid() {}
-SessionID::id_type SyncedTabDelegateAndroid::GetWindowId() const {
+SessionID SyncedTabDelegateAndroid::GetWindowId() const {
return tab_contents_delegate_->GetWindowId();
}
-SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const {
- return tab_android_->session_id().id();
+SessionID SyncedTabDelegateAndroid::GetSessionId() const {
+ return tab_android_->session_id();
}
bool SyncedTabDelegateAndroid::IsBeingDestroyed() const {
return tab_contents_delegate_->IsBeingDestroyed();
}
-SessionID::id_type SyncedTabDelegateAndroid::GetSourceTabID() const {
+SessionID SyncedTabDelegateAndroid::GetSourceTabID() const {
return tab_contents_delegate_->GetSourceTabID();
}
diff --git a/chrome/browser/sync/glue/synced_tab_delegate_android.h b/chrome/browser/sync/glue/synced_tab_delegate_android.h
index c6c1f9f..ddce125 100644
--- a/chrome/browser/sync/glue/synced_tab_delegate_android.h
+++ b/chrome/browser/sync/glue/synced_tab_delegate_android.h
@@ -32,10 +32,10 @@
~SyncedTabDelegateAndroid() override;
// SyncedTabDelegate:
- SessionID::id_type GetWindowId() const override;
- SessionID::id_type GetSessionId() const override;
+ SessionID GetWindowId() const override;
+ SessionID GetSessionId() const override;
bool IsBeingDestroyed() const override;
- SessionID::id_type GetSourceTabID() const override;
+ SessionID GetSourceTabID() const override;
std::string GetExtensionAppId() const override;
bool IsInitialBlankNavigation() const override;
int GetCurrentEntryIndex() const override;
diff --git a/chrome/browser/sync/glue/synced_window_delegate_android.cc b/chrome/browser/sync/glue/synced_window_delegate_android.cc
index 57183ba3..8fc1987 100644
--- a/chrome/browser/sync/glue/synced_window_delegate_android.cc
+++ b/chrome/browser/sync/glue/synced_window_delegate_android.cc
@@ -28,7 +28,7 @@
return !tab_model_->IsOffTheRecord();
}
-SessionID::id_type SyncedWindowDelegateAndroid::GetSessionId() const {
+SessionID SyncedWindowDelegateAndroid::GetSessionId() const {
return tab_model_->GetSessionId();
}
@@ -63,9 +63,9 @@
return tab ? tab->GetSyncedTabDelegate() : nullptr;
}
-SessionID::id_type SyncedWindowDelegateAndroid::GetTabIdAt(int index) const {
+SessionID SyncedWindowDelegateAndroid::GetTabIdAt(int index) const {
SyncedTabDelegate* tab = GetTabAt(index);
- return tab ? tab->GetSessionId() : -1;
+ return tab ? tab->GetSessionId() : SessionID::InvalidValue();
}
bool SyncedWindowDelegateAndroid::IsSessionRestoreInProgress() const {
diff --git a/chrome/browser/sync/glue/synced_window_delegate_android.h b/chrome/browser/sync/glue/synced_window_delegate_android.h
index 0d31d12..d7e094e5 100644
--- a/chrome/browser/sync/glue/synced_window_delegate_android.h
+++ b/chrome/browser/sync/glue/synced_window_delegate_android.h
@@ -25,7 +25,7 @@
// sync_sessions::SyncedWindowDelegate implementation.
bool HasWindow() const override;
- SessionID::id_type GetSessionId() const override;
+ SessionID GetSessionId() const override;
int GetTabCount() const override;
int GetActiveIndex() const override;
bool IsApp() const override;
@@ -33,7 +33,7 @@
bool IsTypePopup() const override;
bool IsTabPinned(const sync_sessions::SyncedTabDelegate* tab) const override;
sync_sessions::SyncedTabDelegate* GetTabAt(int index) const override;
- SessionID::id_type GetTabIdAt(int index) const override;
+ SessionID GetTabIdAt(int index) const override;
bool IsSessionRestoreInProgress() const override;
bool ShouldSync() const override;
diff --git a/chrome/browser/sync/glue/synced_window_delegates_getter_android.cc b/chrome/browser/sync/glue/synced_window_delegates_getter_android.cc
index 22382a9..18591fb 100644
--- a/chrome/browser/sync/glue/synced_window_delegates_getter_android.cc
+++ b/chrome/browser/sync/glue/synced_window_delegates_getter_android.cc
@@ -26,8 +26,8 @@
}
const SyncedWindowDelegate* SyncedWindowDelegatesGetterAndroid::FindById(
- SessionID::id_type session_id) {
- TabModel* tab_model = TabModelList::FindTabModelWithId(session_id);
+ SessionID session_id) {
+ TabModel* tab_model = TabModelList::FindTabModelWithId(session_id.id());
// In case we don't find the browser (e.g. for Developer Tools).
return tab_model ? tab_model->GetSyncedWindowDelegate() : nullptr;
diff --git a/chrome/browser/sync/glue/synced_window_delegates_getter_android.h b/chrome/browser/sync/glue/synced_window_delegates_getter_android.h
index 74b5ca1..c97afbe9 100644
--- a/chrome/browser/sync/glue/synced_window_delegates_getter_android.h
+++ b/chrome/browser/sync/glue/synced_window_delegates_getter_android.h
@@ -25,8 +25,7 @@
// SyncedWindowDelegatesGetter implementation
SyncedWindowDelegateMap GetSyncedWindowDelegates() override;
- const sync_sessions::SyncedWindowDelegate* FindById(
- SessionID::id_type id) override;
+ const sync_sessions::SyncedWindowDelegate* FindById(SessionID id) override;
private:
DISALLOW_COPY_AND_ASSIGN(SyncedWindowDelegatesGetterAndroid);
diff --git a/chrome/browser/sync/sessions/browser_list_router_helper_unittest.cc b/chrome/browser/sync/sessions/browser_list_router_helper_unittest.cc
index f366640..a292de5 100644
--- a/chrome/browser/sync/sessions/browser_list_router_helper_unittest.cc
+++ b/chrome/browser/sync/sessions/browser_list_router_helper_unittest.cc
@@ -33,11 +33,11 @@
const GURL& icon_url) override {}
std::vector<GURL>* seen_urls() { return &seen_urls_; }
- std::vector<SessionID::id_type>* seen_ids() { return &seen_ids_; }
+ std::vector<SessionID>* seen_ids() { return &seen_ids_; }
private:
std::vector<GURL> seen_urls_;
- std::vector<SessionID::id_type> seen_ids_;
+ std::vector<SessionID> seen_ids_;
};
class BrowserListRouterHelperTest : public BrowserWithTestWindowTest {
@@ -130,7 +130,7 @@
BrowserList::GetInstance()->SetLastActive(browser());
EXPECT_EQ(gurl_1, *handler_1.seen_urls()->rbegin());
- SessionID::id_type old_id = *handler_1.seen_ids()->rbegin();
+ SessionID old_id = *handler_1.seen_ids()->rbegin();
// Remove previous any observations from setup to make checking expectations
// easier below.
diff --git a/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.cc b/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.cc
index 474b964..62fc3f1 100644
--- a/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.cc
+++ b/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.cc
@@ -33,7 +33,7 @@
SyncSessionsWebContentsRouter* router)
: content::WebContentsObserver(web_contents),
router_(router),
- source_tab_id_(kInvalidTabID) {}
+ source_tab_id_(SessionID::InvalidValue()) {}
SyncSessionsRouterTabHelper::~SyncSessionsRouterTabHelper() {}
@@ -74,10 +74,11 @@
void SyncSessionsRouterTabHelper::SetSourceTabIdForChild(
content::WebContents* child_contents) {
- SessionID::id_type source_tab_id = SessionTabHelper::IdForTab(web_contents());
+ SessionID source_tab_id = SessionID::FromSerializedValue(
+ SessionTabHelper::IdForTab(web_contents()));
if (child_contents &&
SyncSessionsRouterTabHelper::FromWebContents(child_contents) &&
- child_contents != web_contents() && source_tab_id != kInvalidTabID) {
+ child_contents != web_contents() && source_tab_id.is_valid()) {
SyncSessionsRouterTabHelper::FromWebContents(child_contents)
->set_source_tab_id(source_tab_id);
}
diff --git a/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h b/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h
index aeb8aa7..a82b345b 100644
--- a/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h
+++ b/chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h
@@ -51,8 +51,8 @@
void SetSourceTabIdForChild(content::WebContents* child_contents);
// Get the tab id of the tab responsible for creating the tab this helper
- // corresponds to. Returns -1 if there is no such tab.
- SessionID::id_type source_tab_id() const { return source_tab_id_; }
+ // corresponds to. Returns an invalid ID if there is no such tab.
+ SessionID source_tab_id() const { return source_tab_id_; }
private:
friend class content::WebContentsUserData<SyncSessionsRouterTabHelper>;
@@ -62,7 +62,7 @@
// Set the tab id of the tab reponsible for creating the tab this helper
// corresponds to.
- void set_source_tab_id(const SessionID::id_type id) { source_tab_id_ = id; }
+ void set_source_tab_id(SessionID id) { source_tab_id_ = id; }
void NotifyRouter(bool page_load_completed = false);
@@ -74,7 +74,7 @@
// * From context menu, "Open link in new window".
// * Ctrl-click.
// * Click on a link with target='_blank'.
- SessionID::id_type source_tab_id_;
+ SessionID source_tab_id_;
DISALLOW_COPY_AND_ASSIGN(SyncSessionsRouterTabHelper);
};
diff --git a/chrome/browser/sync/test/integration/sessions_helper.cc b/chrome/browser/sync/test/integration/sessions_helper.cc
index 3dfce0e..b78e14480 100644
--- a/chrome/browser/sync/test/integration/sessions_helper.cc
+++ b/chrome/browser/sync/test/integration/sessions_helper.cc
@@ -242,7 +242,7 @@
new_tab->navigations.begin());
new_window->wrapped_window.tabs.push_back(std::move(new_tab));
}
- auto id = new_window->wrapped_window.window_id.id();
+ auto id = new_window->wrapped_window.window_id;
(*local_windows)[id] = std::move(new_window);
}
diff --git a/chrome/browser/sync/test/integration/sessions_helper.h b/chrome/browser/sync/test/integration/sessions_helper.h
index 1e99bea..c28391a 100644
--- a/chrome/browser/sync/test/integration/sessions_helper.h
+++ b/chrome/browser/sync/test/integration/sessions_helper.h
@@ -24,10 +24,9 @@
using SyncedSessionVector = std::vector<const sync_sessions::SyncedSession*>;
using SessionWindowMap =
- std::map<SessionID::id_type, sync_sessions::SyncedSessionWindow*>;
+ std::map<SessionID, sync_sessions::SyncedSessionWindow*>;
using ScopedWindowMap =
- std::map<SessionID::id_type,
- std::unique_ptr<sync_sessions::SyncedSessionWindow>>;
+ std::map<SessionID, std::unique_ptr<sync_sessions::SyncedSessionWindow>>;
// Copies the local session windows of profile at |index| to |local_windows|.
// Returns true if successful.
diff --git a/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc b/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
index f4ecb6dc..3872aeac 100644
--- a/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
@@ -375,7 +375,7 @@
sync_sessions::SyncSessionsRouterTabHelper* new_tab_helper =
sync_sessions::SyncSessionsRouterTabHelper::FromWebContents(
new_tab_contents);
- EXPECT_EQ(new_tab_helper->source_tab_id(), source_tab_id);
+ EXPECT_EQ(new_tab_helper->source_tab_id().id(), source_tab_id);
}
void DumpSessionsOnServer(fake_server::FakeServer* fake_server) {
diff --git a/chrome/browser/ui/android/tab_model/android_live_tab_context.cc b/chrome/browser/ui/android/tab_model/android_live_tab_context.cc
index 37c849f2..fd30458 100644
--- a/chrome/browser/ui/android/tab_model/android_live_tab_context.cc
+++ b/chrome/browser/ui/android/tab_model/android_live_tab_context.cc
@@ -20,8 +20,8 @@
void AndroidLiveTabContext::ShowBrowserWindow() {
}
-const SessionID& AndroidLiveTabContext::GetSessionID() const {
- return tab_model_->SessionId();
+SessionID AndroidLiveTabContext::GetSessionID() const {
+ return tab_model_->GetSessionId();
}
int AndroidLiveTabContext::GetTabCount() const {
diff --git a/chrome/browser/ui/android/tab_model/android_live_tab_context.h b/chrome/browser/ui/android/tab_model/android_live_tab_context.h
index a166dff..50d844e1 100644
--- a/chrome/browser/ui/android/tab_model/android_live_tab_context.h
+++ b/chrome/browser/ui/android/tab_model/android_live_tab_context.h
@@ -26,7 +26,7 @@
// Overridden from LiveTabContext:
void ShowBrowserWindow() override;
- const SessionID& GetSessionID() const override;
+ SessionID GetSessionID() const override;
int GetTabCount() const override;
int GetSelectedIndex() const override;
std::string GetAppName() const override;
diff --git a/chrome/browser/ui/android/tab_model/tab_model.cc b/chrome/browser/ui/android/tab_model/tab_model.cc
index f4c5e392..b435c4fb 100644
--- a/chrome/browser/ui/android/tab_model/tab_model.cc
+++ b/chrome/browser/ui/android/tab_model/tab_model.cc
@@ -61,11 +61,7 @@
return synced_window_delegate_.get();
}
-SessionID::id_type TabModel::GetSessionId() const {
- return session_id_.id();
-}
-
-const SessionID& TabModel::SessionId() const {
+SessionID TabModel::GetSessionId() const {
return session_id_;
}
diff --git a/chrome/browser/ui/android/tab_model/tab_model.h b/chrome/browser/ui/android/tab_model/tab_model.h
index 4dc93e83..80ef5c0 100644
--- a/chrome/browser/ui/android/tab_model/tab_model.h
+++ b/chrome/browser/ui/android/tab_model/tab_model.h
@@ -39,8 +39,7 @@
virtual Profile* GetProfile() const;
virtual bool IsOffTheRecord() const;
virtual sync_sessions::SyncedWindowDelegate* GetSyncedWindowDelegate() const;
- virtual SessionID::id_type GetSessionId() const;
- virtual const SessionID& SessionId() const;
+ virtual SessionID GetSessionId() const;
virtual sessions::LiveTabContext* GetLiveTabContext() const;
virtual int GetTabCount() const = 0;
diff --git a/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc b/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc
index af04609..5bb7320c 100644
--- a/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc
+++ b/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc
@@ -71,7 +71,8 @@
// Tab#initialize() should have been called by now otherwise we can't push
// the window id.
TabAndroid* tab = TabAndroid::GetNativeTab(env, jtab);
- if (tab) tab->SetWindowSessionID(GetSessionId());
+ if (tab)
+ tab->SetWindowSessionID(GetSessionId().id());
}
int TabModelJniBridge::GetTabCount() const {
diff --git a/chrome/browser/ui/android/tab_model/tab_model_list.cc b/chrome/browser/ui/android/tab_model/tab_model_list.cc
index f60b966..7e02839 100644
--- a/chrome/browser/ui/android/tab_model/tab_model_list.cc
+++ b/chrome/browser/ui/android/tab_model/tab_model_list.cc
@@ -83,7 +83,7 @@
SessionID::id_type desired_id) {
for (TabModelList::const_iterator i = TabModelList::begin();
i != TabModelList::end(); i++) {
- if ((*i)->GetSessionId() == desired_id)
+ if ((*i)->GetSessionId().id() == desired_id)
return *i;
}
diff --git a/chrome/browser/ui/browser_live_tab_context.cc b/chrome/browser/ui/browser_live_tab_context.cc
index 26dc280..6268760e 100644
--- a/chrome/browser/ui/browser_live_tab_context.cc
+++ b/chrome/browser/ui/browser_live_tab_context.cc
@@ -29,7 +29,7 @@
browser_->window()->Show();
}
-const SessionID& BrowserLiveTabContext::GetSessionID() const {
+SessionID BrowserLiveTabContext::GetSessionID() const {
return browser_->session_id();
}
diff --git a/chrome/browser/ui/browser_live_tab_context.h b/chrome/browser/ui/browser_live_tab_context.h
index 8e7bf16..6d5b5ec 100644
--- a/chrome/browser/ui/browser_live_tab_context.h
+++ b/chrome/browser/ui/browser_live_tab_context.h
@@ -33,7 +33,7 @@
// Overridden from LiveTabContext:
void ShowBrowserWindow() override;
- const SessionID& GetSessionID() const override;
+ SessionID GetSessionID() const override;
int GetTabCount() const override;
int GetSelectedIndex() const override;
std::string GetAppName() const override;
diff --git a/chrome/browser/ui/sync/browser_synced_window_delegate.cc b/chrome/browser/ui/sync/browser_synced_window_delegate.cc
index 26f812a..d88aa37 100644
--- a/chrome/browser/ui/sync/browser_synced_window_delegate.cc
+++ b/chrome/browser/ui/sync/browser_synced_window_delegate.cc
@@ -34,7 +34,7 @@
browser_->tab_strip_model()->GetWebContentsAt(index));
}
-SessionID::id_type BrowserSyncedWindowDelegate::GetTabIdAt(int index) const {
+SessionID BrowserSyncedWindowDelegate::GetTabIdAt(int index) const {
return GetTabAt(index)->GetSessionId();
}
@@ -42,8 +42,8 @@
return browser_->window() != NULL;
}
-SessionID::id_type BrowserSyncedWindowDelegate::GetSessionId() const {
- return browser_->session_id().id();
+SessionID BrowserSyncedWindowDelegate::GetSessionId() const {
+ return browser_->session_id();
}
int BrowserSyncedWindowDelegate::GetTabCount() const {
diff --git a/chrome/browser/ui/sync/browser_synced_window_delegate.h b/chrome/browser/ui/sync/browser_synced_window_delegate.h
index a75a817..ad68a11 100644
--- a/chrome/browser/ui/sync/browser_synced_window_delegate.h
+++ b/chrome/browser/ui/sync/browser_synced_window_delegate.h
@@ -25,7 +25,7 @@
// SyncedWindowDelegate:
bool HasWindow() const override;
- SessionID::id_type GetSessionId() const override;
+ SessionID GetSessionId() const override;
int GetTabCount() const override;
int GetActiveIndex() const override;
bool IsApp() const override;
@@ -33,7 +33,7 @@
bool IsTypePopup() const override;
bool IsTabPinned(const sync_sessions::SyncedTabDelegate* tab) const override;
sync_sessions::SyncedTabDelegate* GetTabAt(int index) const override;
- SessionID::id_type GetTabIdAt(int index) const override;
+ SessionID GetTabIdAt(int index) const override;
bool IsSessionRestoreInProgress() const override;
bool ShouldSync() const override;
diff --git a/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc b/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc
index b43e07b..0963c3b 100644
--- a/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc
+++ b/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc
@@ -30,8 +30,8 @@
}
const sync_sessions::SyncedWindowDelegate*
-BrowserSyncedWindowDelegatesGetter::FindById(SessionID::id_type id) {
- Browser* browser = chrome::FindBrowserWithID(id);
+BrowserSyncedWindowDelegatesGetter::FindById(SessionID id) {
+ Browser* browser = chrome::FindBrowserWithID(id.id());
return (browser != nullptr) ? browser->synced_window_delegate() : nullptr;
}
diff --git a/chrome/browser/ui/sync/browser_synced_window_delegates_getter.h b/chrome/browser/ui/sync/browser_synced_window_delegates_getter.h
index a8fcbdf..c10a94f 100644
--- a/chrome/browser/ui/sync/browser_synced_window_delegates_getter.h
+++ b/chrome/browser/ui/sync/browser_synced_window_delegates_getter.h
@@ -24,8 +24,7 @@
// SyncedWindowDelegatesGetter implementation
SyncedWindowDelegateMap GetSyncedWindowDelegates() override;
- const sync_sessions::SyncedWindowDelegate* FindById(
- SessionID::id_type id) override;
+ const sync_sessions::SyncedWindowDelegate* FindById(SessionID id) override;
private:
Profile* const profile_;
diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
index 3a7ec5e..d375597 100644
--- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
+++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
@@ -54,12 +54,12 @@
TabContentsSyncedTabDelegate::~TabContentsSyncedTabDelegate() {}
-SessionID::id_type TabContentsSyncedTabDelegate::GetWindowId() const {
- return SessionTabHelper::FromWebContents(web_contents_)->window_id().id();
+SessionID TabContentsSyncedTabDelegate::GetWindowId() const {
+ return SessionTabHelper::FromWebContents(web_contents_)->window_id();
}
-SessionID::id_type TabContentsSyncedTabDelegate::GetSessionId() const {
- return SessionTabHelper::FromWebContents(web_contents_)->session_id().id();
+SessionID TabContentsSyncedTabDelegate::GetSessionId() const {
+ return SessionTabHelper::FromWebContents(web_contents_)->session_id();
}
bool TabContentsSyncedTabDelegate::IsBeingDestroyed() const {
@@ -179,7 +179,7 @@
return false;
}
-SessionID::id_type TabContentsSyncedTabDelegate::GetSourceTabID() const {
+SessionID TabContentsSyncedTabDelegate::GetSourceTabID() const {
sync_sessions::SyncSessionsRouterTabHelper* helper =
sync_sessions::SyncSessionsRouterTabHelper::FromWebContents(
web_contents_);
diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h
index 79ddf68..053e949 100644
--- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h
+++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h
@@ -26,8 +26,8 @@
~TabContentsSyncedTabDelegate() override;
// SyncedTabDelegate:
- SessionID::id_type GetWindowId() const override;
- SessionID::id_type GetSessionId() const override;
+ SessionID GetWindowId() const override;
+ SessionID GetSessionId() const override;
bool IsBeingDestroyed() const override;
std::string GetExtensionAppId() const override;
bool IsInitialBlankNavigation() const override;
@@ -46,7 +46,7 @@
int GetSyncId() const override;
void SetSyncId(int sync_id) override;
bool ShouldSync(sync_sessions::SyncSessionsClient* sessions_client) override;
- SessionID::id_type GetSourceTabID() const override;
+ SessionID GetSourceTabID() const override;
private:
explicit TabContentsSyncedTabDelegate(content::WebContents* web_contents);
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
index d016e94e..06a4baf 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
@@ -328,7 +328,9 @@
if (!open_tabs)
return;
const sessions::SessionTab* tab;
- if (!open_tabs->GetForeignTab(item.session_tag, item.tab_id, &tab))
+ if (!open_tabs->GetForeignTab(item.session_tag,
+ SessionID::FromSerializedValue(item.tab_id),
+ &tab))
return;
if (tab->navigations.empty())
return;
diff --git a/chrome/browser/ui/webui/foreign_session_handler.cc b/chrome/browser/ui/webui/foreign_session_handler.cc
index 94585185d..f42df1d 100644
--- a/chrome/browser/ui/webui/foreign_session_handler.cc
+++ b/chrome/browser/ui/webui/foreign_session_handler.cc
@@ -178,7 +178,8 @@
// We don't actually care about |window_num|, this is just a sanity check.
DCHECK_LT(kInvalidId, window_num);
const ::sessions::SessionTab* tab;
- if (!open_tabs->GetForeignTab(session_string_value, tab_id, &tab)) {
+ if (!open_tabs->GetForeignTab(session_string_value,
+ SessionID::FromSerializedValue(tab_id), &tab)) {
LOG(ERROR) << "Failed to load foreign tab.";
return;
}