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 #include "chromeos/components/tether/host_scan_cache.h" | 5 #include "chromeos/components/tether/host_scan_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "chromeos/components/tether/active_host.h" | 11 #include "chromeos/components/tether/active_host.h" |
12 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" | 12 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" |
13 #include "chromeos/components/tether/tether_host_response_recorder.h" | 13 #include "chromeos/components/tether/tether_host_response_recorder.h" |
| 14 #include "chromeos/components/tether/timer_factory.h" |
14 #include "chromeos/network/network_state_handler.h" | 15 #include "chromeos/network/network_state_handler.h" |
15 #include "components/proximity_auth/logging/logging.h" | 16 #include "components/proximity_auth/logging/logging.h" |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
18 | 19 |
19 namespace tether { | 20 namespace tether { |
20 | 21 |
21 namespace { | |
22 | |
23 class TimerFactoryImpl : public HostScanCache::TimerFactory { | |
24 public: | |
25 TimerFactoryImpl() {} | |
26 ~TimerFactoryImpl() {} | |
27 | |
28 // HostScanCache::TimerFactory: | |
29 std::unique_ptr<base::Timer> CreateOneShotTimer() override { | |
30 return base::MakeUnique<base::OneShotTimer>(); | |
31 } | |
32 }; | |
33 | |
34 } // namespace | |
35 | |
36 HostScanCache::HostScanCache( | 22 HostScanCache::HostScanCache( |
37 NetworkStateHandler* network_state_handler, | 23 NetworkStateHandler* network_state_handler, |
38 ActiveHost* active_host, | 24 ActiveHost* active_host, |
39 TetherHostResponseRecorder* tether_host_response_recorder, | 25 TetherHostResponseRecorder* tether_host_response_recorder, |
40 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map) | 26 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map) |
41 : timer_factory_(base::MakeUnique<TimerFactoryImpl>()), | 27 : timer_factory_(base::MakeUnique<TimerFactory>()), |
42 network_state_handler_(network_state_handler), | 28 network_state_handler_(network_state_handler), |
43 active_host_(active_host), | 29 active_host_(active_host), |
44 tether_host_response_recorder_(tether_host_response_recorder), | 30 tether_host_response_recorder_(tether_host_response_recorder), |
45 device_id_tether_network_guid_map_(device_id_tether_network_guid_map), | 31 device_id_tether_network_guid_map_(device_id_tether_network_guid_map), |
46 weak_ptr_factory_(this) { | 32 weak_ptr_factory_(this) { |
47 tether_host_response_recorder_->AddObserver(this); | 33 tether_host_response_recorder_->AddObserver(this); |
48 } | 34 } |
49 | 35 |
50 HostScanCache::~HostScanCache() { | 36 HostScanCache::~HostScanCache() { |
51 tether_host_response_recorder_->RemoveObserver(this); | 37 tether_host_response_recorder_->RemoveObserver(this); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 204 } |
219 | 205 |
220 PA_LOG(INFO) << "Timer fired for Tether network GUID " << tether_network_guid | 206 PA_LOG(INFO) << "Timer fired for Tether network GUID " << tether_network_guid |
221 << ". Removing stale scan result."; | 207 << ". Removing stale scan result."; |
222 RemoveHostScanResult(tether_network_guid); | 208 RemoveHostScanResult(tether_network_guid); |
223 } | 209 } |
224 | 210 |
225 } // namespace tether | 211 } // namespace tether |
226 | 212 |
227 } // namespace chromeos | 213 } // namespace chromeos |
OLD | NEW |