Update local tab state with UpdateTrackerWithSpecifics()
Instead of first manually updating SyncedSessionTracker and later
producing the protos (SessionTab, SessionSpecifics), we now propose the
opposite and:
1. Produce the specifics first from SyncedTabDelegate.
2. Update the tracker using the specifics.
This flow is a lot nicer because, once other calling sites are updated,
we could move the updating of SyncedSessionTracker a lot closer to where
the persistence layers & sync are updated
(LocalSessionEventHandlerImpl::WriteBatch), to guarantee that the two
stay consistent.
This patch does not address the analogous updates for placeholder tabs
and the header updates.
Bug: 681921
Change-Id: I6bf7e90f9a3b236ce9e7b1f985fc0626369d8659
Reviewed-on: https://chromium-review.googlesource.com/1002176
Commit-Queue: Mikel Astiz <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Jan Krcal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#549477}
diff --git a/components/sync_sessions/local_session_event_handler_impl.h b/components/sync_sessions/local_session_event_handler_impl.h
index 584b211..2551963 100644
--- a/components/sync_sessions/local_session_event_handler_impl.h
+++ b/components/sync_sessions/local_session_event_handler_impl.h
@@ -75,11 +75,9 @@
void OnFaviconsChanged(const std::set<GURL>& page_urls,
const GURL& icon_url) override;
- // Set |session_tab| from |tab_delegate| and |mtime|. Exposed publicly for
- // testing.
- void SetSessionTabFromDelegateForTest(const SyncedTabDelegate& tab_delegate,
- base::Time mtime,
- sessions::SessionTab* session_tab);
+ // Returns tab specifics from |tab_delegate|. Exposed publicly for testing.
+ sync_pb::SessionTab GetTabSpecificsFromDelegateForTest(
+ const SyncedTabDelegate& tab_delegate) const;
private:
enum ReloadTabsOption { RELOAD_TABS, DONT_RELOAD_TABS };
@@ -112,10 +110,9 @@
const sessions::SessionTab& tab,
WriteBatch* batch) const;
- // Set |session_tab| from |tab_delegate| and |mtime|.
- void SetSessionTabFromDelegate(const SyncedTabDelegate& tab_delegate,
- base::Time mtime,
- sessions::SessionTab* session_tab) const;
+ // Set |session_tab| from |tab_delegate|.
+ sync_pb::SessionTab GetTabSpecificsFromDelegate(
+ const SyncedTabDelegate& tab_delegate) const;
// Updates task tracker with the navigations of |tab_delegate|.
void UpdateTaskTracker(SyncedTabDelegate* const tab_delegate);