summaryrefslogtreecommitdiffstats
path: root/remoting/host/pairing_registry_delegate_linux.h
diff options
context:
space:
mode:
authorjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-23 14:10:30 +0000
committerjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-23 14:10:30 +0000
commitb1ae901f706f60fb1628d6f2254869265a97a2b3 (patch)
tree633d8e62314fa6593f634b39b8942976430c5271 /remoting/host/pairing_registry_delegate_linux.h
parent2885f9cbf2dc9b5217373147b5e2b61319362449 (diff)
downloadchromium_src-b1ae901f706f60fb1628d6f2254869265a97a2b3.zip
chromium_src-b1ae901f706f60fb1628d6f2254869265a97a2b3.tar.gz
chromium_src-b1ae901f706f60fb1628d6f2254869265a97a2b3.tar.bz2
Linux pairing registry delegate implementation
BUG=156182 Review URL: https://chromiumcodereview.appspot.com/15709005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/pairing_registry_delegate_linux.h')
-rw-r--r--remoting/host/pairing_registry_delegate_linux.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/remoting/host/pairing_registry_delegate_linux.h b/remoting/host/pairing_registry_delegate_linux.h
new file mode 100644
index 0000000..08c073b
--- /dev/null
+++ b/remoting/host/pairing_registry_delegate_linux.h
@@ -0,0 +1,73 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
+#define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
+
+#include "remoting/protocol/pairing_registry.h"
+
+#include "base/files/file_path.h"
+#include "base/memory/weak_ptr.h"
+
+namespace base {
+class ListValue;
+class TaskRunner;
+} // namespace base
+
+namespace remoting {
+
+class PairingRegistryDelegateLinux
+ : public protocol::PairingRegistry::Delegate {
+ public:
+ explicit PairingRegistryDelegateLinux(
+ scoped_refptr<base::TaskRunner> task_runner);
+ virtual ~PairingRegistryDelegateLinux();
+
+ // PairingRegistry::Delegate interface
+ virtual void Save(
+ const std::string& pairings_json,
+ const protocol::PairingRegistry::SaveCallback& callback) OVERRIDE;
+ virtual void Load(
+ const protocol::PairingRegistry::LoadCallback& callback) OVERRIDE;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, SaveAndLoad);
+
+ // Blocking helper methods run using the TaskRunner passed to the ctor.
+ void DoSave(const std::string& pairings_json,
+ const protocol::PairingRegistry::SaveCallback& callback);
+ void DoLoad(const protocol::PairingRegistry::LoadCallback& callback);
+
+ // Run the delegate callbacks on their original thread.
+ static void RunSaveCallbackOnThread(
+ scoped_refptr<base::TaskRunner> task_runner,
+ const protocol::PairingRegistry::SaveCallback& callback,
+ bool success);
+ static void RunLoadCallbackOnThread(
+ scoped_refptr<base::TaskRunner> task_runner,
+ const protocol::PairingRegistry::LoadCallback& callback,
+ const std::string& pairings_json);
+
+ // Helper methods to load and save the pairing registry.
+ protocol::PairingRegistry::PairedClients LoadPairings();
+ void SavePairings(
+ const protocol::PairingRegistry::PairedClients& paired_clients);
+
+ // Return the path to the file to use for loading and saving paired clients.
+ base::FilePath GetRegistryFilePath();
+
+ // For testing purposes, set the path returned by |GetRegistryFilePath|.
+ void SetFilenameForTesting(const base::FilePath &filename);
+
+ scoped_refptr<base::TaskRunner> task_runner_;
+ base::FilePath filename_for_testing_;
+
+ base::WeakPtrFactory<PairingRegistryDelegateLinux> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateLinux);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_