Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / storage_monitor / udev_util_linux.cc
blob0231df0b1b9ba643a0acda7473b97f9d765809cf
1 // Copyright (c) 2012 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 #include "chrome/browser/storage_monitor/udev_util_linux.h"
7 #include "base/files/file_path.h"
9 void UdevDeleter::operator()(struct udev* udev) {
10 udev_unref(udev);
13 void UdevDeviceDeleter::operator()(struct udev_device* device) {
14 udev_device_unref(device);
17 std::string GetUdevDevicePropertyValue(struct udev_device* udev_device,
18 const char* key) {
19 const char* value = udev_device_get_property_value(udev_device, key);
20 return value ? value : std::string();
23 bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path,
24 const char* key,
25 std::string* result) {
26 ScopedUdevObject udev(udev_new());
27 if (!udev.get())
28 return false;
29 ScopedUdevDeviceObject device(udev_device_new_from_syspath(
30 udev.get(), device_path.value().c_str()));
31 if (!device.get())
32 return false;
33 *result = GetUdevDevicePropertyValue(device.get(), key);
34 return true;