Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1633)

Unified Diff: remoting/protocol/protocol_mock_objects.h

Issue 21128006: Refactored PairingRegistry::Delegate such that it can retrieve/modify for a single client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/pairing_registry_unittest.cc ('k') | remoting/protocol/protocol_mock_objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..74435dbb486a5c48d0957ca348ade5c7cd5b2203 100644
--- a/remoting/protocol/protocol_mock_objects.h
+++ b/remoting/protocol/protocol_mock_objects.h
@@ -5,8 +5,12 @@
#ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_
#define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_
+#include <map>
#include <string>
+#include "base/location.h"
+#include "base/single_thread_task_runner.h"
+#include "base/values.h"
#include "net/base/ip_endpoint.h"
#include "remoting/proto/internal.pb.h"
#include "remoting/proto/video.pb.h"
@@ -211,44 +215,31 @@ 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 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;
- }
+ virtual scoped_ptr<base::ListValue> LoadAll() OVERRIDE;
+ virtual bool DeleteAll() OVERRIDE;
+ virtual protocol::PairingRegistry::Pairing Load(
+ const std::string& client_id) OVERRIDE;
+ virtual bool Save(const protocol::PairingRegistry::Pairing& pairing) OVERRIDE;
+ virtual bool Delete(const std::string& client_id) OVERRIDE;
- bool HasCallback() const {
- return !load_callback_.is_null() || !save_callback_.is_null();
- }
+ private:
+ typedef std::map<std::string, protocol::PairingRegistry::Pairing> Pairings;
+ Pairings pairings_;
+};
+
+class SynchronousPairingRegistry : public PairingRegistry {
+ public:
+ explicit SynchronousPairingRegistry(scoped_ptr<Delegate> delegate);
- // 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();
+ protected:
+ virtual ~SynchronousPairingRegistry();
- 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_;
+ // Runs tasks synchronously instead of posting them to |task_runner|.
+ virtual void PostTask(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task) OVERRIDE;
};
} // namespace protocol
« no previous file with comments | « remoting/protocol/pairing_registry_unittest.cc ('k') | remoting/protocol/protocol_mock_objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698