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

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

Issue 2801353002: [CrOS Tether] Fill out the Initializer class. Tether will now initialize fully once the flag is ena… (Closed)
Patch Set: Added missing dep. 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_LOCAL_DEVICE_DATA_PROVIDER_H 5 #ifndef CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H_
6 #define CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H 6 #define CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_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/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 14
15 namespace cryptauth { 15 namespace cryptauth {
16 class BeaconSeed; 16 class BeaconSeed;
17 class ExternalDeviceInfo; 17 class CryptAuthService;
18 class CryptAuthDeviceManager;
19 class CryptAuthEnrollmentManager;
20 } 18 }
21 19
22 namespace chromeos { 20 namespace chromeos {
23 21
24 namespace tether { 22 namespace tether {
25 23
26 // Fetches CryptAuth data about the local device (i.e., the device on which this 24 // Fetches CryptAuth data about the local device (i.e., the device on which this
27 // code is running) for the current user (i.e., the one which is logged-in). 25 // code is running) for the current user (i.e., the one which is logged-in).
28 class LocalDeviceDataProvider { 26 class LocalDeviceDataProvider {
29 public: 27 public:
30 LocalDeviceDataProvider( 28 explicit LocalDeviceDataProvider(
31 const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager, 29 cryptauth::CryptAuthService* cryptauth_service);
32 const cryptauth::CryptAuthEnrollmentManager*
33 cryptauth_enrollment_manager);
34 virtual ~LocalDeviceDataProvider(); 30 virtual ~LocalDeviceDataProvider();
35 31
36 // Fetches the public key and/or the beacon seeds for the local device. 32 // Fetches the public key and/or the beacon seeds for the local device.
37 // Returns whether the operation succeeded. If |nullptr| is passed as a 33 // Returns whether the operation succeeded. If |nullptr| is passed as a
38 // parameter, the associated data will not be fetched. 34 // parameter, the associated data will not be fetched.
39 virtual bool GetLocalDeviceData( 35 virtual bool GetLocalDeviceData(
40 std::string* public_key_out, 36 std::string* public_key_out,
41 std::vector<cryptauth::BeaconSeed>* beacon_seeds_out) const; 37 std::vector<cryptauth::BeaconSeed>* beacon_seeds_out) const;
42 38
43 private: 39 private:
44 friend class LocalDeviceDataProviderTest; 40 friend class LocalDeviceDataProviderTest;
45 41
46 class LocalDeviceDataProviderDelegate { 42 cryptauth::CryptAuthService* cryptauth_service_;
47 public:
48 virtual ~LocalDeviceDataProviderDelegate() {}
49 virtual std::string GetUserPublicKey() const = 0;
50 virtual std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices()
51 const = 0;
52 };
53
54 class LocalDeviceDataProviderDelegateImpl
55 : public LocalDeviceDataProviderDelegate {
56 public:
57 LocalDeviceDataProviderDelegateImpl(
58 const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager,
59 const cryptauth::CryptAuthEnrollmentManager*
60 cryptauth_enrollment_manager);
61 ~LocalDeviceDataProviderDelegateImpl() override;
62
63 std::string GetUserPublicKey() const override;
64 std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices()
65 const override;
66
67 private:
68 // Not owned and must outlive this instance.
69 const cryptauth::CryptAuthDeviceManager* const cryptauth_device_manager_;
70
71 // Not owned and must outlive this instance.
72 const cryptauth::CryptAuthEnrollmentManager* const
73 cryptauth_enrollment_manager_;
74 };
75
76 LocalDeviceDataProvider(
77 std::unique_ptr<LocalDeviceDataProviderDelegate> delegate);
78
79 std::unique_ptr<LocalDeviceDataProviderDelegate> delegate_;
80 43
81 DISALLOW_COPY_AND_ASSIGN(LocalDeviceDataProvider); 44 DISALLOW_COPY_AND_ASSIGN(LocalDeviceDataProvider);
82 }; 45 };
83 46
84 } // namespace tether 47 } // namespace tether
85 48
86 } // namespace chromeos 49 } // namespace chromeos
87 50
88 #endif // CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H 51 #endif // CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H_
OLDNEW
« no previous file with comments | « chromeos/components/tether/initializer_unittest.cc ('k') | chromeos/components/tether/local_device_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698