Index: remoting/protocol/protocol_mock_objects.h |
diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h |
index cfb912b71f873843c9011e9bd6fb6b9f611f2a69..6fdab1aae59f4bf48535d6eea8bc23915a9bce9d 100644 |
--- a/remoting/protocol/protocol_mock_objects.h |
+++ b/remoting/protocol/protocol_mock_objects.h |
@@ -5,8 +5,10 @@ |
#ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
#define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
+#include <map> |
#include <string> |
+#include "base/values.h" |
#include "net/base/ip_endpoint.h" |
#include "remoting/proto/internal.pb.h" |
#include "remoting/proto/video.pb.h" |
@@ -211,44 +213,46 @@ class MockPairingRegistryDelegate : public PairingRegistry::Delegate { |
MockPairingRegistryDelegate(); |
virtual ~MockPairingRegistryDelegate(); |
- const std::string& pairings_json() const { |
- return pairings_json_; |
- } |
- |
// PairingRegistry::Delegate implementation. |
- virtual void Save( |
- const std::string& pairings_json, |
- const PairingRegistry::SaveCallback& callback) OVERRIDE; |
+ virtual void LoadAll( |
+ const protocol::PairingRegistry::GetAllPairingsCallback& callback) |
+ OVERRIDE; |
+ virtual void DeleteAll( |
+ const protocol::PairingRegistry::DoneCallback& callback) OVERRIDE; |
virtual void Load( |
- const PairingRegistry::LoadCallback& callback) OVERRIDE; |
- |
- // By default, the Save method runs its callback automatically because the |
- // negotiating authenticator unit test does not provide any hooks to do it |
- // manually. For unit tests that need to verify correct behaviour under |
- // asynchronous conditions, use this method to disable this feature and call |
- // RunCallback as appropriate. |
- void set_run_save_callback_automatically( |
- bool run_save_callback_automatically) { |
- run_save_callback_automatically_ = run_save_callback_automatically; |
- } |
- |
- bool HasCallback() const { |
- return !load_callback_.is_null() || !save_callback_.is_null(); |
- } |
+ const std::string& client_id, |
+ const protocol::PairingRegistry::GetPairingCallback& callback) OVERRIDE; |
+ virtual void Save( |
+ const protocol::PairingRegistry::Pairing& pairing, |
+ const protocol::PairingRegistry::DoneCallback& callback) OVERRIDE; |
+ virtual void Delete( |
+ const std::string& client_id, |
+ const protocol::PairingRegistry::DoneCallback& callback) OVERRIDE; |
- // Run either the save or the load callback (whichever was set most recently; |
- // it is an error for both of these to be set at the same time). |
- void RunCallback(); |
+ // Run |pending_callback_| if set. Keeps running until |pending_callback_| is |
+ // not set. This is needed for the case when a callback in turn sets |
+ // |pending_callback_|. |
+ void DrainCallbacks(); |
private: |
- void SetPairingsJsonAndRunCallback( |
- const std::string& pairings_json, |
- const PairingRegistry::SaveCallback& callback); |
- |
- base::Closure load_callback_; |
- base::Closure save_callback_; |
- std::string pairings_json_; |
- bool run_save_callback_automatically_; |
+ void DoLoadAll( |
+ const protocol::PairingRegistry::GetAllPairingsCallback& callback); |
+ void DoDeleteAll( |
+ const protocol::PairingRegistry::DoneCallback& callback); |
+ void DoLoad( |
+ const std::string& client_id, |
+ const protocol::PairingRegistry::GetPairingCallback& callback); |
+ void DoSave( |
+ const protocol::PairingRegistry::Pairing& pairing, |
+ const protocol::PairingRegistry::DoneCallback& callback); |
+ void DoDelete( |
+ const std::string& client_id, |
+ const protocol::PairingRegistry::DoneCallback& callback); |
+ |
+ base::Closure pending_callback_; |
+ |
+ typedef std::map<std::string, protocol::PairingRegistry::Pairing> Pairings; |
+ Pairings pairings_; |
}; |
} // namespace protocol |