OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "components/cryptauth/remote_device.h" | 15 #include "components/cryptauth/remote_device.h" |
16 | 16 |
17 namespace cryptauth { | 17 namespace cryptauth { |
18 class CryptAuthDeviceManager; | 18 class CryptAuthDeviceManager; |
| 19 class CryptAuthService; |
19 class RemoteDeviceLoader; | 20 class RemoteDeviceLoader; |
20 class SecureMessageDelegate; | |
21 } // namespace cryptauth | 21 } // namespace cryptauth |
22 | 22 |
23 namespace chromeos { | 23 namespace chromeos { |
24 | 24 |
25 namespace tether { | 25 namespace tether { |
26 | 26 |
27 // Fetches RemoteDevice objects corresponding to tether hosts which have been | 27 // Fetches RemoteDevice objects corresponding to tether hosts which have been |
28 // synced via CryptAuth. | 28 // synced via CryptAuth. |
29 class TetherHostFetcher { | 29 class TetherHostFetcher { |
30 public: | 30 public: |
31 class Delegate { | |
32 public: | |
33 virtual std::unique_ptr<cryptauth::SecureMessageDelegate> | |
34 CreateSecureMessageDelegate() = 0; | |
35 }; | |
36 | |
37 TetherHostFetcher(const std::string& user_id, | 31 TetherHostFetcher(const std::string& user_id, |
38 const std::string& user_private_key, | 32 const std::string& user_private_key, |
39 std::unique_ptr<Delegate> delegate, | 33 cryptauth::CryptAuthService* cryptauth_service, |
40 cryptauth::CryptAuthDeviceManager* device_manager); | 34 cryptauth::CryptAuthDeviceManager* device_manager); |
41 virtual ~TetherHostFetcher(); | 35 virtual ~TetherHostFetcher(); |
42 | 36 |
43 // Fetches all tether hosts. | 37 // Fetches all tether hosts. |
44 using TetherHostListCallback = | 38 using TetherHostListCallback = |
45 base::Callback<void(const cryptauth::RemoteDeviceList&)>; | 39 base::Callback<void(const cryptauth::RemoteDeviceList&)>; |
46 virtual void FetchAllTetherHosts(const TetherHostListCallback& callback); | 40 virtual void FetchAllTetherHosts(const TetherHostListCallback& callback); |
47 | 41 |
48 // Fetches the tether host with the ID |device_id|. | 42 // Fetches the tether host with the ID |device_id|. |
49 using TetherHostCallback = | 43 using TetherHostCallback = |
(...skipping 21 matching lines...) Expand all Loading... |
71 | 65 |
72 void OnRemoteDevicesLoaded(const cryptauth::RemoteDeviceList& remote_devices); | 66 void OnRemoteDevicesLoaded(const cryptauth::RemoteDeviceList& remote_devices); |
73 | 67 |
74 std::vector<TetherHostFetchRequest> requests_; | 68 std::vector<TetherHostFetchRequest> requests_; |
75 | 69 |
76 private: | 70 private: |
77 void StartLoadingDevicesIfNeeded(); | 71 void StartLoadingDevicesIfNeeded(); |
78 | 72 |
79 const std::string user_id_; | 73 const std::string user_id_; |
80 const std::string user_private_key_; | 74 const std::string user_private_key_; |
81 std::unique_ptr<Delegate> delegate_; | 75 |
| 76 cryptauth::CryptAuthService* cryptauth_service_; |
82 cryptauth::CryptAuthDeviceManager* device_manager_; | 77 cryptauth::CryptAuthDeviceManager* device_manager_; |
83 | 78 |
84 std::unique_ptr<cryptauth::RemoteDeviceLoader> remote_device_loader_; | 79 std::unique_ptr<cryptauth::RemoteDeviceLoader> remote_device_loader_; |
85 | 80 |
86 base::WeakPtrFactory<TetherHostFetcher> weak_ptr_factory_; | 81 base::WeakPtrFactory<TetherHostFetcher> weak_ptr_factory_; |
87 | 82 |
88 DISALLOW_COPY_AND_ASSIGN(TetherHostFetcher); | 83 DISALLOW_COPY_AND_ASSIGN(TetherHostFetcher); |
89 }; | 84 }; |
90 | 85 |
91 } // namespace tether | 86 } // namespace tether |
92 | 87 |
93 } // namespace chromeos | 88 } // namespace chromeos |
94 | 89 |
95 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ | 90 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ |
OLD | NEW |