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

Unified Diff: remoting/host/pairing_registry_delegate_linux.h

Issue 15709005: Linux pairing registry delegate implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer feedback. 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
Index: remoting/host/pairing_registry_delegate_linux.h
diff --git a/remoting/host/pairing_registry_delegate_linux.h b/remoting/host/pairing_registry_delegate_linux.h
new file mode 100644
index 0000000000000000000000000000000000000000..1114b5703652ba8589ecfdc3bbac3ba6596f8711
--- /dev/null
+++ b/remoting/host/pairing_registry_delegate_linux.h
@@ -0,0 +1,74 @@
+// 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;
+} // namespace base
+
+namespace remoting {
+namespace protocol {
+
+class PairingRegistryDelegateLinux : public PairingRegistry::Delegate {
+ public:
+ explicit PairingRegistryDelegateLinux(
+ scoped_refptr<base::TaskRunner> task_runner);
+ virtual ~PairingRegistryDelegateLinux();
+
+ // PairingRegistry::Delegate interface
+ virtual void AddPairing(
+ const PairingRegistry::Pairing& new_paired_client,
+ const PairingRegistry::AddPairingCallback& callback) OVERRIDE;
+ virtual void GetPairing(
+ const std::string& client_id,
+ const PairingRegistry::GetPairingCallback& callback) OVERRIDE;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, SaveAndLoad);
+
+ // Blocking helper methods run using the TaskRunner passed to the ctor.
+ void DoAddPairing(const PairingRegistry::Pairing& new_paired_client,
+ const PairingRegistry::AddPairingCallback& callback);
+ void DoGetPairing(const std::string& client_id,
+ const PairingRegistry::GetPairingCallback& callback);
+
+ // Run the delegate callbacks on their original thread.
+ void RunAddPairingCallbackOnThread(
+ scoped_refptr<base::TaskRunner> task_runner,
+ const PairingRegistry::AddPairingCallback& callback,
+ bool success);
+ void RunGetPairingCallbackOnThread(
+ scoped_refptr<base::TaskRunner> task_runner,
+ const PairingRegistry::GetPairingCallback& callback,
+ PairingRegistry::Pairing pairing);
+
+ // Helper methods to load and save the pairing registry.
+ PairingRegistry::PairedClients LoadPairings();
+ void SavePairings(const 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 protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
« no previous file with comments | « no previous file | remoting/host/pairing_registry_delegate_linux.cc » ('j') | remoting/host/pairing_registry_delegate_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698