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 MockConnectionToClient(Session * session,HostStub * host_stub)13MockConnectionToClient::MockConnectionToClient( 14 Session* session, 15 HostStub* host_stub) 16 : ConnectionToClient(session) { 17 set_host_stub(host_stub); 18 } 19 ~MockConnectionToClient()20MockConnectionToClient::~MockConnectionToClient() {} 21 MockConnectionToClientEventHandler()22MockConnectionToClientEventHandler::MockConnectionToClientEventHandler() {} 23 ~MockConnectionToClientEventHandler()24MockConnectionToClientEventHandler::~MockConnectionToClientEventHandler() {} 25 MockClipboardStub()26MockClipboardStub::MockClipboardStub() {} 27 ~MockClipboardStub()28MockClipboardStub::~MockClipboardStub() {} 29 MockInputStub()30MockInputStub::MockInputStub() {} 31 ~MockInputStub()32MockInputStub::~MockInputStub() {} 33 MockHostStub()34MockHostStub::MockHostStub() {} 35 ~MockHostStub()36MockHostStub::~MockHostStub() {} 37 MockClientStub()38MockClientStub::MockClientStub() {} 39 ~MockClientStub()40MockClientStub::~MockClientStub() {} 41 MockVideoStub()42MockVideoStub::MockVideoStub() {} 43 ~MockVideoStub()44MockVideoStub::~MockVideoStub() {} 45 MockSession()46MockSession::MockSession() {} 47 ~MockSession()48MockSession::~MockSession() {} 49 MockSessionManager()50MockSessionManager::MockSessionManager() {} 51 ~MockSessionManager()52MockSessionManager::~MockSessionManager() {} 53 MockPairingRegistryDelegate()54MockPairingRegistryDelegate::MockPairingRegistryDelegate() { 55 } 56 ~MockPairingRegistryDelegate()57MockPairingRegistryDelegate::~MockPairingRegistryDelegate() { 58 } 59 LoadAll()60scoped_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 DeleteAll()69bool MockPairingRegistryDelegate::DeleteAll() { 70 pairings_.clear(); 71 return true; 72 } 73 Load(const std::string & client_id)74protocol::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 Save(const protocol::PairingRegistry::Pairing & pairing)84bool MockPairingRegistryDelegate::Save( 85 const protocol::PairingRegistry::Pairing& pairing) { 86 pairings_[pairing.client_id()] = pairing; 87 return true; 88 } 89 Delete(const std::string & client_id)90bool MockPairingRegistryDelegate::Delete(const std::string& client_id) { 91 pairings_.erase(client_id); 92 return true; 93 } 94 SynchronousPairingRegistry(scoped_ptr<Delegate> delegate)95SynchronousPairingRegistry::SynchronousPairingRegistry( 96 scoped_ptr<Delegate> delegate) 97 : PairingRegistry(base::ThreadTaskRunnerHandle::Get(), delegate.Pass()) { 98 } 99 ~SynchronousPairingRegistry()100SynchronousPairingRegistry::~SynchronousPairingRegistry() { 101 } 102 PostTask(const scoped_refptr<base::SingleThreadTaskRunner> & task_runner,const tracked_objects::Location & from_here,const base::Closure & task)103void 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