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()
19 : active_(false), weak_ptr_factory_(this) {}
21 BluetoothDiscoverySession::~BluetoothDiscoverySession() {
22 // |adapter_| may be NULL if this instance was initialized as a mock.
23 if (!adapter_
.get()) {
27 Stop(base::Bind(&base::DoNothing
), base::Bind(&base::DoNothing
));
31 bool BluetoothDiscoverySession::IsActive() const {
35 void BluetoothDiscoverySession::Stop(
36 const base::Closure
& callback
,
37 const ErrorCallback
& error_callback
) {
39 LOG(WARNING
) << "Discovery session not active. Cannot stop.";
43 VLOG(1) << "Stopping device discovery session.";
44 DCHECK(adapter_
.get());
45 adapter_
->RemoveDiscoverySession(
46 base::Bind(&BluetoothDiscoverySession::OnStop
,
47 weak_ptr_factory_
.GetWeakPtr(),
52 void BluetoothDiscoverySession::OnStop(const base::Closure
& callback
) {
57 void BluetoothDiscoverySession::MarkAsInactive() {
61 DCHECK(adapter_
.get());
62 adapter_
->DiscoverySessionBecameInactive(this);