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

Side by Side Diff: device/hid/hid_service_linux.cc

Issue 2291983002: chromeos: Remove dbus::FileDescriptor from PermissionBrokerClient (Closed)
Patch Set: Address comments 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
« no previous file with comments | « device/hid/hid_service_linux.h ('k') | device/serial/serial_io_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/hid/hid_service_linux.h" 5 #include "device/hid/hid_service_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 file_task_runner_->PostTask(FROM_HERE, 247 file_task_runner_->PostTask(FROM_HERE,
248 base::Bind(&HidServiceLinux::OpenOnBlockingThread, 248 base::Bind(&HidServiceLinux::OpenOnBlockingThread,
249 base::Passed(&params))); 249 base::Passed(&params)));
250 #endif // defined(OS_CHROMEOS) 250 #endif // defined(OS_CHROMEOS)
251 } 251 }
252 252
253 #if defined(OS_CHROMEOS) 253 #if defined(OS_CHROMEOS)
254 254
255 // static 255 // static
256 void HidServiceLinux::OnPathOpenComplete(std::unique_ptr<ConnectParams> params, 256 void HidServiceLinux::OnPathOpenComplete(std::unique_ptr<ConnectParams> params,
257 dbus::FileDescriptor fd) { 257 base::ScopedFD fd) {
258 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = 258 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner =
259 params->file_task_runner; 259 params->file_task_runner;
260 file_task_runner->PostTask( 260 params->device_file = base::File(fd.release());
261 FROM_HERE, base::Bind(&HidServiceLinux::ValidateFdOnBlockingThread, 261 file_task_runner->PostTask(FROM_HERE, base::Bind(&HidServiceLinux::FinishOpen,
262 base::Passed(&params), base::Passed(&fd))); 262 base::Passed(&params)));
263 } 263 }
264 264
265 // static 265 // static
266 void HidServiceLinux::OnPathOpenError(const std::string& device_path, 266 void HidServiceLinux::OnPathOpenError(const std::string& device_path,
267 const ConnectCallback& callback, 267 const ConnectCallback& callback,
268 const std::string& error_name, 268 const std::string& error_name,
269 const std::string& error_message) { 269 const std::string& error_message) {
270 HID_LOG(EVENT) << "Permission broker failed to open '" << device_path 270 HID_LOG(EVENT) << "Permission broker failed to open '" << device_path
271 << "': " << error_name << ": " << error_message; 271 << "': " << error_name << ": " << error_message;
272 callback.Run(nullptr); 272 callback.Run(nullptr);
273 } 273 }
274 274
275 // static
276 void HidServiceLinux::ValidateFdOnBlockingThread(
277 std::unique_ptr<ConnectParams> params,
278 dbus::FileDescriptor fd) {
279 base::ThreadRestrictions::AssertIOAllowed();
280 fd.CheckValidity();
281 DCHECK(fd.is_valid());
282 params->device_file = base::File(fd.TakeValue());
283 FinishOpen(std::move(params));
284 }
285
286 #else 275 #else
287 276
288 // static 277 // static
289 void HidServiceLinux::OpenOnBlockingThread( 278 void HidServiceLinux::OpenOnBlockingThread(
290 std::unique_ptr<ConnectParams> params) { 279 std::unique_ptr<ConnectParams> params) {
291 base::ThreadRestrictions::AssertIOAllowed(); 280 base::ThreadRestrictions::AssertIOAllowed();
292 scoped_refptr<base::SingleThreadTaskRunner> task_runner = params->task_runner; 281 scoped_refptr<base::SingleThreadTaskRunner> task_runner = params->task_runner;
293 282
294 base::FilePath device_path(params->device_info->device_node()); 283 base::FilePath device_path(params->device_info->device_node());
295 base::File& device_file = params->device_file; 284 base::File& device_file = params->device_file;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 326
338 // static 327 // static
339 void HidServiceLinux::CreateConnection(std::unique_ptr<ConnectParams> params) { 328 void HidServiceLinux::CreateConnection(std::unique_ptr<ConnectParams> params) {
340 DCHECK(params->device_file.IsValid()); 329 DCHECK(params->device_file.IsValid());
341 params->callback.Run(make_scoped_refptr(new HidConnectionLinux( 330 params->callback.Run(make_scoped_refptr(new HidConnectionLinux(
342 params->device_info, std::move(params->device_file), 331 params->device_info, std::move(params->device_file),
343 params->file_task_runner))); 332 params->file_task_runner)));
344 } 333 }
345 334
346 } // namespace device 335 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_service_linux.h ('k') | device/serial/serial_io_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698