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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/common/physical_web/physical_web_data_source_ios.mm
diff --git a/ios/chrome/common/physical_web/physical_web_data_source_ios.mm b/ios/chrome/common/physical_web/physical_web_data_source_ios.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bbfad21385cc72c90c0d8b00bc55615616dbe0b2
--- /dev/null
+++ b/ios/chrome/common/physical_web/physical_web_data_source_ios.mm
@@ -0,0 +1,43 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/common/physical_web/physical_web_data_source_ios.h"
+
+void PhysicalWebDataSourceIOS::StartDiscovery(bool network_request_enabled) {
+ // If there are unresolved beacons it means the scanner is started but does
+ // not have network requests enabled. In this case we should avoid recreating
+ // the scanner as it would clear the cache of nearby beacons.
+ if (network_request_enabled && HasUnresolvedDiscoveries()) {
+ [scanner_ setNetworkRequestEnabled:YES];
+ return;
+ }
+
+ [scanner_ stop];
+ scanner_.reset([[PhysicalWebScanner alloc] initWithDelegate:nil]);
+ [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.
+ [scanner_ start];
+}
+
+void PhysicalWebDataSourceIOS::StopDiscovery() {
+ [scanner_ stop];
+ scanner_.reset();
+}
+
+std::unique_ptr<base::ListValue> PhysicalWebDataSourceIOS::GetMetadata() {
+ std::unique_ptr<base::ListValue> metadata = [scanner_ metadata];
+ if (metadata.get() == NULL) {
+ metadata.reset(new base::ListValue());
+ }
+ return metadata;
+}
+
+bool PhysicalWebDataSourceIOS::HasUnresolvedDiscoveries() {
+ return [scanner_ unresolvedBeaconsCount] > 0;
+}
+
+PhysicalWebDataSourceIOS::PhysicalWebDataSourceIOS() {}
+
+PhysicalWebDataSourceIOS::~PhysicalWebDataSourceIOS() {
+ StopDiscovery();
+}

Powered by Google App Engine
This is Rietveld 408576698