| Index: chrome/browser/sync/sessions/sessions_sync_manager.cc
|
| diff --git a/chrome/browser/sync/sessions/sessions_sync_manager.cc b/chrome/browser/sync/sessions/sessions_sync_manager.cc
|
| index 72a01d2f8cfe792fa7dd8fbe87c829469535d734..252211cac8b35d130f2ff8e3e2165fb279737252 100644
|
| --- a/chrome/browser/sync/sessions/sessions_sync_manager.cc
|
| +++ b/chrome/browser/sync/sessions/sessions_sync_manager.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/sync/glue/local_device_info_provider.h"
|
| #include "chrome/browser/sync/glue/synced_tab_delegate.h"
|
| #include "chrome/browser/sync/glue/synced_window_delegate.h"
|
| #include "chrome/browser/sync/sessions/sessions_util.h"
|
| @@ -46,13 +47,13 @@ static const size_t kDefaultStaleSessionThresholdDays = 14; // 2 weeks.
|
|
|
| SessionsSyncManager::SessionsSyncManager(
|
| Profile* profile,
|
| - SyncInternalApiDelegate* delegate,
|
| + LocalDeviceInfoProvider* local_device_info_provider,
|
| scoped_ptr<LocalSessionEventRouter> router)
|
| : favicon_cache_(profile, kMaxSyncFavicons),
|
| local_tab_pool_out_of_sync_(true),
|
| sync_prefs_(profile->GetPrefs()),
|
| profile_(profile),
|
| - delegate_(delegate),
|
| + local_device_info_provider_(local_device_info_provider),
|
| local_session_header_node_id_(TabNodePool::kInvalidTabNodeID),
|
| stale_session_threshold_days_(kDefaultStaleSessionThresholdDays),
|
| local_event_router_(router.Pass()),
|
| @@ -85,24 +86,31 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
|
| sync_processor_ = sync_processor.Pass();
|
|
|
| local_session_header_node_id_ = TabNodePool::kInvalidTabNodeID;
|
| - scoped_ptr<DeviceInfo> local_device_info(delegate_->GetLocalDeviceInfo());
|
| - syncer::SyncChangeList new_changes;
|
|
|
| // Make sure we have a machine tag. We do this now (versus earlier) as it's
|
| // a conveniently safe time to assert sync is ready and the cache_guid is
|
| // initialized.
|
| - if (current_machine_tag_.empty())
|
| + if (current_machine_tag_.empty()) {
|
| InitializeCurrentMachineTag();
|
| + }
|
| +
|
| + // SessionDataTypeController ensures that the local device info
|
| + // is available before activating this datatype.
|
| + const DeviceInfo* local_device_info =
|
| + local_device_info_provider_->GetLocalDeviceInfo();
|
| if (local_device_info) {
|
| current_session_name_ = local_device_info->client_name();
|
| } else {
|
| merge_result.set_error(error_handler_->CreateAndUploadError(
|
| FROM_HERE,
|
| - "Failed to get device info for machine tag."));
|
| + "Failed to get local device info."));
|
| return merge_result;
|
| }
|
| +
|
| session_tracker_.SetLocalSessionTag(current_machine_tag_);
|
|
|
| + syncer::SyncChangeList new_changes;
|
| +
|
| // First, we iterate over sync data to update our session_tracker_.
|
| syncer::SyncDataList restored_tabs;
|
| if (!InitFromSyncModel(initial_sync_data, &restored_tabs, &new_changes)) {
|
| @@ -121,7 +129,7 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
|
|
|
| #if defined(OS_ANDROID)
|
| std::string sync_machine_tag(BuildMachineTag(
|
| - delegate_->GetLocalSyncCacheGUID()));
|
| + local_device_info_provider_->GetLocalSyncCacheGUID()));
|
| if (current_machine_tag_.compare(sync_machine_tag) != 0)
|
| DeleteForeignSessionInternal(sync_machine_tag, &new_changes);
|
| #endif
|
| @@ -639,7 +647,9 @@ void SessionsSyncManager::InitializeCurrentMachineTag() {
|
| current_machine_tag_ = persisted_guid;
|
| DVLOG(1) << "Restoring persisted session sync guid: " << persisted_guid;
|
| } else {
|
| - current_machine_tag_ = BuildMachineTag(delegate_->GetLocalSyncCacheGUID());
|
| + DCHECK(local_device_info_provider_->IsInitialized());
|
| + current_machine_tag_ = BuildMachineTag(
|
| + local_device_info_provider_->GetLocalSyncCacheGUID());
|
| DVLOG(1) << "Creating session sync guid: " << current_machine_tag_;
|
| sync_prefs_.SetSyncSessionsGUID(current_machine_tag_);
|
| }
|
| @@ -954,6 +964,11 @@ FaviconCache* SessionsSyncManager::GetFaviconCache() {
|
| return &favicon_cache_;
|
| }
|
|
|
| +SyncedWindowDelegatesGetter*
|
| +SessionsSyncManager::GetSyncedWindowDelegatesGetter() const {
|
| + return synced_window_getter_.get();
|
| +}
|
| +
|
| void SessionsSyncManager::DoGarbageCollection() {
|
| std::vector<const SyncedSession*> sessions;
|
| if (!GetAllForeignSessions(&sessions))
|
|
|