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

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

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 827 }
828 828
829 void ArcBluetoothBridge::StartLEScan() { 829 void ArcBluetoothBridge::StartLEScan() {
830 DCHECK(bluetooth_adapter_); 830 DCHECK(bluetooth_adapter_);
831 if (discovery_session_) { 831 if (discovery_session_) {
832 LOG(WARNING) << "Discovery session already running; leaving alone"; 832 LOG(WARNING) << "Discovery session already running; leaving alone";
833 SendCachedDevicesFound(); 833 SendCachedDevicesFound();
834 return; 834 return;
835 } 835 }
836 bluetooth_adapter_->StartDiscoverySessionWithFilter( 836 bluetooth_adapter_->StartDiscoverySessionWithFilter(
837 base::WrapUnique( 837 base::MakeUnique<BluetoothDiscoveryFilter>(
838 new BluetoothDiscoveryFilter(device::BLUETOOTH_TRANSPORT_LE)), 838 device::BLUETOOTH_TRANSPORT_LE),
839 base::Bind(&ArcBluetoothBridge::OnDiscoveryStarted, 839 base::Bind(&ArcBluetoothBridge::OnDiscoveryStarted,
840 weak_factory_.GetWeakPtr()), 840 weak_factory_.GetWeakPtr()),
841 base::Bind(&ArcBluetoothBridge::OnDiscoveryError, 841 base::Bind(&ArcBluetoothBridge::OnDiscoveryError,
842 weak_factory_.GetWeakPtr())); 842 weak_factory_.GetWeakPtr()));
843 } 843 }
844 844
845 void ArcBluetoothBridge::StopLEScan() { 845 void ArcBluetoothBridge::StopLEScan() {
846 CancelDiscovery(); 846 CancelDiscovery();
847 } 847 }
848 848
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 const StartLEListenCallback& callback, 957 const StartLEListenCallback& callback,
958 BluetoothAdvertisement::ErrorCode error_code) { 958 BluetoothAdvertisement::ErrorCode error_code) {
959 DCHECK(CalledOnValidThread()); 959 DCHECK(CalledOnValidThread());
960 advertisment_ = nullptr; 960 advertisment_ = nullptr;
961 callback.Run(mojom::BluetoothGattStatus::GATT_FAILURE); 961 callback.Run(mojom::BluetoothGattStatus::GATT_FAILURE);
962 } 962 }
963 963
964 void ArcBluetoothBridge::StartLEListen(const StartLEListenCallback& callback) { 964 void ArcBluetoothBridge::StartLEListen(const StartLEListenCallback& callback) {
965 DCHECK(CalledOnValidThread()); 965 DCHECK(CalledOnValidThread());
966 std::unique_ptr<BluetoothAdvertisement::Data> adv_data = 966 std::unique_ptr<BluetoothAdvertisement::Data> adv_data =
967 base::WrapUnique(new BluetoothAdvertisement::Data( 967 base::MakeUnique<BluetoothAdvertisement::Data>(
968 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST)); 968 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST);
969 bluetooth_adapter_->RegisterAdvertisement( 969 bluetooth_adapter_->RegisterAdvertisement(
970 std::move(adv_data), base::Bind(&ArcBluetoothBridge::OnStartLEListenDone, 970 std::move(adv_data), base::Bind(&ArcBluetoothBridge::OnStartLEListenDone,
971 weak_factory_.GetWeakPtr(), callback), 971 weak_factory_.GetWeakPtr(), callback),
972 base::Bind(&ArcBluetoothBridge::OnStartLEListenError, 972 base::Bind(&ArcBluetoothBridge::OnStartLEListenError,
973 weak_factory_.GetWeakPtr(), callback)); 973 weak_factory_.GetWeakPtr(), callback));
974 } 974 }
975 975
976 void ArcBluetoothBridge::OnStopLEListenDone( 976 void ArcBluetoothBridge::OnStopLEListenDone(
977 const StopLEListenCallback& callback) { 977 const StopLEListenCallback& callback) {
978 DCHECK(CalledOnValidThread()); 978 DCHECK(CalledOnValidThread());
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 LOG(WARNING) << "Bluetooth instance is too old (version " << version 1752 LOG(WARNING) << "Bluetooth instance is too old (version " << version
1753 << ") need version " << version_need; 1753 << ") need version " << version_need;
1754 return false; 1754 return false;
1755 } 1755 }
1756 1756
1757 bool ArcBluetoothBridge::CalledOnValidThread() { 1757 bool ArcBluetoothBridge::CalledOnValidThread() {
1758 return thread_checker_.CalledOnValidThread(); 1758 return thread_checker_.CalledOnValidThread();
1759 } 1759 }
1760 1760
1761 } // namespace arc 1761 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/arc_service_manager.cc ('k') | components/autofill/content/browser/content_autofill_driver_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698