| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/glue/session_model_associator.h" | 5 #include "chrome/browser/sync/glue/session_model_associator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/prefs/pref_service_syncable.h" | 22 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/sessions/session_id.h" | 24 #include "chrome/browser/sessions/session_id.h" |
| 25 #include "chrome/browser/sync/glue/device_info.h" | 25 #include "chrome/browser/sync/glue/device_info.h" |
| 26 #include "chrome/browser/sync/glue/synced_device_tracker.h" | 26 #include "chrome/browser/sync/glue/synced_device_tracker.h" |
| 27 #include "chrome/browser/sync/glue/synced_session.h" | 27 #include "chrome/browser/sync/glue/synced_session.h" |
| 28 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | 28 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
| 29 #include "chrome/browser/sync/glue/synced_window_delegate.h" | 29 #include "chrome/browser/sync/glue/synced_window_delegate.h" |
| 30 #include "chrome/browser/sync/profile_sync_service.h" | 30 #include "chrome/browser/sync/profile_sync_service.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/pref_names.h" | |
| 33 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 34 #include "components/sessions/serialized_navigation_entry.h" | 33 #include "components/sessions/serialized_navigation_entry.h" |
| 34 #include "components/sync_driver/sync_prefs.h" |
| 35 #include "components/user_prefs/pref_registry_syncable.h" | 35 #include "components/user_prefs/pref_registry_syncable.h" |
| 36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/browser/favicon_status.h" | 37 #include "content/public/browser/favicon_status.h" |
| 38 #include "content/public/browser/navigation_entry.h" | 38 #include "content/public/browser/navigation_entry.h" |
| 39 #include "content/public/browser/notification_details.h" | 39 #include "content/public/browser/notification_details.h" |
| 40 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/common/url_constants.h" | 41 #include "content/public/common/url_constants.h" |
| 42 #include "sync/api/sync_error.h" | 42 #include "sync/api/sync_error.h" |
| 43 #include "sync/api/time.h" | 43 #include "sync/api/time.h" |
| 44 #include "sync/internal_api/public/base/model_type.h" | 44 #include "sync/internal_api/public/base/model_type.h" |
| 45 #include "sync/internal_api/public/read_node.h" | 45 #include "sync/internal_api/public/read_node.h" |
| 46 #include "sync/internal_api/public/read_transaction.h" | 46 #include "sync/internal_api/public/read_transaction.h" |
| 47 #include "sync/internal_api/public/write_node.h" | 47 #include "sync/internal_api/public/write_node.h" |
| 48 #include "sync/internal_api/public/write_transaction.h" | 48 #include "sync/internal_api/public/write_transaction.h" |
| 49 #include "sync/protocol/session_specifics.pb.h" | 49 #include "sync/protocol/session_specifics.pb.h" |
| 50 #include "sync/syncable/directory.h" | 50 #include "sync/syncable/directory.h" |
| 51 #include "sync/syncable/syncable_read_transaction.h" | 51 #include "sync/syncable/syncable_read_transaction.h" |
| 52 #include "sync/syncable/syncable_write_transaction.h" | 52 #include "sync/syncable/syncable_write_transaction.h" |
| 53 #if defined(OS_LINUX) | 53 #if defined(OS_LINUX) |
| 54 #include "base/linux_util.h" | 54 #include "base/linux_util.h" |
| 55 #elif defined(OS_WIN) | 55 #elif defined(OS_WIN) |
| 56 #include <windows.h> | 56 #include <windows.h> |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 using content::BrowserThread; | 59 using content::BrowserThread; |
| 60 using content::NavigationEntry; | 60 using content::NavigationEntry; |
| 61 using prefs::kSyncSessionsGUID; | |
| 62 using sessions::SerializedNavigationEntry; | 61 using sessions::SerializedNavigationEntry; |
| 63 using syncer::SESSIONS; | 62 using syncer::SESSIONS; |
| 64 | 63 |
| 65 namespace { | 64 namespace { |
| 66 | 65 |
| 67 std::string SessionTagPrefix() { | 66 std::string SessionTagPrefix() { |
| 68 return std::string("session_sync"); | 67 return std::string("session_sync"); |
| 69 } | 68 } |
| 70 | 69 |
| 71 // Given a transaction, returns the GUID-based string that should be used for | 70 // Given a transaction, returns the GUID-based string that should be used for |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 content::Source<Profile>(sync_service_->profile()), | 684 content::Source<Profile>(sync_service_->profile()), |
| 686 content::NotificationService::NoDetails()); | 685 content::NotificationService::NoDetails()); |
| 687 return syncer::SyncError(); | 686 return syncer::SyncError(); |
| 688 } | 687 } |
| 689 | 688 |
| 690 void SessionModelAssociator::InitializeCurrentMachineTag( | 689 void SessionModelAssociator::InitializeCurrentMachineTag( |
| 691 syncer::WriteTransaction* trans) { | 690 syncer::WriteTransaction* trans) { |
| 692 DCHECK(CalledOnValidThread()); | 691 DCHECK(CalledOnValidThread()); |
| 693 DCHECK(current_machine_tag_.empty()); | 692 DCHECK(current_machine_tag_.empty()); |
| 694 std::string persisted_guid; | 693 std::string persisted_guid; |
| 695 browser_sync::SyncPrefs prefs(profile_->GetPrefs()); | 694 sync_driver::SyncPrefs prefs(profile_->GetPrefs()); |
| 696 persisted_guid = prefs.GetSyncSessionsGUID(); | 695 persisted_guid = prefs.GetSyncSessionsGUID(); |
| 697 if (!persisted_guid.empty()) { | 696 if (!persisted_guid.empty()) { |
| 698 current_machine_tag_ = persisted_guid; | 697 current_machine_tag_ = persisted_guid; |
| 699 DVLOG(1) << "Restoring persisted session sync guid: " | 698 DVLOG(1) << "Restoring persisted session sync guid: " |
| 700 << persisted_guid; | 699 << persisted_guid; |
| 701 } else { | 700 } else { |
| 702 current_machine_tag_ = GetMachineTagFromTransaction(trans); | 701 current_machine_tag_ = GetMachineTagFromTransaction(trans); |
| 703 DVLOG(1) << "Creating session sync guid: " << current_machine_tag_; | 702 DVLOG(1) << "Creating session sync guid: " << current_machine_tag_; |
| 704 prefs.SetSyncSessionsGUID(current_machine_tag_); | 703 prefs.SetSyncSessionsGUID(current_machine_tag_); |
| 705 } | 704 } |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 tab_s->set_tab_id(new_tab_id); | 1209 tab_s->set_tab_id(new_tab_id); |
| 1211 tab_node.SetSessionSpecifics(session_specifics); | 1210 tab_node.SetSessionSpecifics(session_specifics); |
| 1212 // Update tab node pool with the new association. | 1211 // Update tab node pool with the new association. |
| 1213 local_tab_pool_.ReassociateTabNode(tab_node_id, new_tab_id); | 1212 local_tab_pool_.ReassociateTabNode(tab_node_id, new_tab_id); |
| 1214 } | 1213 } |
| 1215 } | 1214 } |
| 1216 } | 1215 } |
| 1217 } | 1216 } |
| 1218 | 1217 |
| 1219 } // namespace browser_sync | 1218 } // namespace browser_sync |
| OLD | NEW |