Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 const char kSocketNotListening[] = "Socket is not listening."; | 49 const char kSocketNotListening[] = "Socket is not listening."; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 namespace chromeos { | 53 namespace chromeos { |
| 54 | 54 |
| 55 // static | 55 // static |
| 56 scoped_refptr<BluetoothSocketChromeOS> | 56 scoped_refptr<BluetoothSocketChromeOS> |
| 57 BluetoothSocketChromeOS::CreateBluetoothSocket( | 57 BluetoothSocketChromeOS::CreateBluetoothSocket( |
| 58 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 58 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 59 scoped_refptr<BluetoothSocketThread> socket_thread, | 59 scoped_refptr<BluetoothSocketThread> socket_thread) { |
| 60 net::NetLog* net_log, | |
| 61 const net::NetLog::Source& source) { | |
| 62 DCHECK(ui_task_runner->RunsTasksOnCurrentThread()); | 60 DCHECK(ui_task_runner->RunsTasksOnCurrentThread()); |
| 63 | 61 |
| 64 return make_scoped_refptr( | 62 return make_scoped_refptr( |
| 65 new BluetoothSocketChromeOS( | 63 new BluetoothSocketChromeOS(ui_task_runner, socket_thread)); |
|
keybuk
2014/07/17 18:35:09
ui_task_runner and socket_thread are singletons to
| |
| 66 ui_task_runner, socket_thread, net_log, source)); | |
| 67 } | 64 } |
| 68 | 65 |
| 69 BluetoothSocketChromeOS::AcceptRequest::AcceptRequest() {} | 66 BluetoothSocketChromeOS::AcceptRequest::AcceptRequest() {} |
| 70 | 67 |
| 71 BluetoothSocketChromeOS::AcceptRequest::~AcceptRequest() {} | 68 BluetoothSocketChromeOS::AcceptRequest::~AcceptRequest() {} |
| 72 | 69 |
| 73 BluetoothSocketChromeOS::ConnectionRequest::ConnectionRequest() | 70 BluetoothSocketChromeOS::ConnectionRequest::ConnectionRequest() |
| 74 : accepting(false), | 71 : accepting(false), |
| 75 cancelled(false) {} | 72 cancelled(false) {} |
| 76 | 73 |
| 77 BluetoothSocketChromeOS::ConnectionRequest::~ConnectionRequest() {} | 74 BluetoothSocketChromeOS::ConnectionRequest::~ConnectionRequest() {} |
| 78 | 75 |
| 79 BluetoothSocketChromeOS::BluetoothSocketChromeOS( | 76 BluetoothSocketChromeOS::BluetoothSocketChromeOS( |
| 80 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 77 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 81 scoped_refptr<BluetoothSocketThread> socket_thread, | 78 scoped_refptr<BluetoothSocketThread> socket_thread) |
| 82 net::NetLog* net_log, | 79 : BluetoothSocketNet(ui_task_runner, socket_thread) { |
| 83 const net::NetLog::Source& source) | |
| 84 : BluetoothSocketNet(ui_task_runner, socket_thread, net_log, source) { | |
| 85 } | 80 } |
| 86 | 81 |
| 87 BluetoothSocketChromeOS::~BluetoothSocketChromeOS() { | 82 BluetoothSocketChromeOS::~BluetoothSocketChromeOS() { |
| 88 DCHECK(object_path_.value().empty()); | 83 DCHECK(object_path_.value().empty()); |
| 89 DCHECK(profile_.get() == NULL); | 84 DCHECK(profile_.get() == NULL); |
| 90 | 85 |
| 91 if (adapter_.get()) { | 86 if (adapter_.get()) { |
| 92 adapter_->RemoveObserver(this); | 87 adapter_->RemoveObserver(this); |
| 93 adapter_ = NULL; | 88 adapter_ = NULL; |
| 94 } | 89 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 linked_ptr<ConnectionRequest> request = connection_request_queue_.front(); | 426 linked_ptr<ConnectionRequest> request = connection_request_queue_.front(); |
| 432 request->accepting = true; | 427 request->accepting = true; |
| 433 | 428 |
| 434 BluetoothDeviceChromeOS* device = | 429 BluetoothDeviceChromeOS* device = |
| 435 static_cast<BluetoothAdapterChromeOS*>(adapter_.get())-> | 430 static_cast<BluetoothAdapterChromeOS*>(adapter_.get())-> |
| 436 GetDeviceWithPath(request->device_path); | 431 GetDeviceWithPath(request->device_path); |
| 437 DCHECK(device); | 432 DCHECK(device); |
| 438 | 433 |
| 439 scoped_refptr<BluetoothSocketChromeOS> client_socket = | 434 scoped_refptr<BluetoothSocketChromeOS> client_socket = |
| 440 BluetoothSocketChromeOS::CreateBluetoothSocket( | 435 BluetoothSocketChromeOS::CreateBluetoothSocket( |
| 441 ui_task_runner(), | 436 ui_task_runner(), socket_thread()); |
| 442 socket_thread(), | |
| 443 net_log(), | |
| 444 source()); | |
| 445 | 437 |
| 446 client_socket->device_address_ = device->GetAddress(); | 438 client_socket->device_address_ = device->GetAddress(); |
| 447 client_socket->device_path_ = request->device_path; | 439 client_socket->device_path_ = request->device_path; |
| 448 client_socket->uuid_ = uuid_; | 440 client_socket->uuid_ = uuid_; |
| 449 | 441 |
| 450 socket_thread()->task_runner()->PostTask( | 442 socket_thread()->task_runner()->PostTask( |
| 451 FROM_HERE, | 443 FROM_HERE, |
| 452 base::Bind( | 444 base::Bind( |
| 453 &BluetoothSocketChromeOS::DoNewConnection, | 445 &BluetoothSocketChromeOS::DoNewConnection, |
| 454 client_socket, | 446 client_socket, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 // It's okay if the profile doesn't exist, it means we haven't registered it | 572 // It's okay if the profile doesn't exist, it means we haven't registered it |
| 581 // yet. | 573 // yet. |
| 582 if (error_name == bluetooth_profile_manager::kErrorDoesNotExist) | 574 if (error_name == bluetooth_profile_manager::kErrorDoesNotExist) |
| 583 return; | 575 return; |
| 584 | 576 |
| 585 LOG(WARNING) << object_path_.value() << ": Failed to unregister profile: " | 577 LOG(WARNING) << object_path_.value() << ": Failed to unregister profile: " |
| 586 << error_name << ": " << error_message; | 578 << error_name << ": " << error_message; |
| 587 } | 579 } |
| 588 | 580 |
| 589 } // namespace chromeos | 581 } // namespace chromeos |
| OLD | NEW |