OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/common/physical_web/ios_chrome_physical_web_data_source.h" | 5 #import "ios/chrome/common/physical_web/ios_chrome_physical_web_data_source.h" |
6 | 6 |
7 #include "base/logging.h" | |
8 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
9 #include "base/values.h" | 8 #include "base/values.h" |
10 #import "ios/chrome/common/physical_web/physical_web_scanner.h" | 9 #import "ios/chrome/common/physical_web/physical_web_scanner.h" |
11 | 10 |
12 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource() {} | 11 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource() {} |
13 | 12 |
14 IOSChromePhysicalWebDataSource::~IOSChromePhysicalWebDataSource() { | 13 IOSChromePhysicalWebDataSource::~IOSChromePhysicalWebDataSource() { |
15 StopDiscovery(); | 14 StopDiscovery(); |
16 } | 15 } |
17 | 16 |
(...skipping 12 matching lines...) Expand all Loading... |
30 [scanner_ setNetworkRequestEnabled:network_request_enabled]; | 29 [scanner_ setNetworkRequestEnabled:network_request_enabled]; |
31 [scanner_ start]; | 30 [scanner_ start]; |
32 } | 31 } |
33 | 32 |
34 void IOSChromePhysicalWebDataSource::StopDiscovery() { | 33 void IOSChromePhysicalWebDataSource::StopDiscovery() { |
35 [scanner_ stop]; | 34 [scanner_ stop]; |
36 scanner_.reset(); | 35 scanner_.reset(); |
37 } | 36 } |
38 | 37 |
39 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() { | 38 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() { |
40 std::unique_ptr<base::ListValue> metadata = [scanner_ metadata]; | 39 if (!scanner_) { |
41 DCHECK(metadata); | 40 return base::MakeUnique<base::ListValue>(); |
42 return metadata; | 41 } |
| 42 return [scanner_ metadata]; |
43 } | 43 } |
44 | 44 |
45 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { | 45 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { |
46 return [scanner_ unresolvedBeaconsCount] > 0; | 46 return [scanner_ unresolvedBeaconsCount] > 0; |
47 } | 47 } |
OLD | NEW |