| 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 <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/base64.h" | 10 #include "base/base64.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 args->restored_keystore_key_for_bootstrapping, args->clear_data_option)); | 253 args->restored_keystore_key_for_bootstrapping, args->clear_data_option)); |
| 253 sync_encryption_handler_->AddObserver(this); | 254 sync_encryption_handler_->AddObserver(this); |
| 254 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); | 255 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); |
| 255 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); | 256 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); |
| 256 | 257 |
| 257 base::FilePath absolute_db_path = database_path_; | 258 base::FilePath absolute_db_path = database_path_; |
| 258 DCHECK(absolute_db_path.IsAbsolute()); | 259 DCHECK(absolute_db_path.IsAbsolute()); |
| 259 | 260 |
| 260 scoped_ptr<syncable::DirectoryBackingStore> backing_store = | 261 scoped_ptr<syncable::DirectoryBackingStore> backing_store = |
| 261 args->internal_components_factory->BuildDirectoryBackingStore( | 262 args->internal_components_factory->BuildDirectoryBackingStore( |
| 262 InternalComponentsFactory::STORAGE_ON_DISK, | 263 InternalComponentsFactory::STORAGE_ON_DISK, args->credentials.email, |
| 263 args->credentials.email, absolute_db_path).Pass(); | 264 absolute_db_path); |
| 264 | 265 |
| 265 DCHECK(backing_store.get()); | 266 DCHECK(backing_store.get()); |
| 266 share_.directory.reset( | 267 share_.directory.reset( |
| 267 new syncable::Directory( | 268 new syncable::Directory( |
| 268 backing_store.release(), | 269 backing_store.release(), |
| 269 args->unrecoverable_error_handler, | 270 args->unrecoverable_error_handler, |
| 270 report_unrecoverable_error_function_, | 271 report_unrecoverable_error_function_, |
| 271 sync_encryption_handler_.get(), | 272 sync_encryption_handler_.get(), |
| 272 sync_encryption_handler_->GetCryptographerUnsafe())); | 273 sync_encryption_handler_->GetCryptographerUnsafe())); |
| 273 share_.sync_credentials = args->credentials; | 274 share_.sync_credentials = args->credentials; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 weak_core.get(); | 318 weak_core.get(); |
| 318 | 319 |
| 319 sync_context_proxy_.reset(new syncer_v2::SyncContextProxyImpl( | 320 sync_context_proxy_.reset(new syncer_v2::SyncContextProxyImpl( |
| 320 base::ThreadTaskRunnerHandle::Get(), weak_core)); | 321 base::ThreadTaskRunnerHandle::Get(), weak_core)); |
| 321 | 322 |
| 322 // Build a SyncSessionContext and store the worker in it. | 323 // Build a SyncSessionContext and store the worker in it. |
| 323 DVLOG(1) << "Sync is bringing up SyncSessionContext."; | 324 DVLOG(1) << "Sync is bringing up SyncSessionContext."; |
| 324 std::vector<SyncEngineEventListener*> listeners; | 325 std::vector<SyncEngineEventListener*> listeners; |
| 325 listeners.push_back(&allstatus_); | 326 listeners.push_back(&allstatus_); |
| 326 listeners.push_back(this); | 327 listeners.push_back(this); |
| 327 session_context_ = | 328 session_context_ = args->internal_components_factory->BuildContext( |
| 328 args->internal_components_factory->BuildContext( | 329 connection_manager_.get(), directory(), args->extensions_activity, |
| 329 connection_manager_.get(), | 330 listeners, &debug_info_event_listener_, model_type_registry_.get(), |
| 330 directory(), | 331 args->invalidator_client_id); |
| 331 args->extensions_activity, | |
| 332 listeners, | |
| 333 &debug_info_event_listener_, | |
| 334 model_type_registry_.get(), | |
| 335 args->invalidator_client_id) | |
| 336 .Pass(); | |
| 337 session_context_->set_account_name(args->credentials.email); | 332 session_context_->set_account_name(args->credentials.email); |
| 338 scheduler_ = args->internal_components_factory->BuildScheduler( | 333 scheduler_ = args->internal_components_factory->BuildScheduler( |
| 339 name_, session_context_.get(), args->cancelation_signal).Pass(); | 334 name_, session_context_.get(), args->cancelation_signal); |
| 340 | 335 |
| 341 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 336 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 342 | 337 |
| 343 initialized_ = true; | 338 initialized_ = true; |
| 344 | 339 |
| 345 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 340 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 346 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 341 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 347 observing_network_connectivity_changes_ = true; | 342 observing_network_connectivity_changes_ = true; |
| 348 | 343 |
| 349 UpdateCredentials(args->credentials); | 344 UpdateCredentials(args->credentials); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 allstatus_.SetNotificationsEnabled(invalidator_enabled); | 898 allstatus_.SetNotificationsEnabled(invalidator_enabled); |
| 904 scheduler_->SetNotificationsEnabled(invalidator_enabled); | 899 scheduler_->SetNotificationsEnabled(invalidator_enabled); |
| 905 } | 900 } |
| 906 | 901 |
| 907 void SyncManagerImpl::OnIncomingInvalidation( | 902 void SyncManagerImpl::OnIncomingInvalidation( |
| 908 syncer::ModelType type, | 903 syncer::ModelType type, |
| 909 scoped_ptr<InvalidationInterface> invalidation) { | 904 scoped_ptr<InvalidationInterface> invalidation) { |
| 910 DCHECK(thread_checker_.CalledOnValidThread()); | 905 DCHECK(thread_checker_.CalledOnValidThread()); |
| 911 | 906 |
| 912 allstatus_.IncrementNotificationsReceived(); | 907 allstatus_.IncrementNotificationsReceived(); |
| 913 scheduler_->ScheduleInvalidationNudge( | 908 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), |
| 914 type, | 909 FROM_HERE); |
| 915 invalidation.Pass(), | |
| 916 FROM_HERE); | |
| 917 } | 910 } |
| 918 | 911 |
| 919 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { | 912 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { |
| 920 DCHECK(thread_checker_.CalledOnValidThread()); | 913 DCHECK(thread_checker_.CalledOnValidThread()); |
| 921 if (types.Empty()) { | 914 if (types.Empty()) { |
| 922 LOG(WARNING) << "Sync received refresh request with no types specified."; | 915 LOG(WARNING) << "Sync received refresh request with no types specified."; |
| 923 } else { | 916 } else { |
| 924 scheduler_->ScheduleLocalRefreshRequest( | 917 scheduler_->ScheduleLocalRefreshRequest( |
| 925 types, FROM_HERE); | 918 types, FROM_HERE); |
| 926 } | 919 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 } | 1032 } |
| 1040 | 1033 |
| 1041 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) { | 1034 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) { |
| 1042 DCHECK(thread_checker_.CalledOnValidThread()); | 1035 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1043 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time()); | 1036 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time()); |
| 1044 ClearParams params(callback); | 1037 ClearParams params(callback); |
| 1045 scheduler_->ScheduleClearServerData(params); | 1038 scheduler_->ScheduleClearServerData(params); |
| 1046 } | 1039 } |
| 1047 | 1040 |
| 1048 } // namespace syncer | 1041 } // namespace syncer |
| OLD | NEW |