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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/favicon/favicon_service_factory.h" | 17 #include "chrome/browser/favicon/favicon_service_factory.h" |
18 #include "chrome/browser/history/history_service.h" | 18 #include "chrome/browser/history/history_service.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 20 #include "chrome/browser/prefs/pref_service_syncable.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/sessions/session_id.h" | 22 #include "chrome/browser/sessions/session_id.h" |
22 #include "chrome/browser/sync/glue/device_info.h" | 23 #include "chrome/browser/sync/glue/device_info.h" |
23 #include "chrome/browser/sync/glue/synced_device_tracker.h" | 24 #include "chrome/browser/sync/glue/synced_device_tracker.h" |
24 #include "chrome/browser/sync/glue/synced_session.h" | 25 #include "chrome/browser/sync/glue/synced_session.h" |
25 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | 26 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
26 #include "chrome/browser/sync/glue/synced_window_delegate.h" | 27 #include "chrome/browser/sync/glue/synced_window_delegate.h" |
27 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
28 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service, | 89 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service, |
89 DataTypeErrorHandler* error_handler) | 90 DataTypeErrorHandler* error_handler) |
90 : tab_pool_(sync_service), | 91 : tab_pool_(sync_service), |
91 local_session_syncid_(syncer::kInvalidId), | 92 local_session_syncid_(syncer::kInvalidId), |
92 sync_service_(sync_service), | 93 sync_service_(sync_service), |
93 stale_session_threshold_days_(kDefaultStaleSessionThresholdDays), | 94 stale_session_threshold_days_(kDefaultStaleSessionThresholdDays), |
94 setup_for_test_(false), | 95 setup_for_test_(false), |
95 waiting_for_change_(false), | 96 waiting_for_change_(false), |
96 ALLOW_THIS_IN_INITIALIZER_LIST(test_weak_factory_(this)), | 97 ALLOW_THIS_IN_INITIALIZER_LIST(test_weak_factory_(this)), |
97 profile_(sync_service->profile()), | 98 profile_(sync_service->profile()), |
98 pref_service_(profile_->GetPrefs()), | 99 pref_service_(PrefServiceSyncable::FromProfile(profile_)), |
99 error_handler_(error_handler) { | 100 error_handler_(error_handler) { |
100 DCHECK(CalledOnValidThread()); | 101 DCHECK(CalledOnValidThread()); |
101 DCHECK(sync_service_); | 102 DCHECK(sync_service_); |
102 DCHECK(profile_); | 103 DCHECK(profile_); |
103 if (pref_service_->FindPreference(kSyncSessionsGUID) == NULL) { | 104 if (pref_service_->FindPreference(kSyncSessionsGUID) == NULL) { |
104 pref_service_->RegisterStringPref(kSyncSessionsGUID, | 105 static_cast<PrefRegistrySyncable*>( |
105 std::string(), | 106 pref_service_->DeprecatedGetPrefRegistry())->RegisterStringPref( |
106 PrefServiceSyncable::UNSYNCABLE_PREF); | 107 kSyncSessionsGUID, |
| 108 std::string(), |
| 109 PrefRegistrySyncable::UNSYNCABLE_PREF); |
107 } | 110 } |
108 } | 111 } |
109 | 112 |
110 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service, | 113 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service, |
111 bool setup_for_test) | 114 bool setup_for_test) |
112 : tab_pool_(sync_service), | 115 : tab_pool_(sync_service), |
113 local_session_syncid_(syncer::kInvalidId), | 116 local_session_syncid_(syncer::kInvalidId), |
114 sync_service_(sync_service), | 117 sync_service_(sync_service), |
115 stale_session_threshold_days_(kDefaultStaleSessionThresholdDays), | 118 stale_session_threshold_days_(kDefaultStaleSessionThresholdDays), |
116 setup_for_test_(setup_for_test), | 119 setup_for_test_(setup_for_test), |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 | 1245 |
1243 bool SessionModelAssociator::CryptoReadyIfNecessary() { | 1246 bool SessionModelAssociator::CryptoReadyIfNecessary() { |
1244 // We only access the cryptographer while holding a transaction. | 1247 // We only access the cryptographer while holding a transaction. |
1245 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1248 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1246 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); | 1249 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); |
1247 return !encrypted_types.Has(SESSIONS) || | 1250 return !encrypted_types.Has(SESSIONS) || |
1248 sync_service_->IsCryptographerReady(&trans); | 1251 sync_service_->IsCryptographerReady(&trans); |
1249 } | 1252 } |
1250 | 1253 |
1251 } // namespace browser_sync | 1254 } // namespace browser_sync |
OLD | NEW |