| OLD | NEW |
| 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_INITIALIZER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/gtest_prod_util.h" |
| 8 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 15 #include "device/bluetooth/bluetooth_adapter.h" |
| 16 #include "device/bluetooth/bluetooth_advertisement.h" |
| 17 |
| 18 class PrefService; |
| 9 | 19 |
| 10 namespace cryptauth { | 20 namespace cryptauth { |
| 11 class CryptAuthService; | 21 class CryptAuthService; |
| 22 class RemoteBeaconSeedFetcher; |
| 12 } | 23 } |
| 13 | 24 |
| 14 namespace chromeos { | 25 namespace chromeos { |
| 15 | 26 |
| 27 class NetworkConnect; |
| 28 class NetworkStateHandler; |
| 29 |
| 16 namespace tether { | 30 namespace tether { |
| 17 | 31 |
| 32 class ActiveHost; |
| 33 class ActiveHostNetworkStateUpdater; |
| 34 class BleConnectionManager; |
| 35 class DeviceIdTetherNetworkGuidMap; |
| 36 class HostScanner; |
| 37 class HostScanDevicePrioritizer; |
| 38 class LocalDeviceDataProvider; |
| 39 class NotificationPresenter; |
| 40 class TetherConnector; |
| 41 class TetherHostFetcher; |
| 42 class WifiHotspotConnector; |
| 43 |
| 18 // Initializes the Tether Chrome OS component. | 44 // Initializes the Tether Chrome OS component. |
| 19 // TODO(khorimoto): Implement. | 45 class Initializer : public OAuth2TokenService::Observer { |
| 20 class Initializer { | |
| 21 public: | 46 public: |
| 22 static void Initialize(cryptauth::CryptAuthService* cryptauth_service); | 47 // Initializes the tether feature. |
| 48 static void Init( |
| 49 cryptauth::CryptAuthService* cryptauth_service, |
| 50 std::unique_ptr<NotificationPresenter> notification_presenter, |
| 51 PrefService* pref_service, |
| 52 ProfileOAuth2TokenService* token_service, |
| 53 NetworkStateHandler* network_state_handler, |
| 54 NetworkConnect* network_connect); |
| 55 |
| 56 // Shuts down the tether feature, destroying all internal classes. This should |
| 57 // be called before the dependencies passed to Init() are destroyed. |
| 58 static void Shutdown(); |
| 23 | 59 |
| 24 private: | 60 private: |
| 61 friend class InitializerTest; |
| 62 |
| 25 static Initializer* instance_; | 63 static Initializer* instance_; |
| 26 | 64 |
| 27 explicit Initializer(cryptauth::CryptAuthService* cryptauth_service); | 65 Initializer(cryptauth::CryptAuthService* cryptauth_service, |
| 28 ~Initializer(); | 66 std::unique_ptr<NotificationPresenter> notification_presenter, |
| 67 PrefService* pref_service, |
| 68 ProfileOAuth2TokenService* token_service, |
| 69 NetworkStateHandler* network_state_handler, |
| 70 NetworkConnect* network_connect); |
| 71 ~Initializer() override; |
| 72 |
| 73 // OAuth2TokenService::Observer: |
| 74 void OnRefreshTokensLoaded() override; |
| 75 |
| 76 void FetchBluetoothAdapter(); |
| 77 void OnBluetoothAdapterFetched( |
| 78 scoped_refptr<device::BluetoothAdapter> adapter); |
| 79 void OnBluetoothAdapterAdvertisingIntervalSet( |
| 80 scoped_refptr<device::BluetoothAdapter> adapter); |
| 81 void OnBluetoothAdapterAdvertisingIntervalError( |
| 82 device::BluetoothAdvertisement::ErrorCode status); |
| 29 | 83 |
| 30 cryptauth::CryptAuthService* cryptauth_service_; | 84 cryptauth::CryptAuthService* cryptauth_service_; |
| 85 std::unique_ptr<NotificationPresenter> notification_presenter_; |
| 86 PrefService* pref_service_; |
| 87 ProfileOAuth2TokenService* token_service_; |
| 88 NetworkStateHandler* network_state_handler_; |
| 89 NetworkConnect* network_connect_; |
| 90 |
| 91 // Declare new objects in the order that they will be created during |
| 92 // initialization to ensure that they are destroyed in the correct order. This |
| 93 // order will be enforced by InitializerTest.TestCreateAndDestroy. |
| 94 std::unique_ptr<TetherHostFetcher> tether_host_fetcher_; |
| 95 std::unique_ptr<LocalDeviceDataProvider> local_device_data_provider_; |
| 96 std::unique_ptr<cryptauth::RemoteBeaconSeedFetcher> |
| 97 remote_beacon_seed_fetcher_; |
| 98 std::unique_ptr<BleConnectionManager> ble_connection_manager_; |
| 99 std::unique_ptr<HostScanDevicePrioritizer> host_scan_device_prioritizer_; |
| 100 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; |
| 101 std::unique_ptr<ActiveHost> active_host_; |
| 102 std::unique_ptr<ActiveHostNetworkStateUpdater> |
| 103 active_host_network_state_updater_; |
| 104 std::unique_ptr<DeviceIdTetherNetworkGuidMap> |
| 105 device_id_tether_network_guid_map_; |
| 106 std::unique_ptr<TetherConnector> tether_connector_; |
| 107 std::unique_ptr<HostScanner> host_scanner_; |
| 108 |
| 109 base::WeakPtrFactory<Initializer> weak_ptr_factory_; |
| 31 | 110 |
| 32 DISALLOW_COPY_AND_ASSIGN(Initializer); | 111 DISALLOW_COPY_AND_ASSIGN(Initializer); |
| 33 }; | 112 }; |
| 34 | 113 |
| 35 } // namespace tether | 114 } // namespace tether |
| 36 | 115 |
| 37 } // namespace chromeos | 116 } // namespace chromeos |
| 38 | 117 |
| 39 #endif // CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ | 118 #endif // CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
| OLD | NEW |