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

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

Issue 11345037: Implemented BluetoothAdapterWin::IsPresent(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_adapter_win.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // TODO(youngki): Implement this file. 5 // TODO(youngki): Implement this file.
6 6
7 #include "device/bluetooth/bluetooth_adapter_win.h" 7 #include "device/bluetooth/bluetooth_adapter_win.h"
8 8
9 #include <BluetoothAPIs.h>
9 #include <string> 10 #include <string>
10 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h"
13 #include "base/stringprintf.h"
14 #include "base/sys_string_conversions.h"
15
16 # pragma comment(lib, "Bthprops.lib")
17
18 namespace {
19 const BLUETOOTH_FIND_RADIO_PARAMS bluetooth_adapter_param =
bryeung 2012/10/30 19:58:40 no indent and a blank line after namespace and bef
youngki 2012/10/30 21:50:56 Done.
20 { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) };
21
22 const int kUpdateAdapterStateIntervalMs = 500;
23 } // namespace
11 24
12 namespace device { 25 namespace device {
13 26
14 BluetoothAdapterWin::BluetoothAdapterWin() 27 BluetoothAdapterWin::BluetoothAdapterWin()
15 : BluetoothAdapter(), 28 : BluetoothAdapter(),
16 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 29 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
17 } 30 }
18 31
19 BluetoothAdapterWin::~BluetoothAdapterWin() { 32 BluetoothAdapterWin::~BluetoothAdapterWin() {
20 } 33 }
21 34
22 void BluetoothAdapterWin::AddObserver(BluetoothAdapter::Observer* observer) { 35 void BluetoothAdapterWin::AddObserver(BluetoothAdapter::Observer* observer) {
23 NOTIMPLEMENTED(); 36 NOTIMPLEMENTED();
24 } 37 }
25 38
26 void BluetoothAdapterWin::RemoveObserver(BluetoothAdapter::Observer* observer) { 39 void BluetoothAdapterWin::RemoveObserver(BluetoothAdapter::Observer* observer) {
27 NOTIMPLEMENTED(); 40 NOTIMPLEMENTED();
28 } 41 }
29 42
30 bool BluetoothAdapterWin::IsPresent() const { 43 bool BluetoothAdapterWin::IsPresent() const {
bryeung 2012/10/30 19:58:40 This should probably try to update address_ immedi
youngki 2012/10/30 21:50:56 This is a const method.. so I don't think we can u
31 NOTIMPLEMENTED(); 44 return !address_.empty();
32 return false;
33 } 45 }
34 46
35 bool BluetoothAdapterWin::IsPowered() const { 47 bool BluetoothAdapterWin::IsPowered() const {
36 NOTIMPLEMENTED(); 48 NOTIMPLEMENTED();
37 return false; 49 return false;
38 } 50 }
39 51
40 void BluetoothAdapterWin::SetPowered( 52 void BluetoothAdapterWin::SetPowered(
41 bool powered, 53 bool powered,
42 const base::Closure& callback, 54 const base::Closure& callback,
(...skipping 28 matching lines...) Expand all
71 NOTIMPLEMENTED(); 83 NOTIMPLEMENTED();
72 return NULL; 84 return NULL;
73 } 85 }
74 86
75 void BluetoothAdapterWin::ReadLocalOutOfBandPairingData( 87 void BluetoothAdapterWin::ReadLocalOutOfBandPairingData(
76 const BluetoothOutOfBandPairingDataCallback& callback, 88 const BluetoothOutOfBandPairingDataCallback& callback,
77 const ErrorCallback& error_callback) { 89 const ErrorCallback& error_callback) {
78 NOTIMPLEMENTED(); 90 NOTIMPLEMENTED();
79 } 91 }
80 92
93 void BluetoothAdapterWin::TrackDefaultAdapter() {
94 UpdateAdapterState();
bryeung 2012/10/30 19:58:40 This is going to start polling before it is necess
youngki 2012/10/30 21:50:56 I will wait for Scott's thoughts here.
keybuk 2012/10/31 18:19:47 TrackDefaultAdapter should only be called when a n
bryeung 2012/10/31 18:46:01 Maybe this is strictly a problem with ExtensionBlu
youngki 2012/10/31 19:42:59 Okay then I will leave this as it is for now.
95 }
96
97 void BluetoothAdapterWin::UpdateAdapterState() {
98 HBLUETOOTH_RADIO_FIND bluetooth_adapter_handle = NULL;
99 BLUETOOTH_RADIO_INFO bluetooth_adapter_info =
100 { sizeof(BLUETOOTH_RADIO_INFO), 0 };
101 BluetoothFindFirstRadio(&bluetooth_adapter_param, &bluetooth_adapter_handle);
102 if (bluetooth_adapter_handle &&
103 ERROR_SUCCESS == BluetoothGetRadioInfo(bluetooth_adapter_handle,
104 &bluetooth_adapter_info)) {
105 name_ = base::SysWideToUTF8(bluetooth_adapter_info.szName);
106 address_ = base::StringPrintf("%02X:%02X:%02X:%02X:%02X:%02X",
107 bluetooth_adapter_info.address.rgBytes[5],
108 bluetooth_adapter_info.address.rgBytes[4],
109 bluetooth_adapter_info.address.rgBytes[3],
110 bluetooth_adapter_info.address.rgBytes[2],
111 bluetooth_adapter_info.address.rgBytes[1],
112 bluetooth_adapter_info.address.rgBytes[0]);
113 } else {
114 name_.clear();
115 address_.clear();
116 }
117
118 MessageLoop::current()->PostDelayedTask(
119 FROM_HERE,
120 base::Bind(&BluetoothAdapterWin::UpdateAdapterState,
121 weak_ptr_factory_.GetWeakPtr()),
122 base::TimeDelta::FromMilliseconds(kUpdateAdapterStateIntervalMs));
123 }
124
81 } // namespace device 125 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698