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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2297903002: arc: bluetooth: Implement set discoverable state (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/arc/bluetooth/arc_bluetooth_bridge.h" 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h"
6 6
7 #include <bluetooth/bluetooth.h> 7 #include <bluetooth/bluetooth.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 if (!HasBluetoothInstance()) 611 if (!HasBluetoothInstance())
612 return; 612 return;
613 613
614 mojo::Array<mojom::BluetoothPropertyPtr> properties = 614 mojo::Array<mojom::BluetoothPropertyPtr> properties =
615 GetAdapterProperties(type); 615 GetAdapterProperties(type);
616 616
617 arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties( 617 arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties(
618 mojom::BluetoothStatus::SUCCESS, std::move(properties)); 618 mojom::BluetoothStatus::SUCCESS, std::move(properties));
619 } 619 }
620 620
621 void ArcBluetoothBridge::OnAdapterPropertySuccess(
622 mojo::Array<mojom::BluetoothPropertyPtr> properties) const {
623 arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties(
624 mojom::BluetoothStatus::SUCCESS, std::move(properties));
625 }
626
627 void ArcBluetoothBridge::OnAdapterPropertyError(
628 mojom::BluetoothStatus status) const {
629 arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties(
630 status, mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
631 }
632
621 void ArcBluetoothBridge::SetAdapterProperty( 633 void ArcBluetoothBridge::SetAdapterProperty(
622 mojom::BluetoothPropertyPtr property) { 634 mojom::BluetoothPropertyPtr property) {
623 DCHECK(bluetooth_adapter_); 635 DCHECK(bluetooth_adapter_);
624 if (!HasBluetoothInstance()) 636 if (!HasBluetoothInstance())
625 return; 637 return;
626 638
627 // TODO(smbarber): Implement SetAdapterProperty 639 // TODO(puthik) Implement other case.
Miao 2016/08/30 22:05:38 nit: Move this comment to the unsupported case.
628 arc_bridge_service()->bluetooth()->instance()->OnAdapterProperties( 640 if (property->is_discovery_timeout()) {
629 mojom::BluetoothStatus::FAIL, 641 uint32_t discovery_timeout = property->get_discovery_timeout();
630 mojo::Array<mojom::BluetoothPropertyPtr>::New(0)); 642 mojo::Array<mojom::BluetoothPropertyPtr> success_result;
643 success_result.push_back(std::move(property));
644 if (discovery_timeout > 0) {
Miao 2016/08/30 22:05:38 nit: put a new line above.
645 // TODO(puthik) Add timer and turn this to off when timer end
646 bluetooth_adapter_->SetDiscoverable(
647 true,
648 base::Bind(&ArcBluetoothBridge::OnAdapterPropertySuccess,
649 weak_factory_.GetWeakPtr(), base::Passed(&success_result)),
650 base::Bind(&ArcBluetoothBridge::OnAdapterPropertyError,
651 weak_factory_.GetWeakPtr(), mojom::BluetoothStatus::FAIL));
652 } else {
653 OnAdapterPropertyError(mojom::BluetoothStatus::PARM_INVALID);
654 }
655 } else {
656 OnAdapterPropertyError(mojom::BluetoothStatus::UNSUPPORTED);
657 }
631 } 658 }
632 659
633 void ArcBluetoothBridge::GetRemoteDeviceProperty( 660 void ArcBluetoothBridge::GetRemoteDeviceProperty(
634 mojom::BluetoothAddressPtr remote_addr, 661 mojom::BluetoothAddressPtr remote_addr,
635 mojom::BluetoothPropertyType type) { 662 mojom::BluetoothPropertyType type) {
636 DCHECK(bluetooth_adapter_); 663 DCHECK(bluetooth_adapter_);
637 if (!HasBluetoothInstance()) 664 if (!HasBluetoothInstance())
638 return; 665 return;
639 666
640 std::string addr_str = remote_addr->To<std::string>(); 667 std::string addr_str = remote_addr->To<std::string>();
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 LOG(WARNING) << "Bluetooth instance is too old (version " << version 1779 LOG(WARNING) << "Bluetooth instance is too old (version " << version
1753 << ") need version " << version_need; 1780 << ") need version " << version_need;
1754 return false; 1781 return false;
1755 } 1782 }
1756 1783
1757 bool ArcBluetoothBridge::CalledOnValidThread() { 1784 bool ArcBluetoothBridge::CalledOnValidThread() {
1758 return thread_checker_.CalledOnValidThread(); 1785 return thread_checker_.CalledOnValidThread();
1759 } 1786 }
1760 1787
1761 } // namespace arc 1788 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698