Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: components/sync_sessions/sessions_sync_manager.cc

Issue 2562853002: [Sync] Fix flakiness from Sessions refactor (Closed)
Patch Set: Fix SetSyncId Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync_sessions/sessions_sync_manager.h" 5 #include "components/sync_sessions/sessions_sync_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return; 360 return;
361 361
362 SessionID::id_type tab_id = tab_delegate->GetSessionId(); 362 SessionID::id_type tab_id = tab_delegate->GetSessionId();
363 DVLOG(1) << "Syncing tab " << tab_id << " from window " 363 DVLOG(1) << "Syncing tab " << tab_id << " from window "
364 << tab_delegate->GetWindowId(); 364 << tab_delegate->GetWindowId();
365 365
366 int tab_node_id = TabNodePool::kInvalidTabNodeID; 366 int tab_node_id = TabNodePool::kInvalidTabNodeID;
367 bool existing_tab_node = 367 bool existing_tab_node =
368 session_tracker_.GetTabNodeForLocalTab(tab_id, &tab_node_id); 368 session_tracker_.GetTabNodeForLocalTab(tab_id, &tab_node_id);
369 DCHECK_NE(TabNodePool::kInvalidTabNodeID, tab_node_id); 369 DCHECK_NE(TabNodePool::kInvalidTabNodeID, tab_node_id);
370 tab_delegate->SetSyncId(tab_node_id);
skym 2016/12/09 15:40:00 I can't seem to find anywhere that reads this valu
Nicolas Zea 2016/12/09 17:33:36 Correct, we only use it for placeholders today (al
370 sessions::SessionTab* session_tab = 371 sessions::SessionTab* session_tab =
371 session_tracker_.GetTab(current_machine_tag(), tab_id); 372 session_tracker_.GetTab(current_machine_tag(), tab_id);
372 373
373 // Get the previously synced url. 374 // Get the previously synced url.
374 int old_index = session_tab->normalized_navigation_index(); 375 int old_index = session_tab->normalized_navigation_index();
375 GURL old_url; 376 GURL old_url;
376 if (session_tab->navigations.size() > static_cast<size_t>(old_index)) 377 if (session_tab->navigations.size() > static_cast<size_t>(old_index))
377 old_url = session_tab->navigations[old_index].virtual_url(); 378 old_url = session_tab->navigations[old_index].virtual_url();
378 379
379 // Update the tracker's session representation. 380 // Update the tracker's session representation.
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // with tab_node_id changing from NodeIDB to NodeIDA. 760 // with tab_node_id changing from NodeIDB to NodeIDA.
760 // 761 //
761 // We can also wind up here if we created this tab as an out-of-order 762 // We can also wind up here if we created this tab as an out-of-order
762 // update to the header node for this session before actually associating 763 // update to the header node for this session before actually associating
763 // the tab itself, so the tab node id wasn't available at the time and 764 // the tab itself, so the tab node id wasn't available at the time and
764 // is currently kInvalidTabNodeID. 765 // is currently kInvalidTabNodeID.
765 // 766 //
766 // In both cases, we can safely throw it into the set of node ids. 767 // In both cases, we can safely throw it into the set of node ids.
767 session_tracker_.OnTabNodeSeen(session_tag, specifics.tab_node_id()); 768 session_tracker_.OnTabNodeSeen(session_tag, specifics.tab_node_id());
768 sessions::SessionTab* tab = session_tracker_.GetTab(session_tag, tab_id); 769 sessions::SessionTab* tab = session_tracker_.GetTab(session_tag, tab_id);
769 if (tab->timestamp > modification_time) { 770 if (!tab->timestamp.is_null() && tab->timestamp > modification_time) {
770 DVLOG(1) << "Ignoring " << session_tag << "'s session tab " << tab_id 771 DVLOG(1) << "Ignoring " << session_tag << "'s session tab " << tab_id
771 << " with earlier modification time"; 772 << " with earlier modification time: " << tab->timestamp
773 << " vs " << modification_time;
772 return; 774 return;
773 } 775 }
774 776
775 // Update SessionTab based on protobuf. 777 // Update SessionTab based on protobuf.
776 tab->SetFromSyncData(tab_s, modification_time); 778 tab->SetFromSyncData(tab_s, modification_time);
777 779
778 // If a favicon or favicon urls are present, load the URLs and visit 780 // If a favicon or favicon urls are present, load the URLs and visit
779 // times into the in-memory favicon cache. 781 // times into the in-memory favicon cache.
780 RefreshFaviconVisitTimesFromForeignTab(tab_s, modification_time); 782 RefreshFaviconVisitTimesFromForeignTab(tab_s, modification_time);
781 783
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1118 }
1117 1119
1118 // static 1120 // static
1119 std::string SessionsSyncManager::TagHashFromSpecifics( 1121 std::string SessionsSyncManager::TagHashFromSpecifics(
1120 const sync_pb::SessionSpecifics& specifics) { 1122 const sync_pb::SessionSpecifics& specifics) {
1121 return syncer::GenerateSyncableHash(syncer::SESSIONS, 1123 return syncer::GenerateSyncableHash(syncer::SESSIONS,
1122 TagFromSpecifics(specifics)); 1124 TagFromSpecifics(specifics));
1123 } 1125 }
1124 1126
1125 }; // namespace sync_sessions 1127 }; // namespace sync_sessions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698