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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
6 #define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
7
8 #include "remoting/protocol/pairing_registry.h"
9
10 #include "base/files/file_path.h"
11 #include "base/memory/weak_ptr.h"
12
13 namespace base {
14 class ListValue;
15 class TaskRunner;
16 } // namespace base
17
18 namespace remoting {
19
20 class PairingRegistryDelegateLinux
21 : public protocol::PairingRegistry::Delegate {
22 public:
23 explicit PairingRegistryDelegateLinux(
24 scoped_refptr<base::TaskRunner> task_runner);
25 virtual ~PairingRegistryDelegateLinux();
26
27 // PairingRegistry::Delegate interface
28 virtual void AddPairing(
29 const protocol::PairingRegistry::Pairing& new_paired_client,
30 const protocol::PairingRegistry::AddPairingCallback& callback) OVERRIDE;
31 virtual void GetPairing(
32 const std::string& client_id,
33 const protocol::PairingRegistry::GetPairingCallback& callback) OVERRIDE;
34
35 private:
36 FRIEND_TEST_ALL_PREFIXES(PairingRegistryDelegateLinuxTest, SaveAndLoad);
37
38 // Blocking helper methods run using the TaskRunner passed to the ctor.
39 void DoAddPairing(
40 const protocol::PairingRegistry::Pairing& new_paired_client,
41 const protocol::PairingRegistry::AddPairingCallback& callback);
42 void DoGetPairing(
43 const std::string& client_id,
44 const protocol::PairingRegistry::GetPairingCallback& callback);
45
46 // Run the delegate callbacks on their original thread.
47 static void RunAddPairingCallbackOnThread(
48 scoped_refptr<base::TaskRunner> task_runner,
49 const protocol::PairingRegistry::AddPairingCallback& callback,
50 bool success);
51 static void RunGetPairingCallbackOnThread(
52 scoped_refptr<base::TaskRunner> task_runner,
53 const protocol::PairingRegistry::GetPairingCallback& callback,
54 protocol::PairingRegistry::Pairing pairing);
55
56 // Helper methods to load and save the pairing registry.
57 protocol::PairingRegistry::PairedClients LoadPairings();
58 void SavePairings(
59 const protocol::PairingRegistry::PairedClients& paired_clients);
60
61 // Return the path to the file to use for loading and saving paired clients.
62 base::FilePath GetRegistryFilePath();
63
64 // For testing purposes, set the path returned by |GetRegistryFilePath|.
65 void SetFilenameForTesting(const base::FilePath &filename);
66
67 scoped_refptr<base::TaskRunner> task_runner_;
68 base::FilePath filename_for_testing_;
69
70 base::WeakPtrFactory<PairingRegistryDelegateLinux> weak_factory_;
71
72 DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateLinux);
73 };
74
75 } // namespace remoting
76
77 #endif // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698