Chromium Code Reviews| Index: blimp/net/helium/helium_sync_manager.cc |
| diff --git a/blimp/net/helium/helium_sync_manager.cc b/blimp/net/helium/helium_sync_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..96bb60ec2ed1267ba46983e8f76ae7589ebf58ac |
| --- /dev/null |
| +++ b/blimp/net/helium/helium_sync_manager.cc |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "blimp/net/helium/helium_sync_manager.h" |
| + |
| +#include <utility> |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| + |
| +namespace blimp { |
| +namespace { |
| + |
| +class ScopedSyncRegistration; |
|
scf
2016/09/28 17:18:00
unused?
Kevin M
2016/09/29 00:06:28
Done.
|
| + |
| +class HeliumSyncManagerImpl : public HeliumSyncManager { |
| + public: |
| + explicit HeliumSyncManagerImpl(std::unique_ptr<HeliumTransport> transport); |
|
scf
2016/09/28 17:18:00
Don't you also need the "RunningAs" enum (Client/S
Kevin M
2016/09/29 00:06:28
Was waiting on the common enums to be landed.
|
| + ~HeliumSyncManagerImpl() override; |
| + |
| + // HeliumSyncManager implementation. |
| + std::unique_ptr<SyncRegistration> Register(Syncable* object) override; |
| + std::unique_ptr<SyncRegistration> RegisterExisting(HeliumObjectId id, |
| + Syncable* object) override; |
| + void Unregister(HeliumObjectId id) override; |
| + void Pause(HeliumObjectId id, bool paused) override; |
| + |
| + private: |
| + std::unique_ptr<HeliumTransport> transport_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HeliumSyncManagerImpl); |
| +}; |
| + |
| +HeliumSyncManagerImpl::HeliumSyncManagerImpl( |
| + std::unique_ptr<HeliumTransport> transport) |
| + : transport_(std::move(transport)) { |
| + DCHECK(transport_); |
|
scf
2016/09/28 17:18:00
change to CHECK? if we don't have transport we are
Kevin M
2016/09/29 00:06:28
Coding errors (dev messed up) are typically DCHECK
|
| +} |
| + |
| +HeliumSyncManagerImpl::~HeliumSyncManagerImpl() {} |
| + |
| +std::unique_ptr<HeliumSyncManager::SyncRegistration> |
| +HeliumSyncManagerImpl::Register(Syncable* object) { |
| + NOTIMPLEMENTED(); |
| + return nullptr; |
| +} |
| + |
| +std::unique_ptr<HeliumSyncManager::SyncRegistration> |
| +HeliumSyncManagerImpl::RegisterExisting(HeliumObjectId id, Syncable* object) { |
| + NOTIMPLEMENTED(); |
| + return nullptr; |
| +} |
| + |
| +void HeliumSyncManagerImpl::Unregister(HeliumObjectId id) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void HeliumSyncManagerImpl::Pause(HeliumObjectId id, bool paused) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +} // namespace |
| + |
| +// static |
| +std::unique_ptr<HeliumSyncManager> HeliumSyncManager::Create( |
| + std::unique_ptr<HeliumTransport> transport) { |
| + return base::MakeUnique<HeliumSyncManagerImpl>(std::move(transport)); |
| +} |
| + |
| +HeliumSyncManager::SyncRegistration::SyncRegistration( |
| + HeliumSyncManager* sync_manager, |
| + HeliumObjectId id) |
| + : id_(id), sync_manager_(sync_manager) { |
| + DCHECK(sync_manager); |
| +} |
| + |
| +HeliumSyncManager::SyncRegistration::~SyncRegistration() { |
| + sync_manager_->Unregister(id_); |
| +} |
| + |
| +void HeliumSyncManager::SyncRegistration::Pause(bool paused) { |
| + sync_manager_->Pause(id_, paused); |
| +} |
| + |
| +} // namespace blimp |