| 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 #include "chromeos/components/tether/initializer.h" | 5 #include "chromeos/components/tether/initializer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chromeos/components/tether/active_host.h" | 8 #include "chromeos/components/tether/active_host.h" |
| 9 #include "chromeos/components/tether/active_host_network_state_updater.h" | 9 #include "chromeos/components/tether/active_host_network_state_updater.h" |
| 10 #include "chromeos/components/tether/ble_connection_manager.h" | 10 #include "chromeos/components/tether/ble_connection_manager.h" |
| 11 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" | 11 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" |
| 12 #include "chromeos/components/tether/host_scan_cache.h" | 12 #include "chromeos/components/tether/host_scan_cache.h" |
| 13 #include "chromeos/components/tether/host_scan_device_prioritizer.h" | 13 #include "chromeos/components/tether/host_scan_device_prioritizer_impl.h" |
| 14 #include "chromeos/components/tether/host_scan_scheduler.h" | 14 #include "chromeos/components/tether/host_scan_scheduler.h" |
| 15 #include "chromeos/components/tether/host_scanner.h" | 15 #include "chromeos/components/tether/host_scanner.h" |
| 16 #include "chromeos/components/tether/keep_alive_scheduler.h" | 16 #include "chromeos/components/tether/keep_alive_scheduler.h" |
| 17 #include "chromeos/components/tether/local_device_data_provider.h" | 17 #include "chromeos/components/tether/local_device_data_provider.h" |
| 18 #include "chromeos/components/tether/network_configuration_remover.h" | 18 #include "chromeos/components/tether/network_configuration_remover.h" |
| 19 #include "chromeos/components/tether/network_connection_handler_tether_delegate.
h" | 19 #include "chromeos/components/tether/network_connection_handler_tether_delegate.
h" |
| 20 #include "chromeos/components/tether/notification_presenter.h" | 20 #include "chromeos/components/tether/notification_presenter.h" |
| 21 #include "chromeos/components/tether/tether_connector.h" | 21 #include "chromeos/components/tether/tether_connector.h" |
| 22 #include "chromeos/components/tether/tether_disconnector.h" | 22 #include "chromeos/components/tether/tether_disconnector.h" |
| 23 #include "chromeos/components/tether/tether_host_fetcher.h" | 23 #include "chromeos/components/tether/tether_host_fetcher.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 token_service_->AddObserver(this); | 123 token_service_->AddObserver(this); |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 | 126 |
| 127 PA_LOG(INFO) << "Refresh token is available; initializing tether feature."; | 127 PA_LOG(INFO) << "Refresh token is available; initializing tether feature."; |
| 128 FetchBluetoothAdapter(); | 128 FetchBluetoothAdapter(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 Initializer::~Initializer() { | 131 Initializer::~Initializer() { |
| 132 token_service_->RemoveObserver(this); | 132 token_service_->RemoveObserver(this); |
| 133 network_state_handler_->set_tether_sort_delegate(nullptr); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void Initializer::FetchBluetoothAdapter() { | 136 void Initializer::FetchBluetoothAdapter() { |
| 136 device::BluetoothAdapterFactory::GetAdapter(base::Bind( | 137 device::BluetoothAdapterFactory::GetAdapter(base::Bind( |
| 137 &Initializer::OnBluetoothAdapterFetched, weak_ptr_factory_.GetWeakPtr())); | 138 &Initializer::OnBluetoothAdapterFetched, weak_ptr_factory_.GetWeakPtr())); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void Initializer::OnRefreshTokensLoaded() { | 141 void Initializer::OnRefreshTokensLoaded() { |
| 141 if (!token_service_->RefreshTokenIsAvailable( | 142 if (!token_service_->RefreshTokenIsAvailable( |
| 142 cryptauth_service_->GetAccountId())) { | 143 cryptauth_service_->GetAccountId())) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 base::MakeUnique<LocalDeviceDataProvider>(cryptauth_service_); | 177 base::MakeUnique<LocalDeviceDataProvider>(cryptauth_service_); |
| 177 remote_beacon_seed_fetcher_ = | 178 remote_beacon_seed_fetcher_ = |
| 178 base::MakeUnique<cryptauth::RemoteBeaconSeedFetcher>( | 179 base::MakeUnique<cryptauth::RemoteBeaconSeedFetcher>( |
| 179 cryptauth_service_->GetCryptAuthDeviceManager()); | 180 cryptauth_service_->GetCryptAuthDeviceManager()); |
| 180 ble_connection_manager_ = base::MakeUnique<BleConnectionManager>( | 181 ble_connection_manager_ = base::MakeUnique<BleConnectionManager>( |
| 181 cryptauth_service_, adapter, local_device_data_provider_.get(), | 182 cryptauth_service_, adapter, local_device_data_provider_.get(), |
| 182 remote_beacon_seed_fetcher_.get(), | 183 remote_beacon_seed_fetcher_.get(), |
| 183 cryptauth::BluetoothThrottlerImpl::GetInstance()); | 184 cryptauth::BluetoothThrottlerImpl::GetInstance()); |
| 184 tether_host_response_recorder_ = | 185 tether_host_response_recorder_ = |
| 185 base::MakeUnique<TetherHostResponseRecorder>(pref_service_); | 186 base::MakeUnique<TetherHostResponseRecorder>(pref_service_); |
| 186 host_scan_device_prioritizer_ = base::MakeUnique<HostScanDevicePrioritizer>( | 187 device_id_tether_network_guid_map_ = |
| 187 tether_host_response_recorder_.get()); | 188 base::MakeUnique<DeviceIdTetherNetworkGuidMap>(); |
| 189 host_scan_device_prioritizer_ = |
| 190 base::MakeUnique<HostScanDevicePrioritizerImpl>( |
| 191 tether_host_response_recorder_.get(), |
| 192 device_id_tether_network_guid_map_.get()); |
| 193 network_state_handler_->set_tether_sort_delegate( |
| 194 host_scan_device_prioritizer_.get()); |
| 188 wifi_hotspot_connector_ = base::MakeUnique<WifiHotspotConnector>( | 195 wifi_hotspot_connector_ = base::MakeUnique<WifiHotspotConnector>( |
| 189 network_state_handler_, network_connect_); | 196 network_state_handler_, network_connect_); |
| 190 active_host_ = | 197 active_host_ = |
| 191 base::MakeUnique<ActiveHost>(tether_host_fetcher_.get(), pref_service_); | 198 base::MakeUnique<ActiveHost>(tether_host_fetcher_.get(), pref_service_); |
| 192 active_host_network_state_updater_ = | 199 active_host_network_state_updater_ = |
| 193 base::MakeUnique<ActiveHostNetworkStateUpdater>(active_host_.get(), | 200 base::MakeUnique<ActiveHostNetworkStateUpdater>(active_host_.get(), |
| 194 network_state_handler_); | 201 network_state_handler_); |
| 195 device_id_tether_network_guid_map_ = | |
| 196 base::MakeUnique<DeviceIdTetherNetworkGuidMap>(); | |
| 197 host_scan_cache_ = base::MakeUnique<HostScanCache>( | 202 host_scan_cache_ = base::MakeUnique<HostScanCache>( |
| 198 network_state_handler_, active_host_.get(), | 203 network_state_handler_, active_host_.get(), |
| 199 tether_host_response_recorder_.get(), | 204 tether_host_response_recorder_.get(), |
| 200 device_id_tether_network_guid_map_.get()); | 205 device_id_tether_network_guid_map_.get()); |
| 201 keep_alive_scheduler_ = base::MakeUnique<KeepAliveScheduler>( | 206 keep_alive_scheduler_ = base::MakeUnique<KeepAliveScheduler>( |
| 202 active_host_.get(), ble_connection_manager_.get(), host_scan_cache_.get(), | 207 active_host_.get(), ble_connection_manager_.get(), host_scan_cache_.get(), |
| 203 device_id_tether_network_guid_map_.get()); | 208 device_id_tether_network_guid_map_.get()); |
| 204 clock_ = base::MakeUnique<base::DefaultClock>(); | 209 clock_ = base::MakeUnique<base::DefaultClock>(); |
| 205 host_scanner_ = base::MakeUnique<HostScanner>( | 210 host_scanner_ = base::MakeUnique<HostScanner>( |
| 206 tether_host_fetcher_.get(), ble_connection_manager_.get(), | 211 tether_host_fetcher_.get(), ble_connection_manager_.get(), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 244 |
| 240 void Initializer::OnBluetoothAdapterAdvertisingIntervalError( | 245 void Initializer::OnBluetoothAdapterAdvertisingIntervalError( |
| 241 device::BluetoothAdvertisement::ErrorCode status) { | 246 device::BluetoothAdvertisement::ErrorCode status) { |
| 242 PA_LOG(ERROR) << "Failed to set Bluetooth advertisement interval; " | 247 PA_LOG(ERROR) << "Failed to set Bluetooth advertisement interval; " |
| 243 << "cannot use tether feature. Error code: " << status; | 248 << "cannot use tether feature. Error code: " << status; |
| 244 } | 249 } |
| 245 | 250 |
| 246 } // namespace tether | 251 } // namespace tether |
| 247 | 252 |
| 248 } // namespace chromeos | 253 } // namespace chromeos |
| OLD | NEW |