Chromium Code Reviews| Index: remoting/protocol/pairing_registry.h |
| diff --git a/remoting/protocol/pairing_registry.h b/remoting/protocol/pairing_registry.h |
| index 48893561e8ae14a3220fe061e015aee557bf300c..4a9769ab41917d2965750de8e7e04ce56ddcafcd 100644 |
| --- a/remoting/protocol/pairing_registry.h |
| +++ b/remoting/protocol/pairing_registry.h |
| @@ -12,6 +12,11 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/threading/non_thread_safe.h" |
| +#include "base/time.h" |
| + |
| +namespace base { |
| +class TaskRunner; |
| +} // namespace base |
| namespace remoting { |
| namespace protocol { |
| @@ -29,6 +34,9 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>, |
| public base::NonThreadSafe { |
| public: |
| struct Pairing { |
| + bool operator==(const Pairing& other) const; |
| + |
| + base::Time created_time; |
|
Jamie
2013/05/31 01:14:22
Not strictly related to this CL, and I'm not sure
|
| std::string client_id; |
| std::string client_name; |
| std::string shared_secret; |
| @@ -44,6 +52,14 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>, |
| // Save pairing information to persistent storage. Must not block. |
| virtual void Save(const PairedClients& paired_clients) = 0; |
| + |
| + // Load the pairing information synchronously from persistent storage. |
| + // Note that this method is not used by the PairingRegistry class; instead |
| + // it should be called on the result of CreateDelegate prior to creating |
| + // a PairingRegistry. Unlike Save, LoadOnCurrentThread may block while |
| + // loading the pairings--it is the caller's responsibility to make sure |
| + // it is called on a suitable thread. |
| + virtual PairedClients LoadOnCurrentThread() = 0; |
| }; |
| explicit PairingRegistry(scoped_ptr<Delegate> delegate, |
| @@ -56,6 +72,12 @@ class PairingRegistry : public base::RefCountedThreadSafe<PairingRegistry>, |
| // string if the client id is not known. |
| std::string GetSecret(const std::string &client_id) const; |
| + // Return a platform-specific Delegate that will save to permanent storage |
| + // using the specified TaskRunner. Return NULL on platforms that don't |
| + // support pairing. |
| + static scoped_ptr<Delegate> CreateDelegate( |
| + scoped_refptr<base::TaskRunner> task_runner); |
| + |
| private: |
| friend class base::RefCountedThreadSafe<PairingRegistry>; |
| @@ -77,6 +99,7 @@ class NotImplementedPairingRegistryDelegate : public PairingRegistry::Delegate { |
| public: |
| virtual void Save( |
| const PairingRegistry::PairedClients& paired_clients) OVERRIDE; |
| + virtual PairingRegistry::PairedClients LoadOnCurrentThread() OVERRIDE; |
| }; |
| } // namespace protocol |