OLD | NEW |
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 "chrome/browser/sync/sessions/sessions_sync_manager.h" | 5 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | 9 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
10 #include "chrome/browser/sync/glue/synced_window_delegate.h" | 10 #include "chrome/browser/sync/glue/synced_window_delegate.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 BuildSyncedSessionFromSpecifics(foreign_session_tag, | 645 BuildSyncedSessionFromSpecifics(foreign_session_tag, |
646 window_s, | 646 window_s, |
647 modification_time, | 647 modification_time, |
648 foreign_session->windows[window_id]); | 648 foreign_session->windows[window_id]); |
649 } | 649 } |
650 // Delete any closed windows and unused tabs as necessary. | 650 // Delete any closed windows and unused tabs as necessary. |
651 session_tracker_.CleanupSession(foreign_session_tag); | 651 session_tracker_.CleanupSession(foreign_session_tag); |
652 } else if (specifics.has_tab()) { | 652 } else if (specifics.has_tab()) { |
653 const sync_pb::SessionTab& tab_s = specifics.tab(); | 653 const sync_pb::SessionTab& tab_s = specifics.tab(); |
654 SessionID::id_type tab_id = tab_s.tab_id(); | 654 SessionID::id_type tab_id = tab_s.tab_id(); |
| 655 |
| 656 const SessionTab* existing_tab; |
| 657 if (session_tracker_.LookupSessionTab( |
| 658 foreign_session_tag, tab_id, &existing_tab) && |
| 659 existing_tab->timestamp > modification_time) { |
| 660 DVLOG(1) << "Ignoring " << foreign_session_tag << "'s session tab " |
| 661 << tab_id << " with earlier modification time"; |
| 662 return; |
| 663 } |
| 664 |
655 SessionTab* tab = | 665 SessionTab* tab = |
656 session_tracker_.GetTab(foreign_session_tag, | 666 session_tracker_.GetTab(foreign_session_tag, |
657 tab_id, | 667 tab_id, |
658 specifics.tab_node_id()); | 668 specifics.tab_node_id()); |
659 | 669 |
660 // Update SessionTab based on protobuf. | 670 // Update SessionTab based on protobuf. |
661 tab->SetFromSyncData(tab_s, modification_time); | 671 tab->SetFromSyncData(tab_s, modification_time); |
662 | 672 |
663 // If a favicon or favicon urls are present, load the URLs and visit | 673 // If a favicon or favicon urls are present, load the URLs and visit |
664 // times into the in-memory favicon cache. | 674 // times into the in-memory favicon cache. |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 << " with age " << session_age_in_days << ", deleting."; | 1049 << " with age " << session_age_in_days << ", deleting."; |
1040 DeleteForeignSessionInternal(session_tag, &changes); | 1050 DeleteForeignSessionInternal(session_tag, &changes); |
1041 } | 1051 } |
1042 } | 1052 } |
1043 | 1053 |
1044 if (!changes.empty()) | 1054 if (!changes.empty()) |
1045 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 1055 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
1046 } | 1056 } |
1047 | 1057 |
1048 }; // namespace browser_sync | 1058 }; // namespace browser_sync |
OLD | NEW |