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

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

Issue 1124883004: Submission for C++ Readability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert overrides Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "device/bluetooth/bluetooth_adapter_chromeos.h" 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } // namespace 60 } // namespace
61 61
62 namespace device { 62 namespace device {
63 63
64 // static 64 // static
65 base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter( 65 base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter(
66 const InitCallback& init_callback) { 66 const InitCallback& init_callback) {
67 return chromeos::BluetoothAdapterChromeOS::CreateAdapter(); 67 return chromeos::BluetoothAdapterChromeOS::CreateAdapter();
68 } 68 }
69 69
70 } 70 } // namespace device
71 71
72 namespace chromeos { 72 namespace chromeos {
73 73
74 // static 74 // static
75 base::WeakPtr<BluetoothAdapter> BluetoothAdapterChromeOS::CreateAdapter() { 75 base::WeakPtr<BluetoothAdapter> BluetoothAdapterChromeOS::CreateAdapter() {
76 BluetoothAdapterChromeOS* adapter = new BluetoothAdapterChromeOS(); 76 BluetoothAdapterChromeOS* adapter = new BluetoothAdapterChromeOS();
77 return adapter->weak_ptr_factory_.GetWeakPtr(); 77 return adapter->weak_ptr_factory_.GetWeakPtr();
78 } 78 }
79 79
80 void BluetoothAdapterChromeOS::Shutdown() { 80 void BluetoothAdapterChromeOS::Shutdown() {
81 if (dbus_is_shutdown_) 81 if (dbus_is_shutdown_)
82 return; 82 return;
83 DCHECK(DBusThreadManager::IsInitialized()) 83 DCHECK(DBusThreadManager::IsInitialized())
84 << "Call BluetoothAdapterFactory::Shutdown() before " 84 << "Call BluetoothAdapterFactory::Shutdown() before "
85 "DBusThreadManager::Shutdown()."; 85 "DBusThreadManager::Shutdown().";
86 86
87 if (IsPresent()) 87 if (IsPresent())
88 RemoveAdapter(); // Also deletes devices_. 88 RemoveAdapter(); // Also deletes devices_.
89 DCHECK(devices_.empty()); 89 DCHECK(devices_.empty());
90 // profiles_ should be empty because all BluetoothSockets have been signaled 90 // profiles_ is empty because all BluetoothSockets have been notified
91 // that this adapter is disappearing. 91 // that this adapter is disappearing.
92 DCHECK(profiles_.empty()); 92 DCHECK(profiles_.empty());
93 93
94 for (auto& it : profile_queues_) 94 for (auto& it : profile_queues_)
95 delete it.second; 95 delete it.second;
96 profile_queues_.clear(); 96 profile_queues_.clear();
97 97
98 DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveObserver(this); 98 DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveObserver(this);
99 DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this); 99 DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this);
100 DBusThreadManager::Get()->GetBluetoothInputClient()->RemoveObserver(this); 100 DBusThreadManager::Get()->GetBluetoothInputClient()->RemoveObserver(this);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 scoped_ptr<device::BluetoothAdvertisement::Data> advertisement_data, 317 scoped_ptr<device::BluetoothAdvertisement::Data> advertisement_data,
318 const CreateAdvertisementCallback& callback, 318 const CreateAdvertisementCallback& callback,
319 const CreateAdvertisementErrorCallback& error_callback) { 319 const CreateAdvertisementErrorCallback& error_callback) {
320 scoped_refptr<BluetoothAdvertisementChromeOS> advertisement( 320 scoped_refptr<BluetoothAdvertisementChromeOS> advertisement(
321 new BluetoothAdvertisementChromeOS(advertisement_data.Pass(), this)); 321 new BluetoothAdvertisementChromeOS(advertisement_data.Pass(), this));
322 advertisement->Register(base::Bind(callback, advertisement), error_callback); 322 advertisement->Register(base::Bind(callback, advertisement), error_callback);
323 } 323 }
324 324
325 void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( 325 void BluetoothAdapterChromeOS::RemovePairingDelegateInternal(
326 BluetoothDevice::PairingDelegate* pairing_delegate) { 326 BluetoothDevice::PairingDelegate* pairing_delegate) {
327 // Before removing a pairing delegate make sure that there aren't any devices 327 // Check if any device is using the pairing delegate.
328 // currently using it; if there are, clear the pairing context which will 328 // If so, clear the pairing context which will make any responses no-ops.
329 // make any responses no-ops.
330 for (DevicesMap::iterator iter = devices_.begin(); 329 for (DevicesMap::iterator iter = devices_.begin();
331 iter != devices_.end(); ++iter) { 330 iter != devices_.end(); ++iter) {
332 BluetoothDeviceChromeOS* device_chromeos = 331 BluetoothDeviceChromeOS* device_chromeos =
333 static_cast<BluetoothDeviceChromeOS*>(iter->second); 332 static_cast<BluetoothDeviceChromeOS*>(iter->second);
334 333
335 BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); 334 BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing();
336 if (pairing && pairing->GetPairingDelegate() == pairing_delegate) 335 if (pairing && pairing->GetPairingDelegate() == pairing_delegate)
337 device_chromeos->EndPairing(); 336 device_chromeos->EndPairing();
338 } 337 }
339 } 338 }
(...skipping 15 matching lines...) Expand all
355 const dbus::ObjectPath& object_path, 354 const dbus::ObjectPath& object_path,
356 const std::string& property_name) { 355 const std::string& property_name) {
357 if (object_path != object_path_) 356 if (object_path != object_path_)
358 return; 357 return;
359 DCHECK(IsPresent()); 358 DCHECK(IsPresent());
360 359
361 BluetoothAdapterClient::Properties* properties = 360 BluetoothAdapterClient::Properties* properties =
362 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> 361 DBusThreadManager::Get()->GetBluetoothAdapterClient()->
363 GetProperties(object_path_); 362 GetProperties(object_path_);
364 363
365 if (property_name == properties->powered.name()) 364 if (property_name == properties->powered.name()) {
366 PoweredChanged(properties->powered.value()); 365 PoweredChanged(properties->powered.value());
367 else if (property_name == properties->discoverable.name()) 366 } else if (property_name == properties->discoverable.name()) {
368 DiscoverableChanged(properties->discoverable.value()); 367 DiscoverableChanged(properties->discoverable.value());
369 else if (property_name == properties->discovering.name()) 368 } else if (property_name == properties->discovering.name()) {
370 DiscoveringChanged(properties->discovering.value()); 369 DiscoveringChanged(properties->discovering.value());
370 }
371 } 371 }
372 372
373 void BluetoothAdapterChromeOS::DeviceAdded( 373 void BluetoothAdapterChromeOS::DeviceAdded(
374 const dbus::ObjectPath& object_path) { 374 const dbus::ObjectPath& object_path) {
375 DCHECK(DBusThreadManager::Get()); 375 DCHECK(DBusThreadManager::Get());
376 BluetoothDeviceClient::Properties* properties = 376 BluetoothDeviceClient::Properties* properties =
377 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> 377 DBusThreadManager::Get()->GetBluetoothDeviceClient()->
378 GetProperties(object_path); 378 GetProperties(object_path);
379 if (!properties || properties->adapter.value() != object_path_) 379 if (!properties || properties->adapter.value() != object_path_)
380 return; 380 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 GetProperties(object_path); 422 GetProperties(object_path);
423 423
424 if (property_name == properties->bluetooth_class.name() || 424 if (property_name == properties->bluetooth_class.name() ||
425 property_name == properties->address.name() || 425 property_name == properties->address.name() ||
426 property_name == properties->alias.name() || 426 property_name == properties->alias.name() ||
427 property_name == properties->paired.name() || 427 property_name == properties->paired.name() ||
428 property_name == properties->trusted.name() || 428 property_name == properties->trusted.name() ||
429 property_name == properties->connected.name() || 429 property_name == properties->connected.name() ||
430 property_name == properties->uuids.name() || 430 property_name == properties->uuids.name() ||
431 property_name == properties->rssi.name() || 431 property_name == properties->rssi.name() ||
432 property_name == properties->tx_power.name()) 432 property_name == properties->tx_power.name()) {
433 NotifyDeviceChanged(device_chromeos); 433 NotifyDeviceChanged(device_chromeos);
434 }
434 435
435 // When a device becomes paired, mark it as trusted so that the user does 436 // When a device becomes paired, mark it as trusted so that the user does
436 // not need to approve every incoming connection 437 // not need to approve every incoming connection
437 if (property_name == properties->paired.name() && 438 if (property_name == properties->paired.name() &&
438 properties->paired.value() && !properties->trusted.value()) 439 properties->paired.value() && !properties->trusted.value()) {
439 device_chromeos->SetTrusted(); 440 device_chromeos->SetTrusted();
441 }
440 442
441 // UMA connection counting 443 // UMA connection counting
442 if (property_name == properties->connected.name()) { 444 if (property_name == properties->connected.name()) {
443 // PlayStation joystick tries to reconnect after disconnection from USB. 445 // PlayStation joystick tries to reconnect after disconnection from USB.
444 // If it is still not trusted, set it, so it becomes available on the 446 // If it is still not trusted, set it, so it becomes available on the
445 // list of known devices. 447 // list of known devices.
446 if (properties->connected.value() && device_chromeos->IsTrustable() && 448 if (properties->connected.value() && device_chromeos->IsTrustable() &&
447 !properties->trusted.value()) 449 !properties->trusted.value())
448 device_chromeos->SetTrusted(); 450 device_chromeos->SetTrusted();
449 451
(...skipping 16 matching lines...) Expand all
466 if (!device_chromeos) 468 if (!device_chromeos)
467 return; 469 return;
468 470
469 BluetoothInputClient::Properties* properties = 471 BluetoothInputClient::Properties* properties =
470 DBusThreadManager::Get()->GetBluetoothInputClient()-> 472 DBusThreadManager::Get()->GetBluetoothInputClient()->
471 GetProperties(object_path); 473 GetProperties(object_path);
472 474
473 // Properties structure can be removed, which triggers a change in the 475 // Properties structure can be removed, which triggers a change in the
474 // BluetoothDevice::IsConnectable() property, as does a change in the 476 // BluetoothDevice::IsConnectable() property, as does a change in the
475 // actual reconnect_mode property. 477 // actual reconnect_mode property.
476 if (!properties || 478 if (!properties || property_name == properties->reconnect_mode.name()) {
477 property_name == properties->reconnect_mode.name())
478 NotifyDeviceChanged(device_chromeos); 479 NotifyDeviceChanged(device_chromeos);
480 }
479 } 481 }
480 482
481 void BluetoothAdapterChromeOS::Released() { 483 void BluetoothAdapterChromeOS::Released() {
482 VLOG(1) << "Release"; 484 VLOG(1) << "Release";
483 if (!IsPresent()) 485 if (!IsPresent())
484 return; 486 return;
485 DCHECK(agent_.get()); 487 DCHECK(agent_.get());
486 488
487 // Called after we unregister the pairing agent, e.g. when changing I/O 489 // Called after we unregister the pairing agent, e.g. when changing I/O
488 // capabilities. Nothing much to be done right now. 490 // capabilities. Nothing much to be done right now.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 return; 668 return;
667 } 669 }
668 DCHECK(audio_sink.get()); 670 DCHECK(audio_sink.get());
669 callback.Run(audio_sink); 671 callback.Run(audio_sink);
670 } 672 }
671 673
672 BluetoothDeviceChromeOS* 674 BluetoothDeviceChromeOS*
673 BluetoothAdapterChromeOS::GetDeviceWithPath( 675 BluetoothAdapterChromeOS::GetDeviceWithPath(
674 const dbus::ObjectPath& object_path) { 676 const dbus::ObjectPath& object_path) {
675 if (!IsPresent()) 677 if (!IsPresent())
676 return NULL; 678 return nullptr;
677 679
678 for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); 680 for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end();
679 ++iter) { 681 ++iter) {
680 BluetoothDeviceChromeOS* device_chromeos = 682 BluetoothDeviceChromeOS* device_chromeos =
681 static_cast<BluetoothDeviceChromeOS*>(iter->second); 683 static_cast<BluetoothDeviceChromeOS*>(iter->second);
682 if (device_chromeos->object_path() == object_path) 684 if (device_chromeos->object_path() == object_path)
683 return device_chromeos; 685 return device_chromeos;
684 } 686 }
685 687
686 return NULL; 688 return nullptr;
687 } 689 }
688 690
689 BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing( 691 BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing(
690 const dbus::ObjectPath& object_path) { 692 const dbus::ObjectPath& object_path) {
691 DCHECK(IsPresent()); 693 DCHECK(IsPresent());
692 BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path); 694 BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path);
693 if (!device_chromeos) { 695 if (!device_chromeos) {
694 LOG(WARNING) << "Pairing Agent request for unknown device: " 696 LOG(WARNING) << "Pairing Agent request for unknown device: "
695 << object_path.value(); 697 << object_path.value();
696 return NULL; 698 return nullptr;
697 } 699 }
698 700
699 BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); 701 BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing();
700 if (pairing) 702 if (pairing)
701 return pairing; 703 return pairing;
702 704
703 // The device doesn't have its own pairing context, so this is an incoming 705 // The device doesn't have its own pairing context, so this is an incoming
704 // pairing request that should use our best default delegate (if we have one). 706 // pairing request that should use our best default delegate (if we have one).
705 BluetoothDevice::PairingDelegate* pairing_delegate = DefaultPairingDelegate(); 707 BluetoothDevice::PairingDelegate* pairing_delegate = DefaultPairingDelegate();
706 if (!pairing_delegate) 708 if (!pairing_delegate)
707 return NULL; 709 return nullptr;
708 710
709 return device_chromeos->BeginPairing(pairing_delegate); 711 return device_chromeos->BeginPairing(pairing_delegate);
710 } 712 }
711 713
712 void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { 714 void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) {
713 DCHECK(!IsPresent()); 715 DCHECK(!IsPresent());
714 DCHECK(!dbus_is_shutdown_); 716 DCHECK(!dbus_is_shutdown_);
715 object_path_ = object_path; 717 object_path_ = object_path;
716 718
717 VLOG(1) << object_path_.value() << ": using adapter."; 719 VLOG(1) << object_path_.value() << ": using adapter.";
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 void BluetoothAdapterChromeOS::DiscoverableChanged(bool discoverable) { 808 void BluetoothAdapterChromeOS::DiscoverableChanged(bool discoverable) {
807 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 809 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
808 AdapterDiscoverableChanged(this, discoverable)); 810 AdapterDiscoverableChanged(this, discoverable));
809 } 811 }
810 812
811 void BluetoothAdapterChromeOS::DiscoveringChanged( 813 void BluetoothAdapterChromeOS::DiscoveringChanged(
812 bool discovering) { 814 bool discovering) {
813 // If the adapter stopped discovery due to a reason other than a request by 815 // If the adapter stopped discovery due to a reason other than a request by
814 // us, reset the count to 0. 816 // us, reset the count to 0.
815 VLOG(1) << "Discovering changed: " << discovering; 817 VLOG(1) << "Discovering changed: " << discovering;
816 if (!discovering && !discovery_request_pending_ 818 if (!discovering && !discovery_request_pending_ &&
817 && num_discovery_sessions_ > 0) { 819 num_discovery_sessions_ > 0) {
818 VLOG(1) << "Marking sessions as inactive."; 820 VLOG(1) << "Marking sessions as inactive.";
819 num_discovery_sessions_ = 0; 821 num_discovery_sessions_ = 0;
820 MarkDiscoverySessionsAsInactive(); 822 MarkDiscoverySessionsAsInactive();
821 } 823 }
822 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 824 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
823 AdapterDiscoveringChanged(this, discovering)); 825 AdapterDiscoveringChanged(this, discovering));
824 } 826 }
825 827
826 void BluetoothAdapterChromeOS::PresentChanged(bool present) { 828 void BluetoothAdapterChromeOS::PresentChanged(bool present) {
827 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 829 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
828 AdapterPresentChanged(this, present)); 830 AdapterPresentChanged(this, present));
829 } 831 }
830 832
831 void BluetoothAdapterChromeOS::NotifyDeviceChanged( 833 void BluetoothAdapterChromeOS::NotifyDeviceChanged(
832 BluetoothDeviceChromeOS* device) { 834 BluetoothDeviceChromeOS* device) {
835 DCHECK(device);
833 DCHECK(device->adapter_ == this); 836 DCHECK(device->adapter_ == this);
834 837
835 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 838 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
836 DeviceChanged(this, device)); 839 DeviceChanged(this, device));
837 } 840 }
838 841
839 void BluetoothAdapterChromeOS::NotifyGattServiceAdded( 842 void BluetoothAdapterChromeOS::NotifyGattServiceAdded(
840 BluetoothRemoteGattServiceChromeOS* service) { 843 BluetoothRemoteGattServiceChromeOS* service) {
841 DCHECK_EQ(service->GetAdapter(), this); 844 DCHECK_EQ(service->GetAdapter(), this);
842 DCHECK_EQ( 845 DCHECK_EQ(
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, 1074 base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted,
1072 weak_ptr_factory_.GetWeakPtr(), 1075 weak_ptr_factory_.GetWeakPtr(),
1073 callback, 1076 callback,
1074 error_callback)); 1077 error_callback));
1075 } 1078 }
1076 1079
1077 void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( 1080 void BluetoothAdapterChromeOS::OnPropertyChangeCompleted(
1078 const base::Closure& callback, 1081 const base::Closure& callback,
1079 const ErrorCallback& error_callback, 1082 const ErrorCallback& error_callback,
1080 bool success) { 1083 bool success) {
1081 if (IsPresent() && success) 1084 if (IsPresent() && success) {
1082 callback.Run(); 1085 callback.Run();
1083 else 1086 } else {
1084 error_callback.Run(); 1087 error_callback.Run();
1088 }
1085 } 1089 }
1086 1090
1087 void BluetoothAdapterChromeOS::AddDiscoverySession( 1091 void BluetoothAdapterChromeOS::AddDiscoverySession(
1088 BluetoothDiscoveryFilter* discovery_filter, 1092 BluetoothDiscoveryFilter* discovery_filter,
1089 const base::Closure& callback, 1093 const base::Closure& callback,
1090 const ErrorCallback& error_callback) { 1094 const ErrorCallback& error_callback) {
1091 if (!IsPresent()) { 1095 if (!IsPresent()) {
1092 error_callback.Run(); 1096 error_callback.Run();
1093 return; 1097 return;
1094 } 1098 }
(...skipping 29 matching lines...) Expand all
1124 scoped_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter( 1128 scoped_ptr<BluetoothDiscoveryFilter> df(new BluetoothDiscoveryFilter(
1125 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); 1129 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL));
1126 df->CopyFrom(*discovery_filter); 1130 df->CopyFrom(*discovery_filter);
1127 SetDiscoveryFilter( 1131 SetDiscoveryFilter(
1128 df.Pass(), 1132 df.Pass(),
1129 base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilter, 1133 base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilter,
1130 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), 1134 weak_ptr_factory_.GetWeakPtr(), callback, error_callback),
1131 base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilterError, 1135 base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilterError,
1132 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); 1136 weak_ptr_factory_.GetWeakPtr(), callback, error_callback));
1133 return; 1137 return;
1134 } else 1138 } else {
1135 current_filter_.reset(); 1139 current_filter_.reset();
1140 }
1136 1141
1137 // This is the first request to start device discovery. 1142 // This is the first request to start device discovery.
1138 discovery_request_pending_ = true; 1143 discovery_request_pending_ = true;
1139 DBusThreadManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( 1144 DBusThreadManager::Get()->GetBluetoothAdapterClient()->StartDiscovery(
1140 object_path_, 1145 object_path_,
1141 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, 1146 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery,
1142 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), 1147 weak_ptr_factory_.GetWeakPtr(), callback, error_callback),
1143 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscoveryError, 1148 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscoveryError,
1144 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); 1149 weak_ptr_factory_.GetWeakPtr(), callback, error_callback));
1145 } 1150 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 1274
1270 void BluetoothAdapterChromeOS::OnStartDiscovery( 1275 void BluetoothAdapterChromeOS::OnStartDiscovery(
1271 const base::Closure& callback, 1276 const base::Closure& callback,
1272 const ErrorCallback& error_callback) { 1277 const ErrorCallback& error_callback) {
1273 // Report success on the original request and increment the count. 1278 // Report success on the original request and increment the count.
1274 VLOG(1) << __func__; 1279 VLOG(1) << __func__;
1275 DCHECK(discovery_request_pending_); 1280 DCHECK(discovery_request_pending_);
1276 DCHECK_EQ(num_discovery_sessions_, 0); 1281 DCHECK_EQ(num_discovery_sessions_, 0);
1277 discovery_request_pending_ = false; 1282 discovery_request_pending_ = false;
1278 num_discovery_sessions_++; 1283 num_discovery_sessions_++;
1279 if (IsPresent()) 1284 if (IsPresent()) {
1280 callback.Run(); 1285 callback.Run();
1281 else 1286 } else {
1282 error_callback.Run(); 1287 error_callback.Run();
1288 }
1283 1289
1284 // Try to add a new discovery session for each queued request. 1290 // Try to add a new discovery session for each queued request.
1285 ProcessQueuedDiscoveryRequests(); 1291 ProcessQueuedDiscoveryRequests();
1286 } 1292 }
1287 1293
1288 void BluetoothAdapterChromeOS::OnStartDiscoveryError( 1294 void BluetoothAdapterChromeOS::OnStartDiscoveryError(
1289 const base::Closure& callback, 1295 const base::Closure& callback,
1290 const ErrorCallback& error_callback, 1296 const ErrorCallback& error_callback,
1291 const std::string& error_name, 1297 const std::string& error_name,
1292 const std::string& error_message) { 1298 const std::string& error_message) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 1382
1377 // Try to add a new discovery session for each queued request. 1383 // Try to add a new discovery session for each queued request.
1378 ProcessQueuedDiscoveryRequests(); 1384 ProcessQueuedDiscoveryRequests();
1379 } 1385 }
1380 1386
1381 void BluetoothAdapterChromeOS::OnSetDiscoveryFilter( 1387 void BluetoothAdapterChromeOS::OnSetDiscoveryFilter(
1382 const base::Closure& callback, 1388 const base::Closure& callback,
1383 const ErrorCallback& error_callback) { 1389 const ErrorCallback& error_callback) {
1384 // Report success on the original request and increment the count. 1390 // Report success on the original request and increment the count.
1385 VLOG(1) << __func__; 1391 VLOG(1) << __func__;
1386 if (IsPresent()) 1392 if (IsPresent()) {
1387 callback.Run(); 1393 callback.Run();
1388 else 1394 } else {
1389 error_callback.Run(); 1395 error_callback.Run();
1396 }
1390 } 1397 }
1391 1398
1392 void BluetoothAdapterChromeOS::OnSetDiscoveryFilterError( 1399 void BluetoothAdapterChromeOS::OnSetDiscoveryFilterError(
1393 const base::Closure& callback, 1400 const base::Closure& callback,
1394 const ErrorCallback& error_callback, 1401 const ErrorCallback& error_callback,
1395 const std::string& error_name, 1402 const std::string& error_name,
1396 const std::string& error_message) { 1403 const std::string& error_message) {
1397 LOG(WARNING) << object_path_.value() 1404 LOG(WARNING) << object_path_.value()
1398 << ": Failed to set discovery filter: " << error_name << ": " 1405 << ": Failed to set discovery filter: " << error_name << ": "
1399 << error_message; 1406 << error_message;
(...skipping 14 matching lines...) Expand all
1414 1421
1415 // If the queued request resulted in a pending call, then let it 1422 // If the queued request resulted in a pending call, then let it
1416 // asynchonously process the remaining queued requests once the pending 1423 // asynchonously process the remaining queued requests once the pending
1417 // call returns. 1424 // call returns.
1418 if (discovery_request_pending_) 1425 if (discovery_request_pending_)
1419 return; 1426 return;
1420 } 1427 }
1421 } 1428 }
1422 1429
1423 } // namespace chromeos 1430 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.h ('k') | device/bluetooth/bluetooth_adapter_profile_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698