1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "sync/internal_api/sync_core.h" 6 7 #include "sync/engine/non_blocking_type_processor_core.h" 8 #include "sync/sessions/model_type_registry.h" 9 10 namespace syncer { 11 12 SyncCore::SyncCore(ModelTypeRegistry* model_type_registry) 13 : model_type_registry_(model_type_registry), weak_ptr_factory_(this) {} 14 15 SyncCore::~SyncCore() {} 16 17 void SyncCore::ConnectSyncTypeToCore( 18 ModelType type, 19 const DataTypeState& data_type_state, 20 scoped_refptr<base::SequencedTaskRunner> task_runner, 21 base::WeakPtr<NonBlockingTypeProcessor> processor) { 22 // Initialize the processor's sync-thread sibling and the 23 // processor <-> processor_core (ie. model thread <-> sync thread) 24 // communication channel. 25 model_type_registry_->InitializeNonBlockingType( 26 type, data_type_state, task_runner, processor); 27 } 28 29 void SyncCore::Disconnect(ModelType type) { 30 model_type_registry_->RemoveNonBlockingType(type); 31 } 32 33 base::WeakPtr<SyncCore> SyncCore::AsWeakPtr() { 34 return weak_ptr_factory_.GetWeakPtr(); 35 } 36 37 } // namespace syncer 38