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

Unified Diff: remoting/host/pairing_registry_delegate_linux.h

Issue 21128006: Refactored PairingRegistry::Delegate such that it can retrieve/modify for a single client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cosmetic 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
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
index 08c073b533ce1078b6b0cabbf0ba5c7ad6541f32..a73f68acc4a34f330bf71ad46b3e7224ca179bfb 100644
--- a/remoting/host/pairing_registry_delegate_linux.h
+++ b/remoting/host/pairing_registry_delegate_linux.h
@@ -8,11 +8,9 @@
#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 {
@@ -20,50 +18,30 @@ namespace remoting {
class PairingRegistryDelegateLinux
: public protocol::PairingRegistry::Delegate {
public:
- explicit PairingRegistryDelegateLinux(
- scoped_refptr<base::TaskRunner> task_runner);
+ PairingRegistryDelegateLinux();
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;
+ virtual scoped_ptr<base::ListValue> LoadAll() OVERRIDE;
+ virtual bool DeleteAll() OVERRIDE;
+ virtual protocol::PairingRegistry::Pairing Load(
+ const std::string& client_id) OVERRIDE;
+ virtual bool Save(const protocol::PairingRegistry::Pairing& pairing) OVERRIDE;
+ virtual bool Delete(const std::string& client_id) OVERRIDE;
private:
+ FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, Empty);
+ FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, Delete);
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);
+ // Return the path to the directory to use for loading and saving paired
+ // clients.
+ base::FilePath GetRegistryPath();
- // 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);
+ // For testing purposes, set the path returned by |GetRegistryPath()|.
+ void SetRegistryPathForTesting(const base::FilePath& registry_path);
- // 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_;
+ base::FilePath registry_path_for_testing_;
DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateLinux);
};

Powered by Google App Engine
This is Rietveld 408576698