OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #import "ios/chrome/common/physical_web/physical_web_data_source_ios.h" | |
6 | |
7 void PhysicalWebDataSourceIOS::StartDiscovery(bool network_request_enabled) { | |
8 // If there are unresolved beacons it means the scanner is started but does | |
9 // not have network requests enabled. In this case we should avoid recreating | |
10 // the scanner as it would clear the cache of nearby beacons. | |
11 if (network_request_enabled && HasUnresolvedDiscoveries()) { | |
12 [scanner_ setNetworkRequestEnabled:YES]; | |
13 return; | |
14 } | |
15 | |
16 [scanner_ stop]; | |
17 scanner_.reset([[PhysicalWebScanner alloc] initWithDelegate:nil]); | |
18 [scanner_ setNetworkRequestEnabled:(BOOL)network_request_enabled]; | |
Olivier
2016/06/30 08:14:11
no C cast.
Use static_cast<BOOL> instead
mattreynolds
2016/06/30 17:51:58
Done.
| |
19 [scanner_ start]; | |
20 } | |
21 | |
22 void PhysicalWebDataSourceIOS::StopDiscovery() { | |
23 [scanner_ stop]; | |
24 scanner_.reset(); | |
25 } | |
26 | |
27 std::unique_ptr<base::ListValue> PhysicalWebDataSourceIOS::GetMetadata() { | |
28 std::unique_ptr<base::ListValue> metadata = [scanner_ metadata]; | |
29 if (metadata.get() == NULL) { | |
30 metadata.reset(new base::ListValue()); | |
31 } | |
32 return metadata; | |
33 } | |
34 | |
35 bool PhysicalWebDataSourceIOS::HasUnresolvedDiscoveries() { | |
36 return [scanner_ unresolvedBeaconsCount] > 0; | |
37 } | |
38 | |
39 PhysicalWebDataSourceIOS::PhysicalWebDataSourceIOS() {} | |
40 | |
41 PhysicalWebDataSourceIOS::~PhysicalWebDataSourceIOS() { | |
42 StopDiscovery(); | |
43 } | |
OLD | NEW |