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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_device_client.cc

Issue 2310883003: dbus: No dbus::FileDescriptor in BluetoothProfileServiceProvider (Closed)
Patch Set: Fix tests Created 4 years, 3 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
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/dbus/fake_bluetooth_device_client.h" 5 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 17
18 #include "base/bind_helpers.h" 18 #include "base/bind_helpers.h"
19 #include "base/location.h" 19 #include "base/location.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/memory/ref_counted.h" 22 #include "base/memory/ref_counted.h"
23 #include "base/rand_util.h" 23 #include "base/rand_util.h"
24 #include "base/single_thread_task_runner.h" 24 #include "base/single_thread_task_runner.h"
25 #include "base/stl_util.h" 25 #include "base/stl_util.h"
26 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
27 #include "base/threading/worker_pool.h" 27 #include "base/threading/worker_pool.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "dbus/file_descriptor.h"
30 #include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h" 29 #include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h"
31 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 30 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
32 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" 31 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
33 #include "device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h" 32 #include "device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h"
34 #include "device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h" 33 #include "device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h"
35 #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" 34 #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h"
36 #include "device/bluetooth/dbus/fake_bluetooth_input_client.h" 35 #include "device/bluetooth/dbus/fake_bluetooth_input_client.h"
37 #include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" 36 #include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h"
38 #include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h" 37 #include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h"
39 #include "third_party/cros_system_api/dbus/service_constants.h" 38 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 504
506 args |= O_NONBLOCK; 505 args |= O_NONBLOCK;
507 if (fcntl(fds[1], F_SETFL, args) < 0) { 506 if (fcntl(fds[1], F_SETFL, args) < 0) {
508 error_callback.Run(kNoResponseError, "failed to set socket non-blocking"); 507 error_callback.Run(kNoResponseError, "failed to set socket non-blocking");
509 return; 508 return;
510 } 509 }
511 510
512 base::WorkerPool::GetTaskRunner(false) 511 base::WorkerPool::GetTaskRunner(false)
513 ->PostTask(FROM_HERE, base::Bind(&SimulatedProfileSocket, fds[0])); 512 ->PostTask(FROM_HERE, base::Bind(&SimulatedProfileSocket, fds[0]));
514 513
515 std::unique_ptr<dbus::FileDescriptor> fd(new dbus::FileDescriptor(fds[1])); 514 base::ScopedFD fd(fds[1]);
516 515
517 // Post the new connection to the service provider. 516 // Post the new connection to the service provider.
518 BluetoothProfileServiceProvider::Delegate::Options options; 517 BluetoothProfileServiceProvider::Delegate::Options options;
519 518
520 profile_service_provider->NewConnection( 519 profile_service_provider->NewConnection(
521 object_path, std::move(fd), options, 520 object_path, std::move(fd), options,
522 base::Bind(&FakeBluetoothDeviceClient::ConnectionCallback, 521 base::Bind(&FakeBluetoothDeviceClient::ConnectionCallback,
523 base::Unretained(this), object_path, callback, 522 base::Unretained(this), object_path, callback,
524 error_callback)); 523 error_callback));
525 } 524 }
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 } 1788 }
1790 properties->type.set_valid(true); 1789 properties->type.set_valid(true);
1791 1790
1792 properties_map_.insert(std::make_pair(device_path, std::move(properties))); 1791 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
1793 device_list_.push_back(device_path); 1792 device_list_.push_back(device_path);
1794 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 1793 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_,
1795 DeviceAdded(device_path)); 1794 DeviceAdded(device_path));
1796 } 1795 }
1797 1796
1798 } // namespace bluez 1797 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698