Chromium Code Reviews| 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 #ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ | 5 #ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
| 6 #define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ | 6 #define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 return pairings_json_; | 215 return pairings_json_; |
| 216 } | 216 } |
| 217 | 217 |
| 218 // PairingRegistry::Delegate implementation. | 218 // PairingRegistry::Delegate implementation. |
| 219 virtual void Save( | 219 virtual void Save( |
| 220 const std::string& pairings_json, | 220 const std::string& pairings_json, |
| 221 const PairingRegistry::SaveCallback& callback) OVERRIDE; | 221 const PairingRegistry::SaveCallback& callback) OVERRIDE; |
| 222 virtual void Load( | 222 virtual void Load( |
| 223 const PairingRegistry::LoadCallback& callback) OVERRIDE; | 223 const PairingRegistry::LoadCallback& callback) OVERRIDE; |
| 224 | 224 |
| 225 // By default, the Save method runs its callback automatically because the | |
| 226 // negotiating authenticator unit test does not provide any hooks to do it | |
| 227 // manually. For unit tests that need to verify correct behaviour under | |
|
Lambros
2013/07/18 20:34:51
optional: I think it's strange to have the negotia
Jamie
2013/07/18 22:44:56
I think it makes sense because the focus of the te
| |
| 228 // asynchronous conditions, use this method to disable this feature and call | |
| 229 // RunCallback as appropriate. | |
| 230 void set_run_save_callback_automatically( | |
| 231 bool run_save_callback_automatically) { | |
| 232 run_save_callback_automatically_ = run_save_callback_automatically; | |
| 233 } | |
| 234 | |
| 235 bool HasCallback() { | |
| 236 return !load_callback_.is_null() || !save_callback_.is_null(); | |
|
Lambros
2013/07/18 20:34:51
nit: Move to .cc file? I think clang might trigger
Jamie
2013/07/18 22:44:56
I've made it const, but I think this is simple eno
| |
| 237 } | |
| 238 | |
| 239 // Run either the save or the load callback (whichever was set most recently; | |
| 240 // it is an error for both of these to be set at the same time). | |
| 225 void RunCallback(); | 241 void RunCallback(); |
| 226 | 242 |
| 227 private: | 243 private: |
| 244 void SetPairingsJsonAndRunCallback( | |
| 245 const std::string& pairings_json, | |
| 246 const PairingRegistry::SaveCallback& callback); | |
| 247 | |
| 228 base::Closure load_callback_; | 248 base::Closure load_callback_; |
| 249 base::Closure save_callback_; | |
| 229 std::string pairings_json_; | 250 std::string pairings_json_; |
| 251 bool run_save_callback_automatically_; | |
| 230 }; | 252 }; |
| 231 | 253 |
| 232 } // namespace protocol | 254 } // namespace protocol |
| 233 } // namespace remoting | 255 } // namespace remoting |
| 234 | 256 |
| 235 #endif // REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ | 257 #endif // REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
| OLD | NEW |