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

Side by Side Diff: chromeos/components/tether/tether_host_fetcher.h

Issue 2801353002: [CrOS Tether] Fill out the Initializer class. Tether will now initialize fully once the flag is ena… (Closed)
Patch Set: hansberry@ comments. Created 3 years, 8 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
OLDNEW
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>
(...skipping 10 matching lines...) Expand all
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 TetherHostFetcher(const std::string& user_id, 31 explicit TetherHostFetcher(cryptauth::CryptAuthService* cryptauth_service);
32 const std::string& user_private_key,
33 cryptauth::CryptAuthService* cryptauth_service,
34 cryptauth::CryptAuthDeviceManager* device_manager);
35 virtual ~TetherHostFetcher(); 32 virtual ~TetherHostFetcher();
36 33
37 // Fetches all tether hosts. 34 // Fetches all tether hosts.
38 using TetherHostListCallback = 35 using TetherHostListCallback =
39 base::Callback<void(const cryptauth::RemoteDeviceList&)>; 36 base::Callback<void(const cryptauth::RemoteDeviceList&)>;
40 virtual void FetchAllTetherHosts(const TetherHostListCallback& callback); 37 virtual void FetchAllTetherHosts(const TetherHostListCallback& callback);
41 38
42 // Fetches the tether host with the ID |device_id|. 39 // Fetches the tether host with the ID |device_id|.
43 using TetherHostCallback = 40 using TetherHostCallback =
44 base::Callback<void(std::unique_ptr<cryptauth::RemoteDevice>)>; 41 base::Callback<void(std::unique_ptr<cryptauth::RemoteDevice>)>;
45 virtual void FetchTetherHost(const std::string& device_id, 42 virtual void FetchTetherHost(const std::string& device_id,
46 const TetherHostCallback& callback); 43 const TetherHostCallback& callback);
47 44
48 protected: 45 protected:
49 struct TetherHostFetchRequest { 46 struct TetherHostFetchRequest {
50 TetherHostFetchRequest(const TetherHostListCallback& list_callback); 47 explicit TetherHostFetchRequest(
48 const TetherHostListCallback& list_callback);
51 TetherHostFetchRequest(const std::string& device_id, 49 TetherHostFetchRequest(const std::string& device_id,
52 const TetherHostCallback& single_callback); 50 const TetherHostCallback& single_callback);
53 TetherHostFetchRequest(const TetherHostFetchRequest& other); 51 TetherHostFetchRequest(const TetherHostFetchRequest& other);
54 ~TetherHostFetchRequest(); 52 ~TetherHostFetchRequest();
55 53
56 std::string device_id; 54 std::string device_id;
57 55
58 // Only one of the two callbacks is actually used depending on which 56 // Only one of the two callbacks is actually used depending on which
59 // constructor is used. If a device ID is provided, then the request is for 57 // constructor is used. If a device ID is provided, then the request is for
60 // a single device, and |single_callback| is used; otherwise, the request is 58 // a single device, and |single_callback| is used; otherwise, the request is
61 // for all devices, so |list_callback| is used. 59 // for all devices, so |list_callback| is used.
62 TetherHostListCallback list_callback; 60 TetherHostListCallback list_callback;
63 TetherHostCallback single_callback; 61 TetherHostCallback single_callback;
64 }; 62 };
65 63
64 TetherHostFetcher(const std::string& user_id,
65 const std::string& user_private_key,
66 cryptauth::CryptAuthService* cryptauth_service,
67 cryptauth::CryptAuthDeviceManager* device_manager);
stevenjb 2017/04/10 20:26:59 one constructor
Kyle Horimoto 2017/04/11 01:40:40 Done.
68
66 void OnRemoteDevicesLoaded(const cryptauth::RemoteDeviceList& remote_devices); 69 void OnRemoteDevicesLoaded(const cryptauth::RemoteDeviceList& remote_devices);
67 70
68 std::vector<TetherHostFetchRequest> requests_; 71 std::vector<TetherHostFetchRequest> requests_;
69 72
70 private: 73 private:
71 void StartLoadingDevicesIfNeeded(); 74 void StartLoadingDevicesIfNeeded();
72 75
73 const std::string user_id_; 76 const std::string user_id_;
74 const std::string user_private_key_; 77 const std::string user_private_key_;
75 78
76 cryptauth::CryptAuthService* cryptauth_service_; 79 cryptauth::CryptAuthService* cryptauth_service_;
77 cryptauth::CryptAuthDeviceManager* device_manager_; 80 cryptauth::CryptAuthDeviceManager* device_manager_;
78 81
79 std::unique_ptr<cryptauth::RemoteDeviceLoader> remote_device_loader_; 82 std::unique_ptr<cryptauth::RemoteDeviceLoader> remote_device_loader_;
80 83
81 base::WeakPtrFactory<TetherHostFetcher> weak_ptr_factory_; 84 base::WeakPtrFactory<TetherHostFetcher> weak_ptr_factory_;
82 85
83 DISALLOW_COPY_AND_ASSIGN(TetherHostFetcher); 86 DISALLOW_COPY_AND_ASSIGN(TetherHostFetcher);
84 }; 87 };
85 88
86 } // namespace tether 89 } // namespace tether
87 90
88 } // namespace chromeos 91 } // namespace chromeos
89 92
90 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_ 93 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698