Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / device / udev_linux / scoped_udev.h
blob54df387834460e72212fc93ddcaf8f38f98afa64
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_UDEV_LINUX_SCOPED_UDEV_H_
6 #define DEVICE_UDEV_LINUX_SCOPED_UDEV_H_
8 #include <libudev.h>
10 #include "base/memory/scoped_ptr.h"
12 #if !defined(USE_UDEV)
13 #error "USE_UDEV not defined"
14 #endif
16 namespace device {
18 struct UdevDeleter {
19 void operator()(udev* dev) const {
20 udev_unref(dev);
23 struct UdevEnumerateDeleter {
24 void operator()(udev_enumerate* enumerate) const {
25 udev_enumerate_unref(enumerate);
28 struct UdevDeviceDeleter {
29 void operator()(udev_device* device) const {
30 udev_device_unref(device);
33 struct UdevMonitorDeleter {
34 void operator()(udev_monitor* monitor) const {
35 udev_monitor_unref(monitor);
39 typedef scoped_ptr<udev, UdevDeleter> ScopedUdevPtr;
40 typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr;
41 typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr;
42 typedef scoped_ptr<udev_monitor, UdevMonitorDeleter> ScopedUdevMonitorPtr;
44 } // namespace device
46 #endif // DEVICE_UDEV_LINUX_SCOPED_UDEV_H_