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

Unified Diff: remoting/protocol/pairing_registry.h

Issue 17063003: Changes to PairingRegistry to facilitate per-platform implementions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed spacing. Created 7 years, 6 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_host_authenticator.cc ('k') | remoting/protocol/pairing_registry.cc » ('j') | no next file with comments »
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 c32c54ffb044ea7f72ddb10d59742788504c826c..3f39c7e5d026dd6dcd83e7f1e5a4765e6ddbeecc 100644
--- a/remoting/protocol/pairing_registry.h
+++ b/remoting/protocol/pairing_registry.h
@@ -12,10 +12,14 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/threading/non_thread_safe.h"
+#include "base/time.h"
namespace remoting {
namespace protocol {
+// TODO(jamiewalch): This class is little more than a wrapper around the
+// Pairing and Delegate classes. Refactor it away.
+
// PairingRegistry holds information about paired clients to support
// PIN-less authentication. For each paired client, the registry holds
// the following information:
@@ -29,28 +33,54 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>,
public base::NonThreadSafe {
public:
struct Pairing {
- std::string client_id;
- std::string client_name;
- std::string shared_secret;
+ Pairing();
+ Pairing(const base::Time& created_time,
+ const std::string& client_name,
+ const std::string& client_id,
+ const std::string& shared_secret);
+ ~Pairing();
+
+ static Pairing Create(const std::string& client_name);
+
+ bool operator==(const Pairing& other) const;
+
+ base::Time created_time() const { return created_time_; }
+ std::string client_id() const { return client_id_; }
+ std::string client_name() const { return client_name_; }
+ std::string shared_secret() const { return shared_secret_; }
+
+ private:
+ base::Time created_time_;
+ std::string client_name_;
+ std::string client_id_;
+ std::string shared_secret_;
};
// Mapping from client id to pairing information.
typedef std::map<std::string, Pairing> PairedClients;
- // Delegate::GetPairing callback.
- typedef base::Callback<void(Pairing)> GetPairingCallback;
+ // Delegate callbacks.
+ typedef base::Callback<void(Pairing client_information)> GetPairingCallback;
+ typedef base::Callback<void(bool success)> AddPairingCallback;
// Interface representing the persistent storage back-end.
class Delegate {
public:
virtual ~Delegate() {}
- // Add pairing information to persistent storage. Must not block.
- virtual void AddPairing(const Pairing& new_paired_client) = 0;
+ // Add pairing information to persistent storage. If a non-NULL callback
+ // is provided, invoke it on completion to indicate success or failure.
+ // Must not block.
+ //
+ // TODO(jamiewalch): Plumb the callback into the RequestPairing flow so
+ // that the client isn't sent the pairing information until it has been
+ // saved.
+ virtual void AddPairing(const Pairing& new_paired_client,
+ const AddPairingCallback& callback) = 0;
// Retrieve the Pairing for the specified client id. If none is
// found, invoke the callback with a Pairing in which (at least)
- // the shared_secret is empty.
+ // the client_name is empty. Must not block.
rmsousa 2013/06/17 23:56:10 The check in the code is for client_id. client_nam
Jamie 2013/06/18 00:16:00 Done.
virtual void GetPairing(const std::string& client_id,
const GetPairingCallback& callback) = 0;
};
@@ -80,7 +110,8 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>,
class NotImplementedPairingRegistryDelegate : public PairingRegistry::Delegate {
public:
virtual void AddPairing(
- const PairingRegistry::Pairing& paired_clients) OVERRIDE;
+ const PairingRegistry::Pairing& paired_clients,
+ const PairingRegistry::AddPairingCallback& callback) OVERRIDE;
virtual void GetPairing(
const std::string& client_id,
const PairingRegistry::GetPairingCallback& callback) OVERRIDE;
« no previous file with comments | « remoting/protocol/pairing_host_authenticator.cc ('k') | remoting/protocol/pairing_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698