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

Unified Diff: remoting/protocol/pairing_registry.h

Issue 19714002: Add serialization to PairingRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer feedback. 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 | « no previous file | remoting/protocol/pairing_registry.cc » ('j') | remoting/protocol/pairing_registry.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/pairing_registry.h
diff --git a/remoting/protocol/pairing_registry.h b/remoting/protocol/pairing_registry.h
index f6536a2e72efc23bb13f8545805e8d1a4dd56b8e..fc63e84c91079577cb71a532184029a7b0b03fdf 100644
--- a/remoting/protocol/pairing_registry.h
+++ b/remoting/protocol/pairing_registry.h
@@ -6,6 +6,7 @@
#define REMOTING_PROTOCOL_PAIRING_REGISTRY_H_
#include <map>
+#include <queue>
#include <string>
#include <vector>
@@ -127,8 +128,13 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>,
virtual ~PairingRegistry();
+ // Helper method for unit tests.
void AddPairing(const Pairing& pairing);
+
+ // Worker functions for each of the public methods, passed as a callback to
+ // the delegate.
void MergePairingAndSave(const Pairing& pairing,
+ const SaveCallback& callback,
const std::string& pairings_json);
void DoGetPairing(const std::string& client_id,
const GetPairingCallback& callback,
@@ -139,6 +145,22 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>,
const SaveCallback& callback,
const std::string& pairings_json);
+ // "Trampoline" callbacks that schedule the next pending request and then
+ // invoke the original caller-supplied callback.
+ void InvokeLoadCallbackAndScheduleNext(
+ const LoadCallback& callback, const std::string& pairings_json);
+ void InvokeSaveCallbackAndScheduleNext(
+ const SaveCallback& callback, bool success);
+ void InvokeGetPairingCallbackAndScheduleNext(
+ const GetPairingCallback& callback, Pairing pairing);
+ void InvokeGetAllPairingsCallbackAndScheduleNext(
+ const GetAllPairingsCallback& callback,
+ scoped_ptr<base::ListValue> pairings);
+
+ // Queue management methods.
+ void ServiceOrQueueRequest(const base::Closure& request);
+ void ServiceNextRequest();
+
// Translate between the structured and serialized forms of the pairing data.
static PairedClients DecodeJson(const std::string& pairings_json);
static std::string EncodeJson(const PairedClients& clients);
@@ -148,6 +170,8 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>,
scoped_ptr<Delegate> delegate_;
+ std::queue<base::Closure> pending_requests_;
+
DISALLOW_COPY_AND_ASSIGN(PairingRegistry);
};
« no previous file with comments | « no previous file | remoting/protocol/pairing_registry.cc » ('j') | remoting/protocol/pairing_registry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698