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

Unified Diff: device/bluetooth/bluetooth_discovery_session.cc

Issue 179123008: Migrate chrome.bluetooth API backend to use device::BluetoothDiscoverySession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved constructors around a bit. Gonna try this time. Created 6 years, 10 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
« no previous file with comments | « device/bluetooth/bluetooth_discovery_session.h ('k') | device/bluetooth/test/mock_bluetooth_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_discovery_session.cc
diff --git a/device/bluetooth/bluetooth_discovery_session.cc b/device/bluetooth/bluetooth_discovery_session.cc
index e07df34dd28eb102c4e0c9a8098584e331c11c7e..076123e3ad8f97c08461aead83370581cf8bed54 100644
--- a/device/bluetooth/bluetooth_discovery_session.cc
+++ b/device/bluetooth/bluetooth_discovery_session.cc
@@ -9,13 +9,23 @@
namespace device {
-BluetoothDiscoverySession::BluetoothDiscoverySession(BluetoothAdapter* adapter)
+BluetoothDiscoverySession::BluetoothDiscoverySession(
+ scoped_refptr<BluetoothAdapter> adapter)
: active_(true),
adapter_(adapter),
weak_ptr_factory_(this) {
+ DCHECK(adapter_.get());
+}
+
+BluetoothDiscoverySession::BluetoothDiscoverySession()
+ : active_(false),
+ weak_ptr_factory_(this) {
}
BluetoothDiscoverySession::~BluetoothDiscoverySession() {
+ if (!active_)
+ return;
+ DCHECK(adapter_.get());
Stop(base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
adapter_->DiscoverySessionDestroyed(this);
}
@@ -28,11 +38,12 @@ void BluetoothDiscoverySession::Stop(
const base::Closure& callback,
const ErrorCallback& error_callback) {
if (!active_) {
- LOG(ERROR) << "Discovery session not active. Cannot stop.";
+ LOG(WARNING) << "Discovery session not active. Cannot stop.";
error_callback.Run();
return;
}
VLOG(1) << "Stopping device discovery session.";
+ DCHECK(adapter_.get());
adapter_->RemoveDiscoverySession(
base::Bind(&BluetoothDiscoverySession::OnStop,
weak_ptr_factory_.GetWeakPtr(),
« no previous file with comments | « device/bluetooth/bluetooth_discovery_session.h ('k') | device/bluetooth/test/mock_bluetooth_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698