OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/internal_api/sync_manager.h" | 5 #include "chrome/browser/sync/internal_api/sync_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 } | 112 } |
113 | 113 |
114 } // namespace | 114 } // namespace |
115 | 115 |
116 namespace sync_api { | 116 namespace sync_api { |
117 | 117 |
118 ////////////////////////////////////////////////////////////////////////// | 118 ////////////////////////////////////////////////////////////////////////// |
119 // SyncManager's implementation: SyncManager::SyncInternal | 119 // SyncManager's implementation: SyncManager::SyncInternal |
120 class SyncManager::SyncInternal | 120 class SyncManager::SyncInternal |
121 : public net::NetworkChangeNotifier::IPAddressObserver, | 121 : public net::NetworkChangeNotifier::IPAddressObserver, |
122 public browser_sync::Cryptographer::Observer, | |
122 public sync_notifier::SyncNotifierObserver, | 123 public sync_notifier::SyncNotifierObserver, |
123 public JsBackend, | 124 public JsBackend, |
124 public SyncEngineEventListener, | 125 public SyncEngineEventListener, |
125 public ServerConnectionEventListener, | 126 public ServerConnectionEventListener, |
126 public syncable::DirectoryChangeDelegate { | 127 public syncable::DirectoryChangeDelegate { |
127 static const int kDefaultNudgeDelayMilliseconds; | 128 static const int kDefaultNudgeDelayMilliseconds; |
128 static const int kPreferencesNudgeDelayMilliseconds; | 129 static const int kPreferencesNudgeDelayMilliseconds; |
129 public: | 130 public: |
130 explicit SyncInternal(const std::string& name) | 131 explicit SyncInternal(const std::string& name) |
131 : name_(name), | 132 : name_(name), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 virtual void HandleCalculateChangesChangeEventFromSyncer( | 253 virtual void HandleCalculateChangesChangeEventFromSyncer( |
253 const ImmutableWriteTransactionInfo& write_transaction_info, | 254 const ImmutableWriteTransactionInfo& write_transaction_info, |
254 syncable::BaseTransaction* trans) OVERRIDE; | 255 syncable::BaseTransaction* trans) OVERRIDE; |
255 | 256 |
256 // Listens for notifications from the ServerConnectionManager | 257 // Listens for notifications from the ServerConnectionManager |
257 void HandleServerConnectionEvent(const ServerConnectionEvent& event); | 258 void HandleServerConnectionEvent(const ServerConnectionEvent& event); |
258 | 259 |
259 // Open the directory named with username_for_share | 260 // Open the directory named with username_for_share |
260 bool OpenDirectory(); | 261 bool OpenDirectory(); |
261 | 262 |
263 // Cryptographer::Observer implementation. | |
264 virtual void OnEncryptedTypesChanged( | |
265 const syncable::ModelTypeSet& encrypted_types, | |
266 bool encrypt_everything) OVERRIDE; | |
267 virtual void OnEncryptionComplete() OVERRIDE; | |
268 | |
262 // SyncNotifierObserver implementation. | 269 // SyncNotifierObserver implementation. |
263 virtual void OnNotificationStateChange( | 270 virtual void OnNotificationStateChange( |
264 bool notifications_enabled) OVERRIDE; | 271 bool notifications_enabled) OVERRIDE; |
265 | 272 |
266 virtual void OnIncomingNotification( | 273 virtual void OnIncomingNotification( |
267 const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE; | 274 const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE; |
268 | 275 |
269 virtual void StoreState(const std::string& cookie) OVERRIDE; | 276 virtual void StoreState(const std::string& cookie) OVERRIDE; |
270 | 277 |
271 void AddChangeObserver(SyncManager::ChangeObserver* observer); | 278 void AddChangeObserver(SyncManager::ChangeObserver* observer); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 bool ChangeBuffersAreEmpty() { | 439 bool ChangeBuffersAreEmpty() { |
433 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { | 440 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { |
434 if (!change_buffers_[i].IsEmpty()) | 441 if (!change_buffers_[i].IsEmpty()) |
435 return false; | 442 return false; |
436 } | 443 } |
437 return true; | 444 return true; |
438 } | 445 } |
439 | 446 |
440 void ReEncryptEverything(WriteTransaction* trans); | 447 void ReEncryptEverything(WriteTransaction* trans); |
441 | 448 |
442 // Initializes (bootstraps) the Cryptographer if NIGORI has finished | |
443 // initial sync so that it can immediately start encrypting / decrypting. | |
444 // If the restored key is incompatible with the current version of the NIGORI | |
445 // node (which could happen if a restart occurred just after an update to | |
446 // NIGORI was downloaded and the user must enter a new passphrase to decrypt) | |
447 // then we will raise OnPassphraseRequired and set pending keys for | |
448 // decryption. Otherwise, the cryptographer is made ready (is_ready()). | |
449 void BootstrapEncryption(const std::string& restored_key_for_bootstrapping); | |
450 | |
451 // Called for every notification. This updates the notification statistics | 449 // Called for every notification. This updates the notification statistics |
452 // to be displayed in about:sync. | 450 // to be displayed in about:sync. |
453 void UpdateNotificationInfo( | 451 void UpdateNotificationInfo( |
454 const syncable::ModelTypePayloadMap& type_payloads); | 452 const syncable::ModelTypePayloadMap& type_payloads); |
455 | 453 |
456 // Checks for server reachabilty and requests a nudge. | 454 // Checks for server reachabilty and requests a nudge. |
457 void OnIPAddressChangedImpl(); | 455 void OnIPAddressChangedImpl(); |
458 | 456 |
459 // Helper function used only by the constructor. | 457 // Helper function used only by the constructor. |
460 void BindJsMessageHandler( | 458 void BindJsMessageHandler( |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 if (cryptographer->is_ready()) | 679 if (cryptographer->is_ready()) |
682 cryptographer->set_encrypt_everything(); | 680 cryptographer->set_encrypt_everything(); |
683 } | 681 } |
684 | 682 |
685 // Call with empty set. Reads from cryptographer so will automatically encrypt | 683 // Call with empty set. Reads from cryptographer so will automatically encrypt |
686 // all datatypes and update the nigori node as necessary. Will trigger | 684 // all datatypes and update the nigori node as necessary. Will trigger |
687 // OnPassphraseRequired if necessary. | 685 // OnPassphraseRequired if necessary. |
688 data_->EncryptDataTypes(syncable::ModelTypeSet()); | 686 data_->EncryptDataTypes(syncable::ModelTypeSet()); |
689 } | 687 } |
690 | 688 |
691 bool SyncManager::EncryptEverythingEnabled() const { | 689 bool SyncManager::EncryptEverythingEnabledForTest() const { |
692 ReadTransaction trans(FROM_HERE, GetUserShare()); | 690 ReadTransaction trans(FROM_HERE, GetUserShare()); |
693 return trans.GetCryptographer()->encrypt_everything(); | 691 return trans.GetCryptographer()->encrypt_everything(); |
694 } | 692 } |
695 | 693 |
696 bool SyncManager::IsUsingExplicitPassphrase() { | 694 bool SyncManager::IsUsingExplicitPassphrase() { |
697 return data_ && data_->IsUsingExplicitPassphrase(); | 695 return data_ && data_->IsUsingExplicitPassphrase(); |
698 } | 696 } |
699 | 697 |
700 void SyncManager::RequestCleanupDisabledTypes() { | 698 void SyncManager::RequestCleanupDisabledTypes() { |
701 DCHECK(thread_checker_.CalledOnValidThread()); | 699 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 bool signed_in = SignIn(credentials); | 801 bool signed_in = SignIn(credentials); |
804 | 802 |
805 if (signed_in || setup_for_test_mode_) { | 803 if (signed_in || setup_for_test_mode_) { |
806 if (scheduler()) { | 804 if (scheduler()) { |
807 scheduler()->Start( | 805 scheduler()->Start( |
808 browser_sync::SyncScheduler::CONFIGURATION_MODE, base::Closure()); | 806 browser_sync::SyncScheduler::CONFIGURATION_MODE, base::Closure()); |
809 } | 807 } |
810 | 808 |
811 initialized_ = true; | 809 initialized_ = true; |
812 | 810 |
813 // The following calls check that initialized_ is true. | 811 // The following call checks that initialized_ is true. |
Nicolas Zea
2011/10/21 14:29:07
Something like "Getting the user share to open a t
akalin
2011/10/22 03:28:38
Done.
| |
814 BootstrapEncryption(restored_key_for_bootstrapping); | 812 { |
813 // Cryptographer should only be accessed while holding a | |
814 // transaction. | |
815 ReadTransaction trans(FROM_HERE, GetUserShare()); | |
816 trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping); | |
817 trans.GetCryptographer()->AddObserver(this); | |
818 } | |
815 } | 819 } |
816 | 820 |
817 // Notify that initialization is complete. Note: This should be the last to | 821 // Notify that initialization is complete. Note: This should be the last to |
818 // execute if |signed_in| is false. Reason being in that case we would | 822 // execute if |signed_in| is false. Reason being in that case we would |
819 // post a task to shutdown sync. But if this function posts any other tasks | 823 // post a task to shutdown sync. But if this function posts any other tasks |
820 // on the UI thread and if shutdown wins then that tasks would execute on | 824 // on the UI thread and if shutdown wins then that tasks would execute on |
821 // a freed pointer. This is because UI thread is not shut down. | 825 // a freed pointer. This is because UI thread is not shut down. |
822 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 826 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
823 OnInitializationComplete( | 827 OnInitializationComplete( |
824 WeakHandle<JsBackend>(weak_ptr_factory_.GetWeakPtr()), | 828 WeakHandle<JsBackend>(weak_ptr_factory_.GetWeakPtr()), |
825 signed_in)); | 829 signed_in)); |
826 | 830 |
827 if (!signed_in && !setup_for_test_mode_) | 831 if (!signed_in && !setup_for_test_mode_) |
828 return false; | 832 return false; |
829 | 833 |
830 sync_notifier_->AddObserver(this); | 834 sync_notifier_->AddObserver(this); |
831 | 835 |
832 return signed_in; | 836 return signed_in; |
833 } | 837 } |
834 | 838 |
835 void SyncManager::SyncInternal::BootstrapEncryption( | |
836 const std::string& restored_key_for_bootstrapping) { | |
837 // Cryptographer should only be accessed while holding a transaction. | |
838 ReadTransaction trans(FROM_HERE, GetUserShare()); | |
839 Cryptographer* cryptographer = trans.GetCryptographer(); | |
840 | |
841 // Set the bootstrap token before bailing out if nigori node is not there. | |
842 // This could happen if server asked us to migrate nigri. | |
843 cryptographer->Bootstrap(restored_key_for_bootstrapping); | |
844 } | |
845 | |
846 bool SyncManager::SyncInternal::UpdateCryptographerFromNigori() { | 839 bool SyncManager::SyncInternal::UpdateCryptographerFromNigori() { |
847 DCHECK(initialized_); | 840 DCHECK(initialized_); |
848 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); | 841 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
849 if (!lookup.good()) { | 842 if (!lookup.good()) { |
850 NOTREACHED() << "BootstrapEncryption: lookup not good so bailing out"; | 843 NOTREACHED() |
844 << "UpdateCryptographerFromNigori: lookup not good so bailing out"; | |
851 return false; | 845 return false; |
852 } | 846 } |
853 if (!lookup->initial_sync_ended_for_type(syncable::NIGORI)) | 847 if (!lookup->initial_sync_ended_for_type(syncable::NIGORI)) |
854 return false; // Should only happen during first time sync. | 848 return false; // Should only happen during first time sync. |
855 | 849 |
856 WriteTransaction trans(FROM_HERE, GetUserShare()); | 850 WriteTransaction trans(FROM_HERE, GetUserShare()); |
857 Cryptographer* cryptographer = trans.GetCryptographer(); | 851 Cryptographer* cryptographer = trans.GetCryptographer(); |
858 | 852 |
859 WriteNode node(&trans); | 853 WriteNode node(&trans); |
860 if (!node.InitByTagLookup(kNigoriTag)) { | 854 if (!node.InitByTagLookup(kNigoriTag)) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 cryptographer->SetEncryptedTypes(encrypted_types); | 1126 cryptographer->SetEncryptedTypes(encrypted_types); |
1133 sync_pb::NigoriSpecifics nigori; | 1127 sync_pb::NigoriSpecifics nigori; |
1134 nigori.CopyFrom(node.GetNigoriSpecifics()); | 1128 nigori.CopyFrom(node.GetNigoriSpecifics()); |
1135 cryptographer->UpdateNigoriFromEncryptedTypes(&nigori); | 1129 cryptographer->UpdateNigoriFromEncryptedTypes(&nigori); |
1136 node.SetNigoriSpecifics(nigori); | 1130 node.SetNigoriSpecifics(nigori); |
1137 allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes()); | 1131 allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes()); |
1138 | 1132 |
1139 // We reencrypt everything regardless of whether the set of encrypted | 1133 // We reencrypt everything regardless of whether the set of encrypted |
1140 // types changed to ensure that any stray unencrypted entries are overwritten. | 1134 // types changed to ensure that any stray unencrypted entries are overwritten. |
1141 ReEncryptEverything(&trans); | 1135 ReEncryptEverything(&trans); |
1142 return; | |
1143 } | 1136 } |
1144 | 1137 |
1145 // TODO(zea): Add unit tests that ensure no sync changes are made when not | 1138 // TODO(zea): Add unit tests that ensure no sync changes are made when not |
1146 // needed. | 1139 // needed. |
1147 void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) { | 1140 void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) { |
1148 Cryptographer* cryptographer = trans->GetCryptographer(); | 1141 Cryptographer* cryptographer = trans->GetCryptographer(); |
1149 if (!cryptographer || !cryptographer->is_ready()) | 1142 if (!cryptographer || !cryptographer->is_ready()) |
1150 return; | 1143 return; |
1151 syncable::ModelTypeSet encrypted_types = GetEncryptedTypes(trans); | 1144 syncable::ModelTypeSet encrypted_types = GetEncryptedTypes(trans); |
1152 ModelSafeRoutingInfo routes; | 1145 ModelSafeRoutingInfo routes; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1209 if (!child.InitByIdLookup(child_id)) { | 1202 if (!child.InitByIdLookup(child_id)) { |
1210 NOTREACHED(); | 1203 NOTREACHED(); |
1211 return; | 1204 return; |
1212 } | 1205 } |
1213 child.SetPasswordSpecifics(child.GetPasswordSpecifics()); | 1206 child.SetPasswordSpecifics(child.GetPasswordSpecifics()); |
1214 child_id = child.GetSuccessorId(); | 1207 child_id = child.GetSuccessorId(); |
1215 } | 1208 } |
1216 } | 1209 } |
1217 } | 1210 } |
1218 | 1211 |
1219 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 1212 cryptographer->MarkEncryptionComplete(); |
1220 OnEncryptionComplete(encrypted_types)); | |
1221 } | 1213 } |
1222 | 1214 |
1223 SyncManager::~SyncManager() { | 1215 SyncManager::~SyncManager() { |
1224 DCHECK(thread_checker_.CalledOnValidThread()); | 1216 DCHECK(thread_checker_.CalledOnValidThread()); |
1225 delete data_; | 1217 delete data_; |
1226 } | 1218 } |
1227 | 1219 |
1228 void SyncManager::AddChangeObserver(ChangeObserver* observer) { | 1220 void SyncManager::AddChangeObserver(ChangeObserver* observer) { |
1229 DCHECK(thread_checker_.CalledOnValidThread()); | 1221 DCHECK(thread_checker_.CalledOnValidThread()); |
1230 data_->AddChangeObserver(observer); | 1222 data_->AddChangeObserver(observer); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 | 1279 |
1288 if (connection_manager_.get()) { | 1280 if (connection_manager_.get()) { |
1289 connection_manager_->RemoveListener(this); | 1281 connection_manager_->RemoveListener(this); |
1290 } | 1282 } |
1291 connection_manager_.reset(); | 1283 connection_manager_.reset(); |
1292 | 1284 |
1293 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1285 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
1294 observing_ip_address_changes_ = false; | 1286 observing_ip_address_changes_ = false; |
1295 | 1287 |
1296 if (dir_manager()) { | 1288 if (dir_manager()) { |
1297 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); | 1289 { |
1298 if (lookup.good()) { | 1290 // Cryptographer should only be accessed while holding a |
1299 lookup->RemoveTransactionObserver(&js_mutation_event_observer_); | 1291 // transaction. |
1292 ReadTransaction trans(FROM_HERE, GetUserShare()); | |
1293 trans.GetCryptographer()->RemoveObserver(this); | |
1294 trans.GetLookup()-> | |
1295 RemoveTransactionObserver(&js_mutation_event_observer_); | |
1300 RemoveChangeObserver(&js_mutation_event_observer_); | 1296 RemoveChangeObserver(&js_mutation_event_observer_); |
1301 } else { | |
1302 NOTREACHED(); | |
1303 } | 1297 } |
1304 dir_manager()->FinalSaveChangesForAll(); | 1298 dir_manager()->FinalSaveChangesForAll(); |
1305 dir_manager()->Close(username_for_share()); | 1299 dir_manager()->Close(username_for_share()); |
1306 } | 1300 } |
1307 | 1301 |
1308 // Reset the DirectoryManager and UserSettings so they relinquish sqlite | 1302 // Reset the DirectoryManager and UserSettings so they relinquish sqlite |
1309 // handles to backing files. | 1303 // handles to backing files. |
1310 share_.dir_manager.reset(); | 1304 share_.dir_manager.reset(); |
1311 | 1305 |
1312 setup_for_test_mode_ = false; | 1306 setup_for_test_mode_ = false; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1615 event.snapshot->initial_sync_ended.test(syncable::NIGORI)) { | 1609 event.snapshot->initial_sync_ended.test(syncable::NIGORI)) { |
1616 VLOG(1) << "OnPassphraseRequired sent because cryptographer is not " | 1610 VLOG(1) << "OnPassphraseRequired sent because cryptographer is not " |
1617 << "ready"; | 1611 << "ready"; |
1618 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 1612 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
1619 OnPassphraseRequired(sync_api::REASON_ENCRYPTION)); | 1613 OnPassphraseRequired(sync_api::REASON_ENCRYPTION)); |
1620 } | 1614 } |
1621 | 1615 |
1622 allstatus_.SetCryptographerReady(cryptographer->is_ready()); | 1616 allstatus_.SetCryptographerReady(cryptographer->is_ready()); |
1623 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); | 1617 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); |
1624 allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes()); | 1618 allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes()); |
1625 | |
1626 // If everything is in order(we have the passphrase) then there is no | |
1627 // need to inform the listeners. They will just wait for sync | |
1628 // completion event and if no errors have been raised it means | |
1629 // encryption was succesful. | |
1630 } | 1619 } |
1631 | 1620 |
1632 if (!initialized_) { | 1621 if (!initialized_) { |
1633 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " | 1622 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " |
1634 << "initialized"; | 1623 << "initialized"; |
1635 return; | 1624 return; |
1636 } | 1625 } |
1637 | 1626 |
1638 if (!event.snapshot->has_more_to_sync) { | 1627 if (!event.snapshot->has_more_to_sync) { |
1639 VLOG(1) << "OnSyncCycleCompleted sent"; | 1628 VLOG(1) << "Sending OnSyncCycleCompleted"; |
1640 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 1629 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
1641 OnSyncCycleCompleted(event.snapshot)); | 1630 OnSyncCycleCompleted(event.snapshot)); |
1642 } | 1631 } |
1643 | 1632 |
1644 // This is here for tests, which are still using p2p notifications. | 1633 // This is here for tests, which are still using p2p notifications. |
1645 // | 1634 // |
1646 // TODO(chron): Consider changing this back to track has_more_to_sync | 1635 // TODO(chron): Consider changing this back to track has_more_to_sync |
1647 // only notify peers if a successful commit has occurred. | 1636 // only notify peers if a successful commit has occurred. |
1648 bool is_notifiable_commit = | 1637 bool is_notifiable_commit = |
1649 (event.snapshot->syncer_status.num_successful_commits > 0); | 1638 (event.snapshot->syncer_status.num_successful_commits > 0); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1869 entry_kernels.begin(); it != entry_kernels.end(); ++it) { | 1858 entry_kernels.begin(); it != entry_kernels.end(); ++it) { |
1870 if ((*it)->ContainsString(lowercase_query)) { | 1859 if ((*it)->ContainsString(lowercase_query)) { |
1871 result->Append(new StringValue(base::Int64ToString( | 1860 result->Append(new StringValue(base::Int64ToString( |
1872 (*it)->ref(syncable::META_HANDLE)))); | 1861 (*it)->ref(syncable::META_HANDLE)))); |
1873 } | 1862 } |
1874 } | 1863 } |
1875 | 1864 |
1876 return JsArgList(&return_args); | 1865 return JsArgList(&return_args); |
1877 } | 1866 } |
1878 | 1867 |
1868 void SyncManager::SyncInternal::OnEncryptedTypesChanged( | |
1869 const syncable::ModelTypeSet& encrypted_types, | |
1870 bool encrypt_everything) { | |
1871 // NOTE: We're in a transaction. | |
1872 FOR_EACH_OBSERVER( | |
1873 SyncManager::Observer, observers_, | |
1874 OnEncryptedTypesChanged(encrypted_types, encrypt_everything)); | |
1875 } | |
1876 | |
1877 void SyncManager::SyncInternal::OnEncryptionComplete() { | |
1878 // NOTE: We're in a transaction. | |
1879 FOR_EACH_OBSERVER( | |
1880 SyncManager::Observer, observers_, OnEncryptionComplete()); | |
1881 } | |
1882 | |
1879 void SyncManager::SyncInternal::OnNotificationStateChange( | 1883 void SyncManager::SyncInternal::OnNotificationStateChange( |
1880 bool notifications_enabled) { | 1884 bool notifications_enabled) { |
1881 VLOG(1) << "P2P: Notifications enabled = " | 1885 VLOG(1) << "P2P: Notifications enabled = " |
1882 << (notifications_enabled ? "true" : "false"); | 1886 << (notifications_enabled ? "true" : "false"); |
1883 allstatus_.SetNotificationsEnabled(notifications_enabled); | 1887 allstatus_.SetNotificationsEnabled(notifications_enabled); |
1884 if (scheduler()) { | 1888 if (scheduler()) { |
1885 scheduler()->set_notifications_enabled(notifications_enabled); | 1889 scheduler()->set_notifications_enabled(notifications_enabled); |
1886 } | 1890 } |
1887 if (js_event_handler_.IsInitialized()) { | 1891 if (js_event_handler_.IsInitialized()) { |
1888 DictionaryValue details; | 1892 DictionaryValue details; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2000 UserShare* SyncManager::GetUserShare() const { | 2004 UserShare* SyncManager::GetUserShare() const { |
2001 return data_->GetUserShare(); | 2005 return data_->GetUserShare(); |
2002 } | 2006 } |
2003 | 2007 |
2004 void SyncManager::RefreshEncryption() { | 2008 void SyncManager::RefreshEncryption() { |
2005 DCHECK(thread_checker_.CalledOnValidThread()); | 2009 DCHECK(thread_checker_.CalledOnValidThread()); |
2006 if (data_->UpdateCryptographerFromNigori()) | 2010 if (data_->UpdateCryptographerFromNigori()) |
2007 data_->EncryptDataTypes(syncable::ModelTypeSet()); | 2011 data_->EncryptDataTypes(syncable::ModelTypeSet()); |
2008 } | 2012 } |
2009 | 2013 |
2010 syncable::ModelTypeSet SyncManager::GetEncryptedDataTypes() const { | 2014 syncable::ModelTypeSet SyncManager::GetEncryptedDataTypesForTest() const { |
2011 ReadTransaction trans(FROM_HERE, GetUserShare()); | 2015 ReadTransaction trans(FROM_HERE, GetUserShare()); |
2012 return GetEncryptedTypes(&trans); | 2016 return GetEncryptedTypes(&trans); |
2013 } | 2017 } |
2014 | 2018 |
2015 bool SyncManager::ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add) | 2019 bool SyncManager::ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add) |
2016 const { | 2020 const { |
2017 ReadTransaction trans(FROM_HERE, GetUserShare()); | 2021 ReadTransaction trans(FROM_HERE, GetUserShare()); |
2018 ReadNode node(&trans); | 2022 ReadNode node(&trans); |
2019 if (!node.InitByTagLookup(kNigoriTag)) { | 2023 if (!node.InitByTagLookup(kNigoriTag)) { |
2020 VLOG(1) << "Couldn't find Nigori node."; | 2024 VLOG(1) << "Couldn't find Nigori node."; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2078 | 2082 |
2079 for (syncable::ModelTypeSet::const_iterator i = types.begin(); | 2083 for (syncable::ModelTypeSet::const_iterator i = types.begin(); |
2080 i != types.end(); ++i) { | 2084 i != types.end(); ++i) { |
2081 if (!lookup->initial_sync_ended_for_type(*i)) | 2085 if (!lookup->initial_sync_ended_for_type(*i)) |
2082 return false; | 2086 return false; |
2083 } | 2087 } |
2084 return true; | 2088 return true; |
2085 } | 2089 } |
2086 | 2090 |
2087 } // namespace sync_api | 2091 } // namespace sync_api |
OLD | NEW |