OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 sync_encryption_handler_.reset(new SyncEncryptionHandlerImpl( | 253 sync_encryption_handler_.reset(new SyncEncryptionHandlerImpl( |
254 &share_, args->encryptor, args->restored_key_for_bootstrapping, | 254 &share_, args->encryptor, args->restored_key_for_bootstrapping, |
255 args->restored_keystore_key_for_bootstrapping, args->clear_data_option)); | 255 args->restored_keystore_key_for_bootstrapping, args->clear_data_option)); |
256 sync_encryption_handler_->AddObserver(this); | 256 sync_encryption_handler_->AddObserver(this); |
257 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); | 257 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); |
258 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); | 258 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); |
259 | 259 |
260 base::FilePath absolute_db_path = database_path_; | 260 base::FilePath absolute_db_path = database_path_; |
261 DCHECK(absolute_db_path.IsAbsolute()); | 261 DCHECK(absolute_db_path.IsAbsolute()); |
262 | 262 |
263 scoped_ptr<syncable::DirectoryBackingStore> backing_store = | 263 std::unique_ptr<syncable::DirectoryBackingStore> backing_store = |
264 args->internal_components_factory->BuildDirectoryBackingStore( | 264 args->internal_components_factory->BuildDirectoryBackingStore( |
265 InternalComponentsFactory::STORAGE_ON_DISK, | 265 InternalComponentsFactory::STORAGE_ON_DISK, |
266 args->credentials.account_id, absolute_db_path); | 266 args->credentials.account_id, absolute_db_path); |
267 | 267 |
268 DCHECK(backing_store.get()); | 268 DCHECK(backing_store.get()); |
269 share_.directory.reset( | 269 share_.directory.reset( |
270 new syncable::Directory( | 270 new syncable::Directory( |
271 backing_store.release(), | 271 backing_store.release(), |
272 args->unrecoverable_error_handler, | 272 args->unrecoverable_error_handler, |
273 report_unrecoverable_error_function_, | 273 report_unrecoverable_error_function_, |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 Cryptographer* cryptographer, | 727 Cryptographer* cryptographer, |
728 const syncable::EntryKernel& original, | 728 const syncable::EntryKernel& original, |
729 bool existed_before, | 729 bool existed_before, |
730 bool exists_now) { | 730 bool exists_now) { |
731 // If this is a deletion and the datatype was encrypted, we need to decrypt it | 731 // If this is a deletion and the datatype was encrypted, we need to decrypt it |
732 // and attach it to the buffer. | 732 // and attach it to the buffer. |
733 if (!exists_now && existed_before) { | 733 if (!exists_now && existed_before) { |
734 sync_pb::EntitySpecifics original_specifics(original.ref(SPECIFICS)); | 734 sync_pb::EntitySpecifics original_specifics(original.ref(SPECIFICS)); |
735 if (type == PASSWORDS) { | 735 if (type == PASSWORDS) { |
736 // Passwords must use their own legacy ExtraPasswordChangeRecordData. | 736 // Passwords must use their own legacy ExtraPasswordChangeRecordData. |
737 scoped_ptr<sync_pb::PasswordSpecificsData> data( | 737 std::unique_ptr<sync_pb::PasswordSpecificsData> data( |
738 DecryptPasswordSpecifics(original_specifics, cryptographer)); | 738 DecryptPasswordSpecifics(original_specifics, cryptographer)); |
739 if (!data) { | 739 if (!data) { |
740 NOTREACHED(); | 740 NOTREACHED(); |
741 return; | 741 return; |
742 } | 742 } |
743 buffer->SetExtraDataForId(id, new ExtraPasswordChangeRecordData(*data)); | 743 buffer->SetExtraDataForId(id, new ExtraPasswordChangeRecordData(*data)); |
744 } else if (original_specifics.has_encrypted()) { | 744 } else if (original_specifics.has_encrypted()) { |
745 // All other datatypes can just create a new unencrypted specifics and | 745 // All other datatypes can just create a new unencrypted specifics and |
746 // attach it. | 746 // attach it. |
747 const sync_pb::EncryptedData& encrypted = original_specifics.encrypted(); | 747 const sync_pb::EncryptedData& encrypted = original_specifics.encrypted(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 OnProtocolEvent(event)); | 873 OnProtocolEvent(event)); |
874 } | 874 } |
875 | 875 |
876 void SyncManagerImpl::SetJsEventHandler( | 876 void SyncManagerImpl::SetJsEventHandler( |
877 const WeakHandle<JsEventHandler>& event_handler) { | 877 const WeakHandle<JsEventHandler>& event_handler) { |
878 js_sync_manager_observer_.SetJsEventHandler(event_handler); | 878 js_sync_manager_observer_.SetJsEventHandler(event_handler); |
879 js_mutation_event_observer_.SetJsEventHandler(event_handler); | 879 js_mutation_event_observer_.SetJsEventHandler(event_handler); |
880 js_sync_encryption_handler_observer_.SetJsEventHandler(event_handler); | 880 js_sync_encryption_handler_observer_.SetJsEventHandler(event_handler); |
881 } | 881 } |
882 | 882 |
883 scoped_ptr<base::ListValue> SyncManagerImpl::GetAllNodesForType( | 883 std::unique_ptr<base::ListValue> SyncManagerImpl::GetAllNodesForType( |
884 syncer::ModelType type) { | 884 syncer::ModelType type) { |
885 DirectoryTypeDebugInfoEmitterMap* emitter_map = | 885 DirectoryTypeDebugInfoEmitterMap* emitter_map = |
886 model_type_registry_->directory_type_debug_info_emitter_map(); | 886 model_type_registry_->directory_type_debug_info_emitter_map(); |
887 DirectoryTypeDebugInfoEmitterMap::iterator it = emitter_map->find(type); | 887 DirectoryTypeDebugInfoEmitterMap::iterator it = emitter_map->find(type); |
888 | 888 |
889 if (it == emitter_map->end()) { | 889 if (it == emitter_map->end()) { |
890 // This can happen in some cases. The UI thread makes requests of us | 890 // This can happen in some cases. The UI thread makes requests of us |
891 // when it doesn't really know which types are enabled or disabled. | 891 // when it doesn't really know which types are enabled or disabled. |
892 DLOG(WARNING) << "Asked to return debug info for invalid type " | 892 DLOG(WARNING) << "Asked to return debug info for invalid type " |
893 << ModelTypeToString(type); | 893 << ModelTypeToString(type); |
894 return scoped_ptr<base::ListValue>(new base::ListValue()); | 894 return std::unique_ptr<base::ListValue>(new base::ListValue()); |
895 } | 895 } |
896 | 896 |
897 return it->second->GetAllNodes(); | 897 return it->second->GetAllNodes(); |
898 } | 898 } |
899 | 899 |
900 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) { | 900 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) { |
901 DCHECK(thread_checker_.CalledOnValidThread()); | 901 DCHECK(thread_checker_.CalledOnValidThread()); |
902 | 902 |
903 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled; | 903 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled; |
904 allstatus_.SetNotificationsEnabled(invalidator_enabled); | 904 allstatus_.SetNotificationsEnabled(invalidator_enabled); |
905 scheduler_->SetNotificationsEnabled(invalidator_enabled); | 905 scheduler_->SetNotificationsEnabled(invalidator_enabled); |
906 } | 906 } |
907 | 907 |
908 void SyncManagerImpl::OnIncomingInvalidation( | 908 void SyncManagerImpl::OnIncomingInvalidation( |
909 syncer::ModelType type, | 909 syncer::ModelType type, |
910 scoped_ptr<InvalidationInterface> invalidation) { | 910 std::unique_ptr<InvalidationInterface> invalidation) { |
911 DCHECK(thread_checker_.CalledOnValidThread()); | 911 DCHECK(thread_checker_.CalledOnValidThread()); |
912 | 912 |
913 allstatus_.IncrementNotificationsReceived(); | 913 allstatus_.IncrementNotificationsReceived(); |
914 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), | 914 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), |
915 FROM_HERE); | 915 FROM_HERE); |
916 } | 916 } |
917 | 917 |
918 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { | 918 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { |
919 DCHECK(thread_checker_.CalledOnValidThread()); | 919 DCHECK(thread_checker_.CalledOnValidThread()); |
920 if (types.Empty()) { | 920 if (types.Empty()) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 ClearParams params(callback); | 1032 ClearParams params(callback); |
1033 scheduler_->ScheduleClearServerData(params); | 1033 scheduler_->ScheduleClearServerData(params); |
1034 } | 1034 } |
1035 | 1035 |
1036 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch) { | 1036 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch) { |
1037 DCHECK(thread_checker_.CalledOnValidThread()); | 1037 DCHECK(thread_checker_.CalledOnValidThread()); |
1038 session_context_->set_cookie_jar_mismatch(account_mismatch); | 1038 session_context_->set_cookie_jar_mismatch(account_mismatch); |
1039 } | 1039 } |
1040 | 1040 |
1041 } // namespace syncer | 1041 } // namespace syncer |
OLD | NEW |