Commit 105d9e85 authored by mattreynolds's avatar mattreynolds Committed by Commit bot

Avoid failing assert when Physical Web scanner is inactive

Removes an assert that was triggered when scanner_ was nil,
which is expected whenever the scanner is in the "stopped"
state. Instead, we explicitly check if scanner_ is nil and
return an empty metadata list.

BUG=630769

Review-Url: https://codereview.chromium.org/2248983003
Cr-Commit-Position: refs/heads/master@{#412584}
parent 69de2a35
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#import "ios/chrome/common/physical_web/ios_chrome_physical_web_data_source.h" #import "ios/chrome/common/physical_web/ios_chrome_physical_web_data_source.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/values.h" #include "base/values.h"
#import "ios/chrome/common/physical_web/physical_web_scanner.h" #import "ios/chrome/common/physical_web/physical_web_scanner.h"
...@@ -37,9 +36,10 @@ void IOSChromePhysicalWebDataSource::StopDiscovery() { ...@@ -37,9 +36,10 @@ void IOSChromePhysicalWebDataSource::StopDiscovery() {
} }
std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() { std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() {
std::unique_ptr<base::ListValue> metadata = [scanner_ metadata]; if (!scanner_) {
DCHECK(metadata); return base::MakeUnique<base::ListValue>();
return metadata; }
return [scanner_ metadata];
} }
bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment