| 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_bluez.h" | 5 #include "device/bluetooth/bluetooth_socket_bluez.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 const ConfirmationCallback& callback) { | 450 const ConfirmationCallback& callback) { |
| 451 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); | 451 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); |
| 452 base::ThreadRestrictions::AssertIOAllowed(); | 452 base::ThreadRestrictions::AssertIOAllowed(); |
| 453 fd->CheckValidity(); | 453 fd->CheckValidity(); |
| 454 | 454 |
| 455 VLOG(1) << uuid_.canonical_value() << ": Validity check complete."; | 455 VLOG(1) << uuid_.canonical_value() << ": Validity check complete."; |
| 456 if (!fd->is_valid()) { | 456 if (!fd->is_valid()) { |
| 457 LOG(WARNING) << uuid_.canonical_value() << " :" << fd->value() | 457 LOG(WARNING) << uuid_.canonical_value() << " :" << fd->value() |
| 458 << ": Invalid file descriptor received from Bluetooth Daemon."; | 458 << ": Invalid file descriptor received from Bluetooth Daemon."; |
| 459 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); | 459 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); |
| 460 ; | |
| 461 return; | 460 return; |
| 462 } | 461 } |
| 463 | 462 |
| 464 if (tcp_socket()) { | 463 if (tcp_socket()) { |
| 465 LOG(WARNING) << uuid_.canonical_value() << ": Already connected"; | 464 LOG(WARNING) << uuid_.canonical_value() << ": Already connected"; |
| 466 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); | 465 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); |
| 467 ; | |
| 468 return; | 466 return; |
| 469 } | 467 } |
| 470 | 468 |
| 471 ResetTCPSocket(); | 469 ResetTCPSocket(); |
| 472 | 470 |
| 473 // Note: We don't have a meaningful |IPEndPoint|, but that is ok since the | 471 // Note: We don't have a meaningful |IPEndPoint|, but that is ok since the |
| 474 // TCPSocket implementation does not actually require one. | 472 // TCPSocket implementation does not actually require one. |
| 475 int net_result = | 473 int net_result = |
| 476 tcp_socket()->AdoptConnectedSocket(fd->value(), net::IPEndPoint()); | 474 tcp_socket()->AdoptConnectedSocket(fd->value(), net::IPEndPoint()); |
| 477 if (net_result != net::OK) { | 475 if (net_result != net::OK) { |
| 478 LOG(WARNING) << uuid_.canonical_value() << ": Error adopting socket: " | 476 LOG(WARNING) << uuid_.canonical_value() << ": Error adopting socket: " |
| 479 << std::string(net::ErrorToString(net_result)); | 477 << std::string(net::ErrorToString(net_result)); |
| 480 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); | 478 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); |
| 481 ; | |
| 482 return; | 479 return; |
| 483 } | 480 } |
| 484 | 481 |
| 485 VLOG(2) << uuid_.canonical_value() | 482 VLOG(2) << uuid_.canonical_value() |
| 486 << ": Taking descriptor, confirming success."; | 483 << ": Taking descriptor, confirming success."; |
| 487 fd->TakeValue(); | 484 fd->TakeValue(); |
| 488 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, SUCCESS)); | 485 ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, SUCCESS)); |
| 489 ; | |
| 490 } | 486 } |
| 491 | 487 |
| 492 void BluetoothSocketBlueZ::OnNewConnection( | 488 void BluetoothSocketBlueZ::OnNewConnection( |
| 493 scoped_refptr<BluetoothSocket> socket, | 489 scoped_refptr<BluetoothSocket> socket, |
| 494 const ConfirmationCallback& callback, | 490 const ConfirmationCallback& callback, |
| 495 Status status) { | 491 Status status) { |
| 496 DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); | 492 DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); |
| 497 DCHECK(accept_request_.get()); | 493 DCHECK(accept_request_.get()); |
| 498 DCHECK(connection_request_queue_.size() >= 1); | 494 DCHECK(connection_request_queue_.size() >= 1); |
| 499 | 495 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 DCHECK(profile_); | 532 DCHECK(profile_); |
| 537 | 533 |
| 538 VLOG(1) << profile_->object_path().value() << ": Release profile"; | 534 VLOG(1) << profile_->object_path().value() << ": Release profile"; |
| 539 | 535 |
| 540 static_cast<BluetoothAdapterBlueZ*>(adapter_.get()) | 536 static_cast<BluetoothAdapterBlueZ*>(adapter_.get()) |
| 541 ->ReleaseProfile(device_path_, profile_); | 537 ->ReleaseProfile(device_path_, profile_); |
| 542 profile_ = nullptr; | 538 profile_ = nullptr; |
| 543 } | 539 } |
| 544 | 540 |
| 545 } // namespace bluez | 541 } // namespace bluez |
| OLD | NEW |