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