Chromium Code Reviews| 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/ios_chrome_physical_web_data_source.h" | |
| 6 | |
| 7 void IOSChromePhysicalWebDataSource::StartDiscovery( | |
| 8 bool network_request_enabled) { | |
| 9 // If there are unresolved beacons it means the scanner is started but does | |
| 10 // not have network requests enabled. In this case we should avoid recreating | |
| 11 // the scanner as it would clear the cache of nearby beacons. | |
| 12 if (network_request_enabled && HasUnresolvedDiscoveries()) { | |
| 13 [scanner_ setNetworkRequestEnabled:YES]; | |
| 14 return; | |
| 15 } | |
| 16 | |
| 17 [scanner_ stop]; | |
| 18 scanner_.reset([[PhysicalWebScanner alloc] initWithDelegate:nil]); | |
| 19 [scanner_ | |
| 20 setNetworkRequestEnabled:static_cast<BOOL>(network_request_enabled)]; | |
|
sdefresne
2016/08/02 22:23:36
There is no need to cast a bool to a BOOL. I think
mattreynolds
2016/08/04 00:56:12
Done.
| |
| 21 [scanner_ start]; | |
| 22 } | |
| 23 | |
| 24 void IOSChromePhysicalWebDataSource::StopDiscovery() { | |
| 25 [scanner_ stop]; | |
| 26 scanner_.reset(); | |
| 27 } | |
| 28 | |
| 29 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() { | |
| 30 std::unique_ptr<base::ListValue> metadata = [scanner_ metadata]; | |
| 31 if (metadata.get() == NULL) { | |
|
sdefresne
2016/08/02 22:23:36
if (!metadata)
metadata = base::MakeUnique<base:
mattreynolds
2016/08/04 00:56:12
Done.
| |
| 32 metadata.reset(new base::ListValue()); | |
| 33 } | |
| 34 return metadata; | |
| 35 } | |
| 36 | |
| 37 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { | |
| 38 return [scanner_ unresolvedBeaconsCount] > 0; | |
| 39 } | |
| 40 | |
| 41 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource() {} | |
|
sdefresne
2016/08/02 22:23:36
Please keep method in the same order as in the hea
mattreynolds
2016/08/04 00:56:12
Done.
| |
| 42 | |
| 43 IOSChromePhysicalWebDataSource::~IOSChromePhysicalWebDataSource() { | |
| 44 StopDiscovery(); | |
| 45 } | |
| OLD | NEW |