| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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/test/engine/injectable_sync_context_proxy.h" | 
|  | 6 | 
|  | 7 #include "sync/engine/model_type_sync_proxy_impl.h" | 
|  | 8 #include "sync/engine/model_type_sync_worker.h" | 
|  | 9 | 
|  | 10 namespace syncer { | 
|  | 11 | 
|  | 12 InjectableSyncContextProxy::InjectableSyncContextProxy( | 
|  | 13     ModelTypeSyncWorker* worker) | 
|  | 14     : is_worker_connected_(false), worker_(worker) { | 
|  | 15 } | 
|  | 16 | 
|  | 17 InjectableSyncContextProxy::~InjectableSyncContextProxy() { | 
|  | 18 } | 
|  | 19 | 
|  | 20 void InjectableSyncContextProxy::ConnectTypeToSync( | 
|  | 21     syncer::ModelType type, | 
|  | 22     const DataTypeState& data_type_state, | 
|  | 23     base::WeakPtr<syncer::ModelTypeSyncProxyImpl> type_sync_proxy) { | 
|  | 24   // This class is allowed to participate in only one connection. | 
|  | 25   DCHECK(!is_worker_connected_); | 
|  | 26   is_worker_connected_ = true; | 
|  | 27 | 
|  | 28   // Hands off ownership of our member to the type_sync_proxy, while keeping | 
|  | 29   // an unsafe pointer to it.  This is why we can only connect once. | 
|  | 30   scoped_ptr<ModelTypeSyncWorker> worker(worker_); | 
|  | 31 | 
|  | 32   type_sync_proxy->OnConnect(worker.Pass()); | 
|  | 33 } | 
|  | 34 | 
|  | 35 void InjectableSyncContextProxy::Disconnect(syncer::ModelType type) { | 
|  | 36   // This should delete the worker, but we don't own it. | 
|  | 37   worker_ = NULL; | 
|  | 38 } | 
|  | 39 | 
|  | 40 scoped_ptr<SyncContextProxy> InjectableSyncContextProxy::Clone() const { | 
|  | 41   // This confuses ownership.  We trust that our callers are well-behaved. | 
|  | 42   return scoped_ptr<SyncContextProxy>(new InjectableSyncContextProxy(worker_)); | 
|  | 43 } | 
|  | 44 | 
|  | 45 ModelTypeSyncWorker* InjectableSyncContextProxy::GetWorker() { | 
|  | 46   return worker_; | 
|  | 47 } | 
|  | 48 | 
|  | 49 }  // namespace syncer | 
| OLD | NEW | 
|---|