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 30 matching lines...) Expand all Loading... | |
41 MockVideoStub::~MockVideoStub() {} | 41 MockVideoStub::~MockVideoStub() {} |
42 | 42 |
43 MockSession::MockSession() {} | 43 MockSession::MockSession() {} |
44 | 44 |
45 MockSession::~MockSession() {} | 45 MockSession::~MockSession() {} |
46 | 46 |
47 MockSessionManager::MockSessionManager() {} | 47 MockSessionManager::MockSessionManager() {} |
48 | 48 |
49 MockSessionManager::~MockSessionManager() {} | 49 MockSessionManager::~MockSessionManager() {} |
50 | 50 |
51 MockPairingRegistryDelegate::MockPairingRegistryDelegate() { | 51 MockPairingRegistryDelegate::MockPairingRegistryDelegate() |
52 : run_save_callback_automatically_(true) { | |
52 } | 53 } |
53 | 54 |
54 MockPairingRegistryDelegate::~MockPairingRegistryDelegate() { | 55 MockPairingRegistryDelegate::~MockPairingRegistryDelegate() { |
55 } | 56 } |
56 | 57 |
57 void MockPairingRegistryDelegate::Save( | 58 void MockPairingRegistryDelegate::Save( |
58 const std::string& pairings_json, | 59 const std::string& pairings_json, |
59 const PairingRegistry::SaveCallback& callback) { | 60 const PairingRegistry::SaveCallback& callback) { |
61 DCHECK(load_callback_.is_null()); | |
Lambros
2013/07/18 20:34:51
Use ASSERT_TRUE here and elsewhere instead of DCHE
Jamie
2013/07/18 22:44:56
Done.
| |
62 DCHECK(save_callback_.is_null()); | |
63 if (run_save_callback_automatically_) { | |
64 SetPairingsJsonAndRunCallback(pairings_json, callback); | |
65 } else { | |
66 save_callback_ = base::Bind( | |
67 &MockPairingRegistryDelegate::SetPairingsJsonAndRunCallback, | |
68 base::Unretained(this), pairings_json, callback); | |
69 } | |
70 } | |
71 | |
72 void MockPairingRegistryDelegate::SetPairingsJsonAndRunCallback( | |
73 const std::string& pairings_json, | |
74 const PairingRegistry::SaveCallback& callback) { | |
60 pairings_json_ = pairings_json; | 75 pairings_json_ = pairings_json; |
61 if (!callback.is_null()) { | 76 if (!callback.is_null()) { |
62 callback.Run(true); | 77 callback.Run(true); |
63 } | 78 } |
64 } | 79 } |
65 | 80 |
66 void MockPairingRegistryDelegate::Load( | 81 void MockPairingRegistryDelegate::Load( |
67 const PairingRegistry::LoadCallback& callback) { | 82 const PairingRegistry::LoadCallback& callback) { |
83 DCHECK(load_callback_.is_null()); | |
84 DCHECK(save_callback_.is_null()); | |
68 load_callback_ = base::Bind(base::Bind(callback), pairings_json_); | 85 load_callback_ = base::Bind(base::Bind(callback), pairings_json_); |
Lambros
2013/07/18 20:34:51
optional: Remove inner base::Bind ?
| |
69 } | 86 } |
70 | 87 |
71 void MockPairingRegistryDelegate::RunCallback() { | 88 void MockPairingRegistryDelegate::RunCallback() { |
72 DCHECK(!load_callback_.is_null()); | 89 DCHECK(load_callback_.is_null() ^ save_callback_.is_null()); |
Lambros
2013/07/18 20:34:51
Split this up, otherwise the test output won't tel
Jamie
2013/07/18 22:44:56
Done.
| |
73 load_callback_.Run(); | 90 if (!load_callback_.is_null()) { |
74 load_callback_.Reset(); | 91 base::Closure load_callback = load_callback_; |
92 load_callback_.Reset(); | |
93 load_callback.Run(); | |
94 } else { | |
95 base::Closure save_callback = save_callback_; | |
96 save_callback_.Reset(); | |
97 save_callback.Run(); | |
98 } | |
75 } | 99 } |
76 | 100 |
77 } // namespace protocol | 101 } // namespace protocol |
78 } // namespace remoting | 102 } // namespace remoting |
OLD | NEW |