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

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

Issue 2113473002: Add a Physical Web data source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 4 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/ios_chrome_physical_web_data_source.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
9 #include "base/values.h"
10 #import "ios/chrome/common/physical_web/physical_web_scanner.h"
11
12 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource() {}
13
14 IOSChromePhysicalWebDataSource::~IOSChromePhysicalWebDataSource() {
15 StopDiscovery();
16 }
17
18 void IOSChromePhysicalWebDataSource::StartDiscovery(
19 bool network_request_enabled) {
20 // If there are unresolved beacons it means the scanner is started but does
21 // not have network requests enabled. In this case we should avoid recreating
22 // the scanner as it would clear the cache of nearby beacons.
23 if (network_request_enabled && HasUnresolvedDiscoveries()) {
24 [scanner_ setNetworkRequestEnabled:YES];
25 return;
26 }
27
28 [scanner_ stop];
29 scanner_.reset([[PhysicalWebScanner alloc] initWithDelegate:nil]);
30 [scanner_ setNetworkRequestEnabled:network_request_enabled];
31 [scanner_ start];
32 }
33
34 void IOSChromePhysicalWebDataSource::StopDiscovery() {
35 [scanner_ stop];
36 scanner_.reset();
37 }
38
39 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() {
40 std::unique_ptr<base::ListValue> metadata = [scanner_ metadata];
41 DCHECK(metadata);
42 return metadata;
43 }
44
45 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() {
46 return [scanner_ unresolvedBeaconsCount] > 0;
47 }
OLDNEW
« no previous file with comments | « ios/chrome/common/physical_web/ios_chrome_physical_web_data_source.h ('k') | ios/chrome/common/physical_web/physical_web.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698