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

Side by Side Diff: device/bluetooth/bluetooth_discovery_session.cc

Issue 184953002: Migrate Chrome OS Bluetooth UI to the new discovery API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments by derat@ and keybuk@. Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/bluetooth/bluetooth_discovery_session.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #include "device/bluetooth/bluetooth_discovery_session.h" 5 #include "device/bluetooth/bluetooth_discovery_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "device/bluetooth/bluetooth_adapter.h" 8 #include "device/bluetooth/bluetooth_adapter.h"
9 9
10 namespace device { 10 namespace device {
11 11
12 BluetoothDiscoverySession::BluetoothDiscoverySession(BluetoothAdapter* adapter) 12 BluetoothDiscoverySession::BluetoothDiscoverySession(BluetoothAdapter* adapter)
13 : active_(true), 13 : active_(true),
14 adapter_(adapter), 14 adapter_(adapter),
15 weak_ptr_factory_(this) { 15 weak_ptr_factory_(this) {
16 } 16 }
17 17
18 BluetoothDiscoverySession::~BluetoothDiscoverySession() { 18 BluetoothDiscoverySession::~BluetoothDiscoverySession() {
19 Stop(base::Bind(&base::DoNothing), base::Bind(&base::DoNothing)); 19 Stop(base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
20 adapter_->DiscoverySessionDestroyed(this); 20 adapter_->DiscoverySessionDestroyed(this);
21 } 21 }
22 22
23 bool BluetoothDiscoverySession::IsActive() const {
24 return active_;
25 }
26
23 void BluetoothDiscoverySession::Stop( 27 void BluetoothDiscoverySession::Stop(
24 const base::Closure& callback, 28 const base::Closure& callback,
25 const ErrorCallback& error_callback) { 29 const ErrorCallback& error_callback) {
26 if (!active_) { 30 if (!active_) {
27 LOG(ERROR) << "Discovery session not active. Cannot stop."; 31 LOG(ERROR) << "Discovery session not active. Cannot stop.";
28 error_callback.Run(); 32 error_callback.Run();
29 return; 33 return;
30 } 34 }
31 VLOG(1) << "Stopping device discovery session."; 35 VLOG(1) << "Stopping device discovery session.";
32 adapter_->RemoveDiscoverySession( 36 adapter_->RemoveDiscoverySession(
33 base::Bind(&BluetoothDiscoverySession::OnStop, 37 base::Bind(&BluetoothDiscoverySession::OnStop,
34 weak_ptr_factory_.GetWeakPtr(), 38 weak_ptr_factory_.GetWeakPtr(),
35 callback), 39 callback),
36 error_callback); 40 error_callback);
37 } 41 }
38 42
39 void BluetoothDiscoverySession::OnStop(const base::Closure& callback) { 43 void BluetoothDiscoverySession::OnStop(const base::Closure& callback) {
40 active_ = false; 44 active_ = false;
41 callback.Run(); 45 callback.Run();
42 } 46 }
43 47
44 void BluetoothDiscoverySession::MarkAsInactive() { 48 void BluetoothDiscoverySession::MarkAsInactive() {
45 active_ = false; 49 active_ = false;
46 } 50 }
47 51
48 } // namespace device 52 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_discovery_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698