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. 4 5 #include "remoting/protocol/protocol_mock_objects.h" 6 7 #include "base/logging.h" 8 #include "base/thread_task_runner_handle.h" 9 10 namespace remoting { 11 namespace protocol { 12 13 MockConnectionToClient::MockConnectionToClient( 14 Session* session, 15 HostStub* host_stub) 16 : ConnectionToClient(session) { 17 set_host_stub(host_stub); 18 } 19 20 MockConnectionToClient::~MockConnectionToClient() {} 21 22 MockConnectionToClientEventHandler::MockConnectionToClientEventHandler() {} 23 24 MockConnectionToClientEventHandler::~MockConnectionToClientEventHandler() {} 25 26 MockClipboardStub::MockClipboardStub() {} 27 28 MockClipboardStub::~MockClipboardStub() {} 29 30 MockInputStub::MockInputStub() {} 31 32 MockInputStub::~MockInputStub() {} 33 34 MockHostStub::MockHostStub() {} 35 36 MockHostStub::~MockHostStub() {} 37 38 MockClientStub::MockClientStub() {} 39 40 MockClientStub::~MockClientStub() {} 41 42 MockVideoStub::MockVideoStub() {} 43 44 MockVideoStub::~MockVideoStub() {} 45 46 MockSession::MockSession() {} 47 48 MockSession::~MockSession() {} 49 50 MockSessionManager::MockSessionManager() {} 51 52 MockSessionManager::~MockSessionManager() {} 53 54 MockPairingRegistryDelegate::MockPairingRegistryDelegate() { 55 } 56 57 MockPairingRegistryDelegate::~MockPairingRegistryDelegate() { 58 } 59 60 scoped_ptr<base::ListValue> MockPairingRegistryDelegate::LoadAll() { 61 scoped_ptr<base::ListValue> result(new base::ListValue()); 62 for (Pairings::const_iterator i = pairings_.begin(); i != pairings_.end(); 63 ++i) { 64 result->Append(i->second.ToValue().release()); 65 } 66 return result.Pass(); 67 } 68 69 bool MockPairingRegistryDelegate::DeleteAll() { 70 pairings_.clear(); 71 return true; 72 } 73 74 protocol::PairingRegistry::Pairing MockPairingRegistryDelegate::Load( 75 const std::string& client_id) { 76 Pairings::const_iterator i = pairings_.find(client_id); 77 if (i != pairings_.end()) { 78 return i->second; 79 } else { 80 return protocol::PairingRegistry::Pairing(); 81 } 82 } 83 84 bool MockPairingRegistryDelegate::Save( 85 const protocol::PairingRegistry::Pairing& pairing) { 86 pairings_[pairing.client_id()] = pairing; 87 return true; 88 } 89 90 bool MockPairingRegistryDelegate::Delete(const std::string& client_id) { 91 pairings_.erase(client_id); 92 return true; 93 } 94 95 SynchronousPairingRegistry::SynchronousPairingRegistry( 96 scoped_ptr<Delegate> delegate) 97 : PairingRegistry(base::ThreadTaskRunnerHandle::Get(), delegate.Pass()) { 98 } 99 100 SynchronousPairingRegistry::~SynchronousPairingRegistry() { 101 } 102 103 void SynchronousPairingRegistry::PostTask( 104 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 105 const tracked_objects::Location& from_here, 106 const base::Closure& task) { 107 DCHECK(task_runner->BelongsToCurrentThread()); 108 task.Run(); 109 } 110 111 } // namespace protocol 112 } // namespace remoting 113