OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/protocol/protocol_mock_objects.h" | 5 #include "remoting/protocol/protocol_mock_objects.h" |
6 | 6 |
7 namespace remoting { | 7 namespace remoting { |
8 namespace protocol { | 8 namespace protocol { |
9 | 9 |
10 MockConnectionToClient::MockConnectionToClient( | 10 MockConnectionToClient::MockConnectionToClient( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 MockSessionManager::MockSessionManager() {} | 47 MockSessionManager::MockSessionManager() {} |
48 | 48 |
49 MockSessionManager::~MockSessionManager() {} | 49 MockSessionManager::~MockSessionManager() {} |
50 | 50 |
51 MockPairingRegistryDelegate::MockPairingRegistryDelegate() { | 51 MockPairingRegistryDelegate::MockPairingRegistryDelegate() { |
52 } | 52 } |
53 | 53 |
54 MockPairingRegistryDelegate::~MockPairingRegistryDelegate() { | 54 MockPairingRegistryDelegate::~MockPairingRegistryDelegate() { |
55 } | 55 } |
56 | 56 |
57 void MockPairingRegistryDelegate::AddPairing( | 57 void MockPairingRegistryDelegate::Save( |
58 const PairingRegistry::Pairing& new_paired_client, | 58 const std::string& pairings_json, |
59 const PairingRegistry::AddPairingCallback& callback) { | 59 const PairingRegistry::SaveCallback& callback) { |
60 paired_clients_[new_paired_client.client_id()] = new_paired_client; | 60 pairings_json_ = pairings_json; |
61 if (!callback.is_null()) { | 61 if (!callback.is_null()) { |
62 callback.Run(true); | 62 callback.Run(true); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 void MockPairingRegistryDelegate::GetPairing( | 66 void MockPairingRegistryDelegate::Load( |
67 const std::string& client_id, | 67 const PairingRegistry::LoadCallback& callback) { |
68 const PairingRegistry::GetPairingCallback& callback) { | 68 load_callback_ = base::Bind(base::Bind(callback), pairings_json_); |
69 PairingRegistry::Pairing result; | |
70 PairingRegistry::PairedClients::const_iterator i = | |
71 paired_clients_.find(client_id); | |
72 if (i != paired_clients_.end()) { | |
73 result = i->second; | |
74 } | |
75 saved_callback_ = base::Bind(base::Bind(callback), result); | |
76 } | 69 } |
77 | 70 |
78 void MockPairingRegistryDelegate::RunCallback() { | 71 void MockPairingRegistryDelegate::RunCallback() { |
79 DCHECK(!saved_callback_.is_null()); | 72 DCHECK(!load_callback_.is_null()); |
80 saved_callback_.Run(); | 73 load_callback_.Run(); |
81 saved_callback_.Reset(); | 74 load_callback_.Reset(); |
82 } | 75 } |
83 | 76 |
84 } // namespace protocol | 77 } // namespace protocol |
85 } // namespace remoting | 78 } // namespace remoting |
OLD | NEW |