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

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

Issue 273953002: Hook up RSSI and host transmit power Bluetooth device properties for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Start connection monitor when connected through chrome.bluetooth API Created 6 years, 7 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 (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 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind_helpers.h"
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" 13 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/extensions/api/bluetooth.h" 15 #include "chrome/common/extensions/api/bluetooth.h"
15 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" 16 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "device/bluetooth/bluetooth_adapter.h" 18 #include "device/bluetooth/bluetooth_adapter.h"
18 #include "device/bluetooth/bluetooth_device.h" 19 #include "device/bluetooth/bluetooth_device.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 BluetoothProfile* bluetooth_profile = 451 BluetoothProfile* bluetooth_profile =
451 GetEventRouter(browser_context())->GetProfile(uuid); 452 GetEventRouter(browser_context())->GetProfile(uuid);
452 if (!bluetooth_profile) { 453 if (!bluetooth_profile) {
453 SetError(kProfileNotFound); 454 SetError(kProfileNotFound);
454 SendResponse(false); 455 SendResponse(false);
455 return false; 456 return false;
456 } 457 }
457 458
458 device->ConnectToProfile( 459 device->ConnectToProfile(
459 bluetooth_profile, 460 bluetooth_profile,
460 base::Bind(&BluetoothConnectFunction::OnSuccessCallback, this), 461 base::Bind(&BluetoothConnectFunction::OnSuccessCallback, this, device),
keybuk 2014/05/09 22:37:21 You can't pass device pointers around like this, i
461 base::Bind(&BluetoothConnectFunction::OnErrorCallback, this)); 462 base::Bind(&BluetoothConnectFunction::OnErrorCallback, this));
462 463
463 return true; 464 return true;
464 } 465 }
465 466
466 void BluetoothConnectFunction::OnSuccessCallback() { 467 void BluetoothConnectFunction::OnSuccessCallback(BluetoothDevice* device) {
467 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 468 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
469
470 // TODO(tengs): Remove this once we have an API for starting the connection
471 // monitor.
472 DCHECK(device);
473 device->StartConnectionMonitor(base::Bind(&base::DoNothing),
474 base::Bind(&base::DoNothing));
468 SendResponse(true); 475 SendResponse(true);
469 } 476 }
470 477
471 void BluetoothConnectFunction::OnErrorCallback(const std::string& error) { 478 void BluetoothConnectFunction::OnErrorCallback(const std::string& error) {
472 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 479 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
473 SetError(error); 480 SetError(error);
474 SendResponse(false); 481 SendResponse(false);
475 } 482 }
476 483
477 bool BluetoothDisconnectFunction::RunAsync() { 484 bool BluetoothDisconnectFunction::RunAsync() {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 adapter, 651 adapter,
645 extension_id(), 652 extension_id(),
646 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), 653 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this),
647 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); 654 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this));
648 655
649 return true; 656 return true;
650 } 657 }
651 658
652 } // namespace api 659 } // namespace api
653 } // namespace extensions 660 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698