OLD | NEW |
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_socket_chromeos.h" | 5 #include "device/bluetooth/bluetooth_socket_chromeos.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 const dbus::ObjectPath& device_path, | 469 const dbus::ObjectPath& device_path, |
470 scoped_ptr<dbus::FileDescriptor> fd, | 470 scoped_ptr<dbus::FileDescriptor> fd, |
471 const BluetoothProfileServiceProvider::Delegate::Options& options, | 471 const BluetoothProfileServiceProvider::Delegate::Options& options, |
472 const ConfirmationCallback& callback) { | 472 const ConfirmationCallback& callback) { |
473 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); | 473 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); |
474 base::ThreadRestrictions::AssertIOAllowed(); | 474 base::ThreadRestrictions::AssertIOAllowed(); |
475 fd->CheckValidity(); | 475 fd->CheckValidity(); |
476 | 476 |
477 VLOG(1) << object_path_.value() << ": Validity check complete."; | 477 VLOG(1) << object_path_.value() << ": Validity check complete."; |
478 if (!fd->is_valid()) { | 478 if (!fd->is_valid()) { |
| 479 LOG(WARNING) << object_path_.value() << " :" << fd->value() |
| 480 << ": Invalid file descriptor received from Bluetooth Daemon."; |
479 ui_task_runner()->PostTask(FROM_HERE, | 481 ui_task_runner()->PostTask(FROM_HERE, |
480 base::Bind(callback, REJECTED));; | 482 base::Bind(callback, REJECTED));; |
481 return; | 483 return; |
482 } | 484 } |
483 | 485 |
484 if (tcp_socket()) { | 486 if (tcp_socket()) { |
485 LOG(WARNING) << object_path_.value() << ": Already connected"; | 487 LOG(WARNING) << object_path_.value() << ": Already connected"; |
486 ui_task_runner()->PostTask(FROM_HERE, | 488 ui_task_runner()->PostTask(FROM_HERE, |
487 base::Bind(callback, REJECTED));; | 489 base::Bind(callback, REJECTED));; |
488 return; | 490 return; |
489 } | 491 } |
490 | 492 |
491 ResetTCPSocket(); | 493 ResetTCPSocket(); |
492 | 494 |
493 // Note: We don't have a meaningful |IPEndPoint|, but that is ok since the | 495 // Note: We don't have a meaningful |IPEndPoint|, but that is ok since the |
494 // TCPSocket implementation does not actually require one. | 496 // TCPSocket implementation does not actually require one. |
495 int net_result = tcp_socket()->AdoptConnectedSocket(fd->value(), | 497 int net_result = tcp_socket()->AdoptConnectedSocket(fd->value(), |
496 net::IPEndPoint()); | 498 net::IPEndPoint()); |
497 if (net_result != net::OK) { | 499 if (net_result != net::OK) { |
498 LOG(WARNING) << object_path_.value() << ": Error adopting socket: " | 500 LOG(WARNING) << object_path_.value() << ": Error adopting socket: " |
499 << std::string(net::ErrorToString(net_result)); | 501 << std::string(net::ErrorToString(net_result)); |
500 ui_task_runner()->PostTask(FROM_HERE, | 502 ui_task_runner()->PostTask(FROM_HERE, |
501 base::Bind(callback, REJECTED));; | 503 base::Bind(callback, REJECTED));; |
502 return; | 504 return; |
503 } | 505 } |
504 | 506 |
| 507 VLOG(2) << object_path_.value() << ": Taking descriptor, confirming success."; |
505 fd->TakeValue(); | 508 fd->TakeValue(); |
506 ui_task_runner()->PostTask(FROM_HERE, | 509 ui_task_runner()->PostTask(FROM_HERE, |
507 base::Bind(callback, SUCCESS));; | 510 base::Bind(callback, SUCCESS));; |
508 } | 511 } |
509 | 512 |
510 void BluetoothSocketChromeOS::OnNewConnection( | 513 void BluetoothSocketChromeOS::OnNewConnection( |
511 scoped_refptr<BluetoothSocket> socket, | 514 scoped_refptr<BluetoothSocket> socket, |
512 const ConfirmationCallback& callback, | 515 const ConfirmationCallback& callback, |
513 Status status) { | 516 Status status) { |
514 DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); | 517 DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 // It's okay if the profile doesn't exist, it means we haven't registered it | 584 // It's okay if the profile doesn't exist, it means we haven't registered it |
582 // yet. | 585 // yet. |
583 if (error_name == bluetooth_profile_manager::kErrorDoesNotExist) | 586 if (error_name == bluetooth_profile_manager::kErrorDoesNotExist) |
584 return; | 587 return; |
585 | 588 |
586 LOG(WARNING) << object_path_.value() << ": Failed to unregister profile: " | 589 LOG(WARNING) << object_path_.value() << ": Failed to unregister profile: " |
587 << error_name << ": " << error_message; | 590 << error_name << ": " << error_message; |
588 } | 591 } |
589 | 592 |
590 } // namespace chromeos | 593 } // namespace chromeos |
OLD | NEW |