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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_private_api.cc

Issue 246603008: Expose device RSSI and Tx power via the chrome.bluetooth API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
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 "chrome/browser/extensions/api/bluetooth/bluetooth_private_api.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_private_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 break; 269 break;
270 default: 270 default:
271 NOTREACHED(); 271 NOTREACHED();
272 } 272 }
273 } 273 }
274 274
275 SendResponse(true); 275 SendResponse(true);
276 return true; 276 return true;
277 } 277 }
278 278
279 BluetoothPrivateGetDeviceRSSIFunction::
280 BluetoothPrivateGetDeviceRSSIFunction() {}
281
282 BluetoothPrivateGetDeviceRSSIFunction::
283 ~BluetoothPrivateGetDeviceRSSIFunction() {}
284
285 bool BluetoothPrivateGetDeviceRSSIFunction::DoWork(
286 scoped_refptr<device::BluetoothAdapter> adapter) {
287 scoped_ptr<bt_private::GetDeviceRSSI::Params> params(
288 bt_private::GetDeviceRSSI::Params::Create(*args_));
289 EXTENSION_FUNCTION_VALIDATE(params.get());
290 const std::string& device_address = params->address;
291 device::BluetoothDevice* device = adapter->GetDevice(device_address);
292 if (!device) {
293 SetError(kDeviceNotFoundError);
294 SendResponse(false);
295 return false;
296 }
297
298 results_ = bt_private::GetDeviceRSSI::Results::Create(device->GetRSSI());
299 SendResponse(true);
300 return true;
301 }
302
279 } // namespace api 303 } // namespace api
280 304
281 } // namespace extensions 305 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698