1 // Copyright 2014 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.
5 #include "device/bluetooth/bluetooth_discovery_session.h"
8 #include "device/bluetooth/bluetooth_adapter.h"
12 BluetoothDiscoverySession::BluetoothDiscoverySession(
13 scoped_refptr
<BluetoothAdapter
> adapter
)
14 : active_(true), adapter_(adapter
), weak_ptr_factory_(this) {
15 DCHECK(adapter_
.get());
18 BluetoothDiscoverySession::~BluetoothDiscoverySession() {
20 Stop(base::Bind(&base::DoNothing
), base::Bind(&base::DoNothing
));
25 bool BluetoothDiscoverySession::IsActive() const {
29 void BluetoothDiscoverySession::Stop(
30 const base::Closure
& callback
,
31 const ErrorCallback
& error_callback
) {
33 LOG(WARNING
) << "Discovery session not active. Cannot stop.";
37 VLOG(1) << "Stopping device discovery session.";
38 adapter_
->RemoveDiscoverySession(
39 base::Bind(&BluetoothDiscoverySession::OnStop
,
40 weak_ptr_factory_
.GetWeakPtr(),
45 void BluetoothDiscoverySession::OnStop(const base::Closure
& callback
) {
50 void BluetoothDiscoverySession::MarkAsInactive() {
54 adapter_
->DiscoverySessionBecameInactive(this);