| 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 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "sync/internal_api/change_reorder_buffer.h" | 21 #include "sync/internal_api/change_reorder_buffer.h" |
| 22 #include "sync/internal_api/public/base/cancelation_signal.h" | 22 #include "sync/internal_api/public/base/cancelation_signal.h" |
| 23 #include "sync/internal_api/public/base/model_type.h" | 23 #include "sync/internal_api/public/base/model_type.h" |
| 24 #include "sync/internal_api/public/base_node.h" | 24 #include "sync/internal_api/public/base_node.h" |
| 25 #include "sync/internal_api/public/configure_reason.h" | 25 #include "sync/internal_api/public/configure_reason.h" |
| 26 #include "sync/internal_api/public/engine/polling_constants.h" | 26 #include "sync/internal_api/public/engine/polling_constants.h" |
| 27 #include "sync/internal_api/public/http_post_provider_factory.h" | 27 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 28 #include "sync/internal_api/public/internal_components_factory.h" | 28 #include "sync/internal_api/public/internal_components_factory.h" |
| 29 #include "sync/internal_api/public/read_node.h" | 29 #include "sync/internal_api/public/read_node.h" |
| 30 #include "sync/internal_api/public/read_transaction.h" | 30 #include "sync/internal_api/public/read_transaction.h" |
| 31 #include "sync/internal_api/public/sync_core_proxy.h" | 31 #include "sync/internal_api/public/sync_context_proxy.h" |
| 32 #include "sync/internal_api/public/user_share.h" | 32 #include "sync/internal_api/public/user_share.h" |
| 33 #include "sync/internal_api/public/util/experiments.h" | 33 #include "sync/internal_api/public/util/experiments.h" |
| 34 #include "sync/internal_api/public/write_node.h" | 34 #include "sync/internal_api/public/write_node.h" |
| 35 #include "sync/internal_api/public/write_transaction.h" | 35 #include "sync/internal_api/public/write_transaction.h" |
| 36 #include "sync/internal_api/sync_core.h" | 36 #include "sync/internal_api/sync_context.h" |
| 37 #include "sync/internal_api/sync_core_proxy_impl.h" | 37 #include "sync/internal_api/sync_context_proxy_impl.h" |
| 38 #include "sync/internal_api/syncapi_internal.h" | 38 #include "sync/internal_api/syncapi_internal.h" |
| 39 #include "sync/internal_api/syncapi_server_connection_manager.h" | 39 #include "sync/internal_api/syncapi_server_connection_manager.h" |
| 40 #include "sync/notifier/invalidation_util.h" | 40 #include "sync/notifier/invalidation_util.h" |
| 41 #include "sync/notifier/invalidator.h" | 41 #include "sync/notifier/invalidator.h" |
| 42 #include "sync/notifier/object_id_invalidation_map.h" | 42 #include "sync/notifier/object_id_invalidation_map.h" |
| 43 #include "sync/protocol/proto_value_conversions.h" | 43 #include "sync/protocol/proto_value_conversions.h" |
| 44 #include "sync/protocol/sync.pb.h" | 44 #include "sync/protocol/sync.pb.h" |
| 45 #include "sync/sessions/directory_type_debug_info_emitter.h" | 45 #include "sync/sessions/directory_type_debug_info_emitter.h" |
| 46 #include "sync/syncable/directory.h" | 46 #include "sync/syncable/directory.h" |
| 47 #include "sync/syncable/entry.h" | 47 #include "sync/syncable/entry.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 383 |
| 384 std::string sync_id = directory()->cache_guid(); | 384 std::string sync_id = directory()->cache_guid(); |
| 385 | 385 |
| 386 DVLOG(1) << "Setting sync client ID: " << sync_id; | 386 DVLOG(1) << "Setting sync client ID: " << sync_id; |
| 387 allstatus_.SetSyncId(sync_id); | 387 allstatus_.SetSyncId(sync_id); |
| 388 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; | 388 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; |
| 389 allstatus_.SetInvalidatorClientId(invalidator_client_id); | 389 allstatus_.SetInvalidatorClientId(invalidator_client_id); |
| 390 | 390 |
| 391 model_type_registry_.reset(new ModelTypeRegistry(workers, directory())); | 391 model_type_registry_.reset(new ModelTypeRegistry(workers, directory())); |
| 392 | 392 |
| 393 sync_core_.reset(new SyncCore(model_type_registry_.get())); | 393 sync_context_.reset(new SyncContext(model_type_registry_.get())); |
| 394 | 394 |
| 395 // Bind the SyncCore WeakPtr to this thread. This helps us crash earlier if | 395 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier |
| 396 // the pointer is misused in debug mode. | 396 // if the pointer is misused in debug mode. |
| 397 base::WeakPtr<SyncCore> weak_core = sync_core_->AsWeakPtr(); | 397 base::WeakPtr<SyncContext> weak_core = sync_context_->AsWeakPtr(); |
| 398 weak_core.get(); | 398 weak_core.get(); |
| 399 | 399 |
| 400 sync_core_proxy_.reset( | 400 sync_context_proxy_.reset( |
| 401 new SyncCoreProxyImpl(base::MessageLoopProxy::current(), weak_core)); | 401 new SyncContextProxyImpl(base::MessageLoopProxy::current(), weak_core)); |
| 402 | 402 |
| 403 // Build a SyncSessionContext and store the worker in it. | 403 // Build a SyncSessionContext and store the worker in it. |
| 404 DVLOG(1) << "Sync is bringing up SyncSessionContext."; | 404 DVLOG(1) << "Sync is bringing up SyncSessionContext."; |
| 405 std::vector<SyncEngineEventListener*> listeners; | 405 std::vector<SyncEngineEventListener*> listeners; |
| 406 listeners.push_back(&allstatus_); | 406 listeners.push_back(&allstatus_); |
| 407 listeners.push_back(this); | 407 listeners.push_back(this); |
| 408 session_context_ = internal_components_factory->BuildContext( | 408 session_context_ = internal_components_factory->BuildContext( |
| 409 connection_manager_.get(), | 409 connection_manager_.get(), |
| 410 directory(), | 410 directory(), |
| 411 extensions_activity, | 411 extensions_activity, |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 | 1015 |
| 1016 void SyncManagerImpl::SaveChanges() { | 1016 void SyncManagerImpl::SaveChanges() { |
| 1017 directory()->SaveChanges(); | 1017 directory()->SaveChanges(); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 UserShare* SyncManagerImpl::GetUserShare() { | 1020 UserShare* SyncManagerImpl::GetUserShare() { |
| 1021 DCHECK(initialized_); | 1021 DCHECK(initialized_); |
| 1022 return &share_; | 1022 return &share_; |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 syncer::SyncCoreProxy* SyncManagerImpl::GetSyncCoreProxy() { | 1025 syncer::SyncContextProxy* SyncManagerImpl::GetSyncContextProxy() { |
| 1026 DCHECK(initialized_); | 1026 DCHECK(initialized_); |
| 1027 return sync_core_proxy_.get(); | 1027 return sync_context_proxy_.get(); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 const std::string SyncManagerImpl::cache_guid() { | 1030 const std::string SyncManagerImpl::cache_guid() { |
| 1031 DCHECK(initialized_); | 1031 DCHECK(initialized_); |
| 1032 return directory()->cache_guid(); | 1032 return directory()->cache_guid(); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) { | 1035 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) { |
| 1036 ReadTransaction trans(FROM_HERE, GetUserShare()); | 1036 ReadTransaction trans(FROM_HERE, GetUserShare()); |
| 1037 ReadNode nigori_node(&trans); | 1037 ReadNode nigori_node(&trans); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1142 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1143 return kDefaultNudgeDelayMilliseconds; | 1143 return kDefaultNudgeDelayMilliseconds; |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 // static. | 1146 // static. |
| 1147 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1147 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1148 return kPreferencesNudgeDelayMilliseconds; | 1148 return kPreferencesNudgeDelayMilliseconds; |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 } // namespace syncer | 1151 } // namespace syncer |
| OLD | NEW |