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

Side by Side 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: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_ 5 #ifndef REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
6 #define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_ 6 #define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
7 7
8 #include "remoting/protocol/pairing_registry.h" 8 #include "remoting/protocol/pairing_registry.h"
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 12
13 namespace base { 13 namespace base {
14 class ListValue; 14 class ListValue;
15 class TaskRunner; 15 class TaskRunner;
16 } // namespace base 16 } // namespace base
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 class PairingRegistryDelegateLinux 20 class PairingRegistryDelegateLinux
21 : public protocol::PairingRegistry::Delegate { 21 : public protocol::PairingRegistry::Delegate {
22 public: 22 public:
23 explicit PairingRegistryDelegateLinux( 23 explicit PairingRegistryDelegateLinux(
24 scoped_refptr<base::TaskRunner> task_runner); 24 scoped_refptr<base::TaskRunner> task_runner);
25 virtual ~PairingRegistryDelegateLinux(); 25 virtual ~PairingRegistryDelegateLinux();
26 26
27 // PairingRegistry::Delegate interface 27 // PairingRegistry::Delegate interface
28 virtual void LoadAll(
29 const protocol::PairingRegistry::GetAllPairingsCallback& callback)
30 OVERRIDE;
31 virtual void DeleteAll(
32 const protocol::PairingRegistry::DoneCallback& callback) OVERRIDE;
33 virtual void Load(
34 const std::string& client_id,
35 const protocol::PairingRegistry::GetPairingCallback& callback) OVERRIDE;
28 virtual void Save( 36 virtual void Save(
29 const std::string& pairings_json, 37 const protocol::PairingRegistry::Pairing& pairing,
30 const protocol::PairingRegistry::SaveCallback& callback) OVERRIDE; 38 const protocol::PairingRegistry::DoneCallback& callback) OVERRIDE;
31 virtual void Load( 39 virtual void Delete(
32 const protocol::PairingRegistry::LoadCallback& callback) OVERRIDE; 40 const std::string& client_id,
41 const protocol::PairingRegistry::DoneCallback& callback) OVERRIDE;
33 42
34 private: 43 private:
35 FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, SaveAndLoad); 44 FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, SaveAndLoad);
36 45
37 // Blocking helper methods run using the TaskRunner passed to the ctor. 46 // Blocking helper methods run using the TaskRunner passed to the ctor.
38 void DoSave(const std::string& pairings_json, 47 void DoLoadAll(
39 const protocol::PairingRegistry::SaveCallback& callback); 48 const protocol::PairingRegistry::GetAllPairingsCallback& callback);
40 void DoLoad(const protocol::PairingRegistry::LoadCallback& callback); 49 void DoDeleteAll(
50 const protocol::PairingRegistry::DoneCallback& callback);
51 void DoLoad(
52 const std::string& client_id,
53 const protocol::PairingRegistry::GetPairingCallback& callback);
54 void DoSave(
55 const protocol::PairingRegistry::Pairing& pairing,
56 const protocol::PairingRegistry::DoneCallback& callback);
57 void DoDelete(
58 const std::string& client_id,
59 const protocol::PairingRegistry::DoneCallback& callback);
41 60
42 // Run the delegate callbacks on their original thread. 61 // Run the delegate callbacks on their original thread.
43 static void RunSaveCallbackOnThread( 62 static void RunDoneCallbackOnThread(
44 scoped_refptr<base::TaskRunner> task_runner, 63 scoped_refptr<base::TaskRunner> task_runner,
45 const protocol::PairingRegistry::SaveCallback& callback, 64 const protocol::PairingRegistry::DoneCallback& callback,
46 bool success); 65 bool success);
47 static void RunLoadCallbackOnThread( 66 static void RunGetAllPairingsCallbackOnThread(
48 scoped_refptr<base::TaskRunner> task_runner, 67 scoped_refptr<base::TaskRunner> task_runner,
49 const protocol::PairingRegistry::LoadCallback& callback, 68 const protocol::PairingRegistry::GetAllPairingsCallback& callback,
50 const std::string& pairings_json); 69 scoped_ptr<base::ListValue> pairings);
70 static void RunGetPairingCallbackOnThread(
71 scoped_refptr<base::TaskRunner> task_runner,
72 const protocol::PairingRegistry::GetPairingCallback& callback,
73 protocol::PairingRegistry::Pairing pairing);
51 74
52 // Helper methods to load and save the pairing registry. 75 // Return the path to the directory to use for loading and saving paired
53 protocol::PairingRegistry::PairedClients LoadPairings(); 76 // clients.
54 void SavePairings( 77 base::FilePath GetRegistryPath();
55 const protocol::PairingRegistry::PairedClients& paired_clients);
56 78
57 // Return the path to the file to use for loading and saving paired clients. 79 // For testing purposes, set the path returned by |GetRegistryPath()|.
58 base::FilePath GetRegistryFilePath(); 80 void SetRegistryPathForTesting(const base::FilePath& registry_path);
59
60 // For testing purposes, set the path returned by |GetRegistryFilePath|.
61 void SetFilenameForTesting(const base::FilePath &filename);
62 81
63 scoped_refptr<base::TaskRunner> task_runner_; 82 scoped_refptr<base::TaskRunner> task_runner_;
64 base::FilePath filename_for_testing_; 83 base::FilePath registry_path_for_testing_;
65 84
66 base::WeakPtrFactory<PairingRegistryDelegateLinux> weak_factory_; 85 base::WeakPtrFactory<PairingRegistryDelegateLinux> weak_factory_;
67 86
68 DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateLinux); 87 DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateLinux);
69 }; 88 };
70 89
71 } // namespace remoting 90 } // namespace remoting
72 91
73 #endif // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_ 92 #endif // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
OLDNEW
« 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