Revert of Revert of Roll android_tools f6e2370:2a860d8 (patchset #1 id:1 of https...
[chromium-blink-merge.git] / remoting / protocol / protocol_mock_objects.cc
blob4f42d3223fb3cd6a64fc16f93c3231dfd825dcb1
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
3 // found in the LICENSE file.
5 #include "remoting/protocol/protocol_mock_objects.h"
7 #include "base/logging.h"
8 #include "base/thread_task_runner_handle.h"
10 namespace remoting {
11 namespace protocol {
13 MockConnectionToClient::MockConnectionToClient(
14 Session* session,
15 HostStub* host_stub)
16 : ConnectionToClient(session) {
17 set_host_stub(host_stub);
20 MockConnectionToClient::~MockConnectionToClient() {}
22 MockConnectionToClientEventHandler::MockConnectionToClientEventHandler() {}
24 MockConnectionToClientEventHandler::~MockConnectionToClientEventHandler() {}
26 MockClipboardStub::MockClipboardStub() {}
28 MockClipboardStub::~MockClipboardStub() {}
30 MockInputStub::MockInputStub() {}
32 MockInputStub::~MockInputStub() {}
34 MockHostStub::MockHostStub() {}
36 MockHostStub::~MockHostStub() {}
38 MockClientStub::MockClientStub() {}
40 MockClientStub::~MockClientStub() {}
42 MockCursorShapeStub::MockCursorShapeStub() {}
44 MockCursorShapeStub::~MockCursorShapeStub() {}
46 MockVideoStub::MockVideoStub() {}
48 MockVideoStub::~MockVideoStub() {}
50 MockSession::MockSession() {}
52 MockSession::~MockSession() {}
54 MockSessionManager::MockSessionManager() {}
56 MockSessionManager::~MockSessionManager() {}
58 MockPairingRegistryDelegate::MockPairingRegistryDelegate() {
61 MockPairingRegistryDelegate::~MockPairingRegistryDelegate() {
64 scoped_ptr<base::ListValue> MockPairingRegistryDelegate::LoadAll() {
65 scoped_ptr<base::ListValue> result(new base::ListValue());
66 for (Pairings::const_iterator i = pairings_.begin(); i != pairings_.end();
67 ++i) {
68 result->Append(i->second.ToValue().release());
70 return result.Pass();
73 bool MockPairingRegistryDelegate::DeleteAll() {
74 pairings_.clear();
75 return true;
78 protocol::PairingRegistry::Pairing MockPairingRegistryDelegate::Load(
79 const std::string& client_id) {
80 Pairings::const_iterator i = pairings_.find(client_id);
81 if (i != pairings_.end()) {
82 return i->second;
83 } else {
84 return protocol::PairingRegistry::Pairing();
88 bool MockPairingRegistryDelegate::Save(
89 const protocol::PairingRegistry::Pairing& pairing) {
90 pairings_[pairing.client_id()] = pairing;
91 return true;
94 bool MockPairingRegistryDelegate::Delete(const std::string& client_id) {
95 pairings_.erase(client_id);
96 return true;
99 SynchronousPairingRegistry::SynchronousPairingRegistry(
100 scoped_ptr<Delegate> delegate)
101 : PairingRegistry(base::ThreadTaskRunnerHandle::Get(), delegate.Pass()) {
104 SynchronousPairingRegistry::~SynchronousPairingRegistry() {
107 void SynchronousPairingRegistry::PostTask(
108 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
109 const tracked_objects::Location& from_here,
110 const base::Closure& task) {
111 DCHECK(task_runner->BelongsToCurrentThread());
112 task.Run();
115 } // namespace protocol
116 } // namespace remoting