Fix session sync ID duplicates on Android
Because the writes to the two databases (sync and tab restore) on
Android are not atomic, it's possible that tabs contain sync IDs that
have been generated by sync, but sync itself wasn't able to persist.
During window association, unless we handle sync IDs reported by the
delegate (UI) earlier, it's possible that AssociateTab() generates
"new" sync IDs that in fact are not new, because the delegate will
expose those sync IDs, if the tabs happen to be iterated in the wrong
order (i.e. AssociateTab() can generate a tab node ID that conflicts
with a later tab delegate).
Bug: 843554
Change-Id: I7dc0b01ee2481bc2b7c1e7c4fc47f345b9594ed7
Reviewed-on: https://chromium-review.googlesource.com/1062030
Commit-Queue: Mikel Astiz <[email protected]>
Reviewed-by: Sky Malice <[email protected]>
Reviewed-by: Marc Treib <[email protected]>
Cr-Commit-Position: refs/heads/master@{#561078}
diff --git a/components/sync_sessions/local_session_event_handler_impl.h b/components/sync_sessions/local_session_event_handler_impl.h
index 6006379..071b593b 100644
--- a/components/sync_sessions/local_session_event_handler_impl.h
+++ b/components/sync_sessions/local_session_event_handler_impl.h
@@ -79,6 +79,16 @@
private:
enum ReloadTabsOption { RELOAD_TABS, DONT_RELOAD_TABS };
+
+ // Updates |session_tracker_| with tab_id<->tab_node_id association that the
+ // delegate already knows about, while resolving conflicts if the delegate
+ // reports conflicting sync IDs. This makes sure duplicate tab_node_id-s are
+ // not assigned. On return, the following conditions are met:
+ // 1. Delegate contains no duplicate sync IDs (tab_node_id).
+ // 2. Delegate contains no sync-ID <-> tab_id association that the tracker
+ // doesn't know about (but not the opposite).
+ void AssociateExistingSyncIds();
+
void AssociateWindows(ReloadTabsOption option,
bool has_tabbed_window,
WriteBatch* batch);