| OLD | NEW |
| 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 // StorageMonitorLinux implementation. | 5 // StorageMonitorLinux implementation. |
| 6 | 6 |
| 7 #include "components/storage_monitor/storage_monitor_linux.h" | 7 #include "components/storage_monitor/storage_monitor_linux.h" |
| 8 | 8 |
| 9 #include <mntent.h> | 9 #include <mntent.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const char kModelID[] = "ID_MODEL_ID"; | 48 const char kModelID[] = "ID_MODEL_ID"; |
| 49 const char kRemovableSysAttr[] = "removable"; | 49 const char kRemovableSysAttr[] = "removable"; |
| 50 const char kSerialShort[] = "ID_SERIAL_SHORT"; | 50 const char kSerialShort[] = "ID_SERIAL_SHORT"; |
| 51 const char kSizeSysAttr[] = "size"; | 51 const char kSizeSysAttr[] = "size"; |
| 52 const char kVendor[] = "ID_VENDOR"; | 52 const char kVendor[] = "ID_VENDOR"; |
| 53 const char kVendorID[] = "ID_VENDOR_ID"; | 53 const char kVendorID[] = "ID_VENDOR_ID"; |
| 54 | 54 |
| 55 // Construct a device id using label or manufacturer (vendor and model) details. | 55 // Construct a device id using label or manufacturer (vendor and model) details. |
| 56 std::string MakeDeviceUniqueId(struct udev_device* device) { | 56 std::string MakeDeviceUniqueId(struct udev_device* device) { |
| 57 std::string uuid = device::UdevDeviceGetPropertyValue(device, kFsUUID); | 57 std::string uuid = device::UdevDeviceGetPropertyValue(device, kFsUUID); |
| 58 // Keep track of device uuid, to see how often we receive empty uuid values. | |
| 59 UMA_HISTOGRAM_BOOLEAN( | |
| 60 "RemovableDeviceNotificationsLinux.device_file_system_uuid_available", | |
| 61 !uuid.empty()); | |
| 62 | |
| 63 if (!uuid.empty()) | 58 if (!uuid.empty()) |
| 64 return kFSUniqueIdPrefix + uuid; | 59 return kFSUniqueIdPrefix + uuid; |
| 65 | 60 |
| 66 // If one of the vendor, model, serial information is missing, its value | 61 // If one of the vendor, model, serial information is missing, its value |
| 67 // in the string is empty. | 62 // in the string is empty. |
| 68 // Format: VendorModelSerial:VendorInfo:ModelInfo:SerialShortInfo | 63 // Format: VendorModelSerial:VendorInfo:ModelInfo:SerialShortInfo |
| 69 // E.g.: VendorModelSerial:Kn:DataTravel_12.10:8000000000006CB02CDB | 64 // E.g.: VendorModelSerial:Kn:DataTravel_12.10:8000000000006CB02CDB |
| 70 std::string vendor = device::UdevDeviceGetPropertyValue(device, kVendorID); | 65 std::string vendor = device::UdevDeviceGetPropertyValue(device, kVendorID); |
| 71 std::string model = device::UdevDeviceGetPropertyValue(device, kModelID); | 66 std::string model = device::UdevDeviceGetPropertyValue(device, kModelID); |
| 72 std::string serial_short = | 67 std::string serial_short = |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 mount_priority_map_[mount_device][mount_point] = removable; | 454 mount_priority_map_[mount_device][mount_point] = removable; |
| 460 receiver()->ProcessAttach(*storage_info); | 455 receiver()->ProcessAttach(*storage_info); |
| 461 } | 456 } |
| 462 | 457 |
| 463 StorageMonitor* StorageMonitor::CreateInternal() { | 458 StorageMonitor* StorageMonitor::CreateInternal() { |
| 464 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 459 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
| 465 return new StorageMonitorLinux(kDefaultMtabPath); | 460 return new StorageMonitorLinux(kDefaultMtabPath); |
| 466 } | 461 } |
| 467 | 462 |
| 468 } // namespace storage_monitor | 463 } // namespace storage_monitor |
| OLD | NEW |