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/dbus/bluetooth_profile_service_provider.h" | 5 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Called by dbus:: when the Bluetooth daemon establishes a new connection | 97 // Called by dbus:: when the Bluetooth daemon establishes a new connection |
98 // to the profile. | 98 // to the profile. |
99 void NewConnection(dbus::MethodCall* method_call, | 99 void NewConnection(dbus::MethodCall* method_call, |
100 dbus::ExportedObject::ResponseSender response_sender) { | 100 dbus::ExportedObject::ResponseSender response_sender) { |
101 DCHECK(OnOriginThread()); | 101 DCHECK(OnOriginThread()); |
102 DCHECK(delegate_); | 102 DCHECK(delegate_); |
103 | 103 |
104 dbus::MessageReader reader(method_call); | 104 dbus::MessageReader reader(method_call); |
105 dbus::ObjectPath device_path; | 105 dbus::ObjectPath device_path; |
106 std::unique_ptr<dbus::FileDescriptor> fd(new dbus::FileDescriptor()); | 106 base::ScopedFD fd; |
107 dbus::MessageReader array_reader(NULL); | 107 dbus::MessageReader array_reader(NULL); |
108 if (!reader.PopObjectPath(&device_path) || | 108 if (!reader.PopObjectPath(&device_path) || !reader.PopFileDescriptor(&fd) || |
109 !reader.PopFileDescriptor(fd.get()) || | |
110 !reader.PopArray(&array_reader)) { | 109 !reader.PopArray(&array_reader)) { |
111 LOG(WARNING) << "NewConnection called with incorrect paramters: " | 110 LOG(WARNING) << "NewConnection called with incorrect paramters: " |
112 << method_call->ToString(); | 111 << method_call->ToString(); |
113 return; | 112 return; |
114 } | 113 } |
115 | 114 |
116 Delegate::Options options; | 115 Delegate::Options options; |
117 while (array_reader.HasMoreData()) { | 116 while (array_reader.HasMoreData()) { |
118 dbus::MessageReader dict_entry_reader(NULL); | 117 dbus::MessageReader dict_entry_reader(NULL); |
119 std::string key; | 118 std::string key; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 dbus::Bus* bus, | 241 dbus::Bus* bus, |
243 const dbus::ObjectPath& object_path, | 242 const dbus::ObjectPath& object_path, |
244 Delegate* delegate) { | 243 Delegate* delegate) { |
245 if (!bluez::BluezDBusManager::Get()->IsUsingFakes()) { | 244 if (!bluez::BluezDBusManager::Get()->IsUsingFakes()) { |
246 return new BluetoothProfileServiceProviderImpl(bus, object_path, delegate); | 245 return new BluetoothProfileServiceProviderImpl(bus, object_path, delegate); |
247 } | 246 } |
248 return new FakeBluetoothProfileServiceProvider(object_path, delegate); | 247 return new FakeBluetoothProfileServiceProvider(object_path, delegate); |
249 } | 248 } |
250 | 249 |
251 } // namespace bluez | 250 } // namespace bluez |
OLD | NEW |