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

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

Issue 14487002: Bluetooth: Profile support for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle EINTR. Detect disconnection during Receive and Send Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_device_experimental_chromeos.h" 5 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" 12 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
13 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" 13 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h"
14 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" 14 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h"
15 #include "chromeos/dbus/experimental_bluetooth_device_client.h" 15 #include "chromeos/dbus/experimental_bluetooth_device_client.h"
16 #include "chromeos/dbus/experimental_bluetooth_input_client.h" 16 #include "chromeos/dbus/experimental_bluetooth_input_client.h"
17 #include "dbus/bus.h" 17 #include "dbus/bus.h"
18 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" 18 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h"
19 #include "device/bluetooth/bluetooth_profile_experimental_chromeos.h"
19 #include "device/bluetooth/bluetooth_socket.h" 20 #include "device/bluetooth/bluetooth_socket.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 21 #include "third_party/cros_system_api/dbus/service_constants.h"
21 22
22 using device::BluetoothDevice; 23 using device::BluetoothDevice;
23 24
24 namespace { 25 namespace {
25 26
26 // The agent path is relatively meaningless since BlueZ only supports one 27 // The agent path is relatively meaningless since BlueZ only supports one
27 // at time and will fail in an attempt to register another with "Already Exists" 28 // at time and will fail in an attempt to register another with "Already Exists"
28 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). 29 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS).
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 const std::string& service_uuid, 353 const std::string& service_uuid,
353 const SocketCallback& callback) { 354 const SocketCallback& callback) {
354 // TODO(keybuk): implement 355 // TODO(keybuk): implement
355 callback.Run(scoped_refptr<device::BluetoothSocket>()); 356 callback.Run(scoped_refptr<device::BluetoothSocket>());
356 } 357 }
357 358
358 void BluetoothDeviceExperimentalChromeOS::ConnectToProfile( 359 void BluetoothDeviceExperimentalChromeOS::ConnectToProfile(
359 device::BluetoothProfile* profile, 360 device::BluetoothProfile* profile,
360 const base::Closure& callback, 361 const base::Closure& callback,
361 const ErrorCallback& error_callback) { 362 const ErrorCallback& error_callback) {
362 // TODO(keybuk): implement 363 BluetoothProfileExperimentalChromeOS* profile_chromeos =
363 error_callback.Run(); 364 static_cast<BluetoothProfileExperimentalChromeOS*>(profile);
365 VLOG(1) << object_path_.value() << ": Connecting profile: "
366 << profile_chromeos->uuid();
367 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()->
368 ConnectProfile(
369 object_path_,
370 profile_chromeos->uuid(),
371 base::Bind(
372 &BluetoothDeviceExperimentalChromeOS::OnConnectProfile,
373 weak_ptr_factory_.GetWeakPtr(),
374 profile,
375 callback),
376 base::Bind(
377 &BluetoothDeviceExperimentalChromeOS::OnConnectProfileError,
378 weak_ptr_factory_.GetWeakPtr(),
379 profile,
380 error_callback));
364 } 381 }
365 382
366 void BluetoothDeviceExperimentalChromeOS::SetOutOfBandPairingData( 383 void BluetoothDeviceExperimentalChromeOS::SetOutOfBandPairingData(
367 const device::BluetoothOutOfBandPairingData& data, 384 const device::BluetoothOutOfBandPairingData& data,
368 const base::Closure& callback, 385 const base::Closure& callback,
369 const ErrorCallback& error_callback) { 386 const ErrorCallback& error_callback) {
370 // TODO(keybuk): implement 387 // TODO(keybuk): implement
371 error_callback.Run(); 388 error_callback.Run();
372 } 389 }
373 390
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 default: 804 default:
788 pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR; 805 pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR;
789 } 806 }
790 } 807 }
791 808
792 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", 809 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult",
793 pairing_result, 810 pairing_result,
794 UMA_PAIRING_RESULT_COUNT); 811 UMA_PAIRING_RESULT_COUNT);
795 } 812 }
796 813
814 void BluetoothDeviceExperimentalChromeOS::OnConnectProfile(
815 device::BluetoothProfile* profile,
816 const base::Closure& callback) {
817 BluetoothProfileExperimentalChromeOS* profile_chromeos =
818 static_cast<BluetoothProfileExperimentalChromeOS*>(profile);
819 VLOG(1) << object_path_.value() << ": Profile connected: "
820 << profile_chromeos->uuid();
821 callback.Run();
822 }
823
824 void BluetoothDeviceExperimentalChromeOS::OnConnectProfileError(
825 device::BluetoothProfile* profile,
826 const ErrorCallback& error_callback,
827 const std::string& error_name,
828 const std::string& error_message) {
829 BluetoothProfileExperimentalChromeOS* profile_chromeos =
830 static_cast<BluetoothProfileExperimentalChromeOS*>(profile);
831 VLOG(1) << object_path_.value() << ": Profile connection failed: "
832 << profile_chromeos->uuid() << ": "
833 << error_name << ": " << error_message;
834 error_callback.Run();
835 }
836
797 } // namespace chromeos 837 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698