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

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

Issue 12379062: Remove Debug restriction on Bluetooth log messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again (base files missing?) Created 7 years, 9 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
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.cc ('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 (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 "device/bluetooth/bluetooth_device_chromeos.h" 5 #include "device/bluetooth/bluetooth_device_chromeos.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); 163 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus();
164 if (system_bus) { 164 if (system_bus) {
165 agent_.reset(BluetoothAgentServiceProvider::Create(system_bus, 165 agent_.reset(BluetoothAgentServiceProvider::Create(system_bus,
166 agent_path, 166 agent_path,
167 this)); 167 this));
168 } else { 168 } else {
169 agent_.reset(NULL); 169 agent_.reset(NULL);
170 } 170 }
171 171
172 DVLOG(1) << "Pairing: " << address_; 172 VLOG(1) << "Pairing: " << address_;
173 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> 173 DBusThreadManager::Get()->GetBluetoothAdapterClient()->
174 CreatePairedDevice( 174 CreatePairedDevice(
175 adapter_->object_path_, 175 adapter_->object_path_,
176 address_, 176 address_,
177 agent_path, 177 agent_path,
178 bluetooth_agent::kDisplayYesNoCapability, 178 bluetooth_agent::kDisplayYesNoCapability,
179 base::Bind(&BluetoothDeviceChromeOS::OnCreateDevice, 179 base::Bind(&BluetoothDeviceChromeOS::OnCreateDevice,
180 weak_ptr_factory_.GetWeakPtr(), 180 weak_ptr_factory_.GetWeakPtr(),
181 wrapped_callback, 181 wrapped_callback,
182 wrapped_error_callback), 182 wrapped_error_callback),
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // spec refers to this as bonded. Use the spec name for our interface. 364 // spec refers to this as bonded. Use the spec name for our interface.
365 bonded_ = properties->paired.value(); 365 bonded_ = properties->paired.value();
366 connected_ = properties->connected.value(); 366 connected_ = properties->connected.value();
367 } 367 }
368 } 368 }
369 369
370 void BluetoothDeviceChromeOS::OnCreateDevice( 370 void BluetoothDeviceChromeOS::OnCreateDevice(
371 const base::Closure& callback, 371 const base::Closure& callback,
372 const ConnectErrorCallback& error_callback, 372 const ConnectErrorCallback& error_callback,
373 const dbus::ObjectPath& device_path) { 373 const dbus::ObjectPath& device_path) {
374 DVLOG(1) << "Connection successful: " << device_path.value(); 374 VLOG(1) << "Connection successful: " << device_path.value();
375 if (object_path_.value().empty()) { 375 if (object_path_.value().empty()) {
376 object_path_ = device_path; 376 object_path_ = device_path;
377 } else { 377 } else {
378 LOG_IF(WARNING, object_path_ != device_path) 378 LOG_IF(WARNING, object_path_ != device_path)
379 << "Conflicting device paths for objects, result gave: " 379 << "Conflicting device paths for objects, result gave: "
380 << device_path.value() << " but signal gave: " 380 << device_path.value() << " but signal gave: "
381 << object_path_.value(); 381 << object_path_.value();
382 } 382 }
383 383
384 // Mark the device trusted so it can connect to us automatically, and 384 // Mark the device trusted so it can connect to us automatically, and
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 hid_reconnect_initiate = 476 hid_reconnect_initiate =
477 hid_reconnect_initiate && (*it)->hid_reconnect_initiate(); 477 hid_reconnect_initiate && (*it)->hid_reconnect_initiate();
478 } 478 }
479 } 479 }
480 // The Bluetooth HID spec states that if HIDNormallyConnectable or 480 // The Bluetooth HID spec states that if HIDNormallyConnectable or
481 // HIDReconnectInitiate are not present in a HID profile, the value is false. 481 // HIDReconnectInitiate are not present in a HID profile, the value is false.
482 // Nevertheless, a device with both properties in false can't reconnect to the 482 // Nevertheless, a device with both properties in false can't reconnect to the
483 // adapter and can't be reconnected from the adapter. To avoid problems with 483 // adapter and can't be reconnected from the adapter. To avoid problems with
484 // devices that don't export this properties we asume they are connectable. 484 // devices that don't export this properties we asume they are connectable.
485 connectable_ = hid_normally_connectable || !hid_reconnect_initiate; 485 connectable_ = hid_normally_connectable || !hid_reconnect_initiate;
486 DVLOG(1) << "ServiceRecordsChanged for " << address_ 486 VLOG(1) << "ServiceRecordsChanged for " << address_
487 << ": connectable = " << connectable_; 487 << ": connectable = " << connectable_;
488 } 488 }
489 489
490 void BluetoothDeviceChromeOS::OnSetTrusted(bool success) { 490 void BluetoothDeviceChromeOS::OnSetTrusted(bool success) {
491 LOG_IF(WARNING, !success) << "Failed to set device as trusted: " << address_; 491 LOG_IF(WARNING, !success) << "Failed to set device as trusted: " << address_;
492 } 492 }
493 493
494 void BluetoothDeviceChromeOS::OnInitialGetServiceRecords( 494 void BluetoothDeviceChromeOS::OnInitialGetServiceRecords(
495 const base::Closure& callback, 495 const base::Closure& callback,
496 const ConnectErrorCallback& error_callback, 496 const ConnectErrorCallback& error_callback,
497 const ServiceRecordList& list) { 497 const ServiceRecordList& list) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 // directly as it has not been called by any of the OnConnect callbacks. 592 // directly as it has not been called by any of the OnConnect callbacks.
593 // This is safe because OnIntrospect and OnConnect run on the same thread. 593 // This is safe because OnIntrospect and OnConnect run on the same thread.
594 connecting_applications_counter_--; 594 connecting_applications_counter_--;
595 if (connecting_applications_counter_ == -1) 595 if (connecting_applications_counter_ == -1)
596 callback.Run(); 596 callback.Run();
597 } 597 }
598 598
599 void BluetoothDeviceChromeOS::OnConnect(const base::Closure& callback, 599 void BluetoothDeviceChromeOS::OnConnect(const base::Closure& callback,
600 const std::string& interface_name, 600 const std::string& interface_name,
601 const dbus::ObjectPath& device_path) { 601 const dbus::ObjectPath& device_path) {
602 DVLOG(1) << "Application connection successful: " << device_path.value() 602 VLOG(1) << "Application connection successful: " << device_path.value()
603 << ": " << interface_name; 603 << ": " << interface_name;
604 604
605 connecting_applications_counter_--; 605 connecting_applications_counter_--;
606 // |callback| should only be called once, meaning it cannot be called before 606 // |callback| should only be called once, meaning it cannot be called before
607 // all requests have been started. The extra decrement after all requests 607 // all requests have been started. The extra decrement after all requests
608 // have been started, and the check for -1 instead of 0 below, insure only a 608 // have been started, and the check for -1 instead of 0 below, insure only a
609 // single call to |callback| will occur (provided OnConnect and OnIntrospect 609 // single call to |callback| will occur (provided OnConnect and OnIntrospect
610 // run on the same thread, which is true). 610 // run on the same thread, which is true).
611 if (connecting_applications_counter_ == -1) { 611 if (connecting_applications_counter_ == -1) {
612 connecting_applications_counter_ = 0; 612 connecting_applications_counter_ = 0;
613 callback.Run(); 613 callback.Run();
(...skipping 28 matching lines...) Expand all
642 error_callback.Run(error_code); 642 error_callback.Run(error_code);
643 } 643 }
644 644
645 void BluetoothDeviceChromeOS::DisconnectCallback( 645 void BluetoothDeviceChromeOS::DisconnectCallback(
646 const base::Closure& callback, 646 const base::Closure& callback,
647 const ErrorCallback& error_callback, 647 const ErrorCallback& error_callback,
648 const dbus::ObjectPath& device_path, 648 const dbus::ObjectPath& device_path,
649 bool success) { 649 bool success) {
650 DCHECK(device_path == object_path_); 650 DCHECK(device_path == object_path_);
651 if (success) { 651 if (success) {
652 DVLOG(1) << "Disconnection successful: " << address_; 652 VLOG(1) << "Disconnection successful: " << address_;
653 callback.Run(); 653 callback.Run();
654 } else { 654 } else {
655 if (connected_) { 655 if (connected_) {
656 LOG(WARNING) << "Disconnection failed: " << address_; 656 LOG(WARNING) << "Disconnection failed: " << address_;
657 error_callback.Run(); 657 error_callback.Run();
658 } else { 658 } else {
659 DVLOG(1) << "Disconnection failed on a already disconnected device: " 659 VLOG(1) << "Disconnection failed on a already disconnected device: "
660 << address_; 660 << address_;
661 callback.Run(); 661 callback.Run();
662 } 662 }
663 } 663 }
664 } 664 }
665 665
666 void BluetoothDeviceChromeOS::ForgetCallback( 666 void BluetoothDeviceChromeOS::ForgetCallback(
667 const ErrorCallback& error_callback, 667 const ErrorCallback& error_callback,
668 const dbus::ObjectPath& adapter_path, 668 const dbus::ObjectPath& adapter_path,
669 bool success) { 669 bool success) {
670 // It's quite normal that this path never gets called on success; we use a 670 // It's quite normal that this path never gets called on success; we use a
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 error_callback.Run(); 738 error_callback.Run();
739 } 739 }
740 740
741 void BluetoothDeviceChromeOS::DisconnectRequested( 741 void BluetoothDeviceChromeOS::DisconnectRequested(
742 const dbus::ObjectPath& object_path) { 742 const dbus::ObjectPath& object_path) {
743 DCHECK(object_path == object_path_); 743 DCHECK(object_path == object_path_);
744 } 744 }
745 745
746 void BluetoothDeviceChromeOS::Release() { 746 void BluetoothDeviceChromeOS::Release() {
747 DCHECK(agent_.get()); 747 DCHECK(agent_.get());
748 DVLOG(1) << "Release: " << address_; 748 VLOG(1) << "Release: " << address_;
749 749
750 DCHECK(pairing_delegate_); 750 DCHECK(pairing_delegate_);
751 pairing_delegate_->DismissDisplayOrConfirm(); 751 pairing_delegate_->DismissDisplayOrConfirm();
752 pairing_delegate_ = NULL; 752 pairing_delegate_ = NULL;
753 753
754 pincode_callback_.Reset(); 754 pincode_callback_.Reset();
755 passkey_callback_.Reset(); 755 passkey_callback_.Reset();
756 confirmation_callback_.Reset(); 756 confirmation_callback_.Reset();
757 757
758 agent_.reset(); 758 agent_.reset();
759 } 759 }
760 760
761 void BluetoothDeviceChromeOS::RequestPinCode( 761 void BluetoothDeviceChromeOS::RequestPinCode(
762 const dbus::ObjectPath& device_path, 762 const dbus::ObjectPath& device_path,
763 const PinCodeCallback& callback) { 763 const PinCodeCallback& callback) {
764 DCHECK(agent_.get()); 764 DCHECK(agent_.get());
765 DVLOG(1) << "RequestPinCode: " << device_path.value(); 765 VLOG(1) << "RequestPinCode: " << device_path.value();
766 766
767 DCHECK(pairing_delegate_); 767 DCHECK(pairing_delegate_);
768 DCHECK(pincode_callback_.is_null()); 768 DCHECK(pincode_callback_.is_null());
769 pincode_callback_ = callback; 769 pincode_callback_ = callback;
770 pairing_delegate_->RequestPinCode(this); 770 pairing_delegate_->RequestPinCode(this);
771 } 771 }
772 772
773 void BluetoothDeviceChromeOS::RequestPasskey( 773 void BluetoothDeviceChromeOS::RequestPasskey(
774 const dbus::ObjectPath& device_path, 774 const dbus::ObjectPath& device_path,
775 const PasskeyCallback& callback) { 775 const PasskeyCallback& callback) {
776 DCHECK(agent_.get()); 776 DCHECK(agent_.get());
777 DCHECK(device_path == object_path_); 777 DCHECK(device_path == object_path_);
778 DVLOG(1) << "RequestPasskey: " << device_path.value(); 778 VLOG(1) << "RequestPasskey: " << device_path.value();
779 779
780 DCHECK(pairing_delegate_); 780 DCHECK(pairing_delegate_);
781 DCHECK(passkey_callback_.is_null()); 781 DCHECK(passkey_callback_.is_null());
782 passkey_callback_ = callback; 782 passkey_callback_ = callback;
783 pairing_delegate_->RequestPasskey(this); 783 pairing_delegate_->RequestPasskey(this);
784 } 784 }
785 785
786 void BluetoothDeviceChromeOS::DisplayPinCode( 786 void BluetoothDeviceChromeOS::DisplayPinCode(
787 const dbus::ObjectPath& device_path, 787 const dbus::ObjectPath& device_path,
788 const std::string& pincode) { 788 const std::string& pincode) {
789 DCHECK(agent_.get()); 789 DCHECK(agent_.get());
790 DCHECK(device_path == object_path_); 790 DCHECK(device_path == object_path_);
791 DVLOG(1) << "DisplayPinCode: " << device_path.value() << " " << pincode; 791 VLOG(1) << "DisplayPinCode: " << device_path.value() << " " << pincode;
792 792
793 DCHECK(pairing_delegate_); 793 DCHECK(pairing_delegate_);
794 pairing_delegate_->DisplayPinCode(this, pincode); 794 pairing_delegate_->DisplayPinCode(this, pincode);
795 } 795 }
796 796
797 void BluetoothDeviceChromeOS::DisplayPasskey( 797 void BluetoothDeviceChromeOS::DisplayPasskey(
798 const dbus::ObjectPath& device_path, 798 const dbus::ObjectPath& device_path,
799 uint32 passkey) { 799 uint32 passkey) {
800 DCHECK(agent_.get()); 800 DCHECK(agent_.get());
801 DCHECK(device_path == object_path_); 801 DCHECK(device_path == object_path_);
802 DVLOG(1) << "DisplayPasskey: " << device_path.value() << " " << passkey; 802 VLOG(1) << "DisplayPasskey: " << device_path.value() << " " << passkey;
803 803
804 DCHECK(pairing_delegate_); 804 DCHECK(pairing_delegate_);
805 pairing_delegate_->DisplayPasskey(this, passkey); 805 pairing_delegate_->DisplayPasskey(this, passkey);
806 } 806 }
807 807
808 void BluetoothDeviceChromeOS::RequestConfirmation( 808 void BluetoothDeviceChromeOS::RequestConfirmation(
809 const dbus::ObjectPath& device_path, 809 const dbus::ObjectPath& device_path,
810 uint32 passkey, 810 uint32 passkey,
811 const ConfirmationCallback& callback) { 811 const ConfirmationCallback& callback) {
812 DCHECK(agent_.get()); 812 DCHECK(agent_.get());
813 DCHECK(device_path == object_path_); 813 DCHECK(device_path == object_path_);
814 DVLOG(1) << "RequestConfirmation: " << device_path.value() << " " << passkey; 814 VLOG(1) << "RequestConfirmation: " << device_path.value() << " " << passkey;
815 815
816 DCHECK(pairing_delegate_); 816 DCHECK(pairing_delegate_);
817 DCHECK(confirmation_callback_.is_null()); 817 DCHECK(confirmation_callback_.is_null());
818 confirmation_callback_ = callback; 818 confirmation_callback_ = callback;
819 pairing_delegate_->ConfirmPasskey(this, passkey); 819 pairing_delegate_->ConfirmPasskey(this, passkey);
820 } 820 }
821 821
822 void BluetoothDeviceChromeOS::Authorize(const dbus::ObjectPath& device_path, 822 void BluetoothDeviceChromeOS::Authorize(const dbus::ObjectPath& device_path,
823 const std::string& uuid, 823 const std::string& uuid,
824 const ConfirmationCallback& callback) { 824 const ConfirmationCallback& callback) {
825 DCHECK(agent_.get()); 825 DCHECK(agent_.get());
826 DCHECK(device_path == object_path_); 826 DCHECK(device_path == object_path_);
827 LOG(WARNING) << "Rejected authorization for service: " << uuid 827 LOG(WARNING) << "Rejected authorization for service: " << uuid
828 << " requested from device: " << device_path.value(); 828 << " requested from device: " << device_path.value();
829 callback.Run(REJECTED); 829 callback.Run(REJECTED);
830 } 830 }
831 831
832 void BluetoothDeviceChromeOS::ConfirmModeChange( 832 void BluetoothDeviceChromeOS::ConfirmModeChange(
833 Mode mode, 833 Mode mode,
834 const ConfirmationCallback& callback) { 834 const ConfirmationCallback& callback) {
835 DCHECK(agent_.get()); 835 DCHECK(agent_.get());
836 LOG(WARNING) << "Rejected adapter-level mode change: " << mode 836 LOG(WARNING) << "Rejected adapter-level mode change: " << mode
837 << " made on agent for device: " << address_; 837 << " made on agent for device: " << address_;
838 callback.Run(REJECTED); 838 callback.Run(REJECTED);
839 } 839 }
840 840
841 void BluetoothDeviceChromeOS::Cancel() { 841 void BluetoothDeviceChromeOS::Cancel() {
842 DCHECK(agent_.get()); 842 DCHECK(agent_.get());
843 DVLOG(1) << "Cancel: " << address_; 843 VLOG(1) << "Cancel: " << address_;
844 844
845 DCHECK(pairing_delegate_); 845 DCHECK(pairing_delegate_);
846 pairing_delegate_->DismissDisplayOrConfirm(); 846 pairing_delegate_->DismissDisplayOrConfirm();
847 } 847 }
848 848
849 849
850 // static 850 // static
851 BluetoothDeviceChromeOS* BluetoothDeviceChromeOS::Create( 851 BluetoothDeviceChromeOS* BluetoothDeviceChromeOS::Create(
852 BluetoothAdapterChromeOS* adapter) { 852 BluetoothAdapterChromeOS* adapter) {
853 return new BluetoothDeviceChromeOS(adapter); 853 return new BluetoothDeviceChromeOS(adapter);
854 } 854 }
855 855
856 } // namespace chromeos 856 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698