Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: ios/chrome/common/physical_web/physical_web_data_source_ios.mm

Issue 2113473002: Add a Physical Web data source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove notification Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698