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 | |
10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/base64.h" | 12 #include "base/base64.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 scoped_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).Pass(); | 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_, |
274 sync_encryption_handler_.get(), | 274 sync_encryption_handler_.get(), |
275 sync_encryption_handler_->GetCryptographerUnsafe())); | 275 sync_encryption_handler_->GetCryptographerUnsafe())); |
276 share_.sync_credentials = args->credentials; | 276 share_.sync_credentials = args->credentials; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 weak_core.get(); | 320 weak_core.get(); |
321 | 321 |
322 sync_context_proxy_.reset(new syncer_v2::SyncContextProxyImpl( | 322 sync_context_proxy_.reset(new syncer_v2::SyncContextProxyImpl( |
323 base::ThreadTaskRunnerHandle::Get(), weak_core)); | 323 base::ThreadTaskRunnerHandle::Get(), weak_core)); |
324 | 324 |
325 // Build a SyncSessionContext and store the worker in it. | 325 // Build a SyncSessionContext and store the worker in it. |
326 DVLOG(1) << "Sync is bringing up SyncSessionContext."; | 326 DVLOG(1) << "Sync is bringing up SyncSessionContext."; |
327 std::vector<SyncEngineEventListener*> listeners; | 327 std::vector<SyncEngineEventListener*> listeners; |
328 listeners.push_back(&allstatus_); | 328 listeners.push_back(&allstatus_); |
329 listeners.push_back(this); | 329 listeners.push_back(this); |
330 session_context_ = | 330 session_context_ = args->internal_components_factory->BuildContext( |
331 args->internal_components_factory->BuildContext( | 331 connection_manager_.get(), directory(), args->extensions_activity, |
332 connection_manager_.get(), | 332 listeners, &debug_info_event_listener_, model_type_registry_.get(), |
333 directory(), | 333 args->invalidator_client_id); |
334 args->extensions_activity, | |
335 listeners, | |
336 &debug_info_event_listener_, | |
337 model_type_registry_.get(), | |
338 args->invalidator_client_id) | |
339 .Pass(); | |
340 scheduler_ = args->internal_components_factory->BuildScheduler( | 334 scheduler_ = args->internal_components_factory->BuildScheduler( |
341 name_, session_context_.get(), args->cancelation_signal).Pass(); | 335 name_, session_context_.get(), args->cancelation_signal); |
342 | 336 |
343 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 337 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
344 | 338 |
345 initialized_ = true; | 339 initialized_ = true; |
346 | 340 |
347 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 341 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
348 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 342 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
349 observing_network_connectivity_changes_ = true; | 343 observing_network_connectivity_changes_ = true; |
350 | 344 |
351 UpdateCredentials(args->credentials); | 345 UpdateCredentials(args->credentials); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 allstatus_.SetNotificationsEnabled(invalidator_enabled); | 904 allstatus_.SetNotificationsEnabled(invalidator_enabled); |
911 scheduler_->SetNotificationsEnabled(invalidator_enabled); | 905 scheduler_->SetNotificationsEnabled(invalidator_enabled); |
912 } | 906 } |
913 | 907 |
914 void SyncManagerImpl::OnIncomingInvalidation( | 908 void SyncManagerImpl::OnIncomingInvalidation( |
915 syncer::ModelType type, | 909 syncer::ModelType type, |
916 scoped_ptr<InvalidationInterface> invalidation) { | 910 scoped_ptr<InvalidationInterface> invalidation) { |
917 DCHECK(thread_checker_.CalledOnValidThread()); | 911 DCHECK(thread_checker_.CalledOnValidThread()); |
918 | 912 |
919 allstatus_.IncrementNotificationsReceived(); | 913 allstatus_.IncrementNotificationsReceived(); |
920 scheduler_->ScheduleInvalidationNudge( | 914 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), |
921 type, | 915 FROM_HERE); |
922 invalidation.Pass(), | |
923 FROM_HERE); | |
924 } | 916 } |
925 | 917 |
926 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { | 918 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { |
927 DCHECK(thread_checker_.CalledOnValidThread()); | 919 DCHECK(thread_checker_.CalledOnValidThread()); |
928 if (types.Empty()) { | 920 if (types.Empty()) { |
929 LOG(WARNING) << "Sync received refresh request with no types specified."; | 921 LOG(WARNING) << "Sync received refresh request with no types specified."; |
930 } else { | 922 } else { |
931 scheduler_->ScheduleLocalRefreshRequest( | 923 scheduler_->ScheduleLocalRefreshRequest( |
932 types, FROM_HERE); | 924 types, FROM_HERE); |
933 } | 925 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 } | 1038 } |
1047 | 1039 |
1048 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) { | 1040 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) { |
1049 DCHECK(thread_checker_.CalledOnValidThread()); | 1041 DCHECK(thread_checker_.CalledOnValidThread()); |
1050 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time()); | 1042 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time()); |
1051 ClearParams params(callback); | 1043 ClearParams params(callback); |
1052 scheduler_->ScheduleClearServerData(params); | 1044 scheduler_->ScheduleClearServerData(params); |
1053 } | 1045 } |
1054 | 1046 |
1055 } // namespace syncer | 1047 } // namespace syncer |
OLD | NEW |