Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // RemovableDeviceNotificationsLinux implementation. | 5 // RemovableDeviceNotificationsLinux implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" | 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" |
| 8 | 8 |
| 9 #include <libudev.h> | 9 #include <libudev.h> |
| 10 #include <mntent.h> | 10 #include <mntent.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 | 12 |
| 13 #include <list> | 13 #include <list> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
| 17 #include "base/memory/scoped_generic_obj.h" | 17 #include "base/memory/scoped_generic_obj.h" |
| 18 #include "base/metrics/histogram.h" | |
| 19 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 20 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 21 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 22 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
| 23 #include "base/system_monitor/system_monitor.h" | 22 #include "base/system_monitor/system_monitor.h" |
| 24 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 25 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" | 24 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 26 #include "chrome/browser/system_monitor/removable_device_constants.h" | 25 #include "chrome/browser/system_monitor/removable_device_constants.h" |
| 26 #include "chrome/browser/system_monitor/removable_device_notifications_histogram .h" | |
| 27 #include "chrome/browser/system_monitor/media_storage_util.h" | 27 #include "chrome/browser/system_monitor/media_storage_util.h" |
| 28 | 28 |
| 29 namespace chrome { | 29 namespace chrome { |
| 30 | 30 |
| 31 using base::SystemMonitor; | 31 using base::SystemMonitor; |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 static RemovableDeviceNotificationsLinux* | 36 static RemovableDeviceNotificationsLinux* |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 mount_info_map_[mount_point] = | 463 mount_info_map_[mount_point] = |
| 464 mount_info_map_.find(other_mount_point)->second; | 464 mount_info_map_.find(other_mount_point)->second; |
| 465 return; | 465 return; |
| 466 } | 466 } |
| 467 | 467 |
| 468 std::string unique_id; | 468 std::string unique_id; |
| 469 string16 name; | 469 string16 name; |
| 470 bool removable; | 470 bool removable; |
| 471 get_device_info_func_(mount_device, &unique_id, &name, &removable); | 471 get_device_info_func_(mount_device, &unique_id, &name, &removable); |
| 472 | 472 |
| 473 | |
| 474 // Keep track of device uuid, to see how often we receive empty values. | |
| 475 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.DeviceUUIDAvailable", | |
| 476 !unique_id.empty()); | |
| 477 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.DeviceNameAvailable", | |
| 478 !name.empty()); | |
| 479 if (unique_id.empty() || name.empty()) | |
| 480 return; | |
| 481 | |
| 482 bool has_dcim = IsMediaDevice(mount_point.value()); | 473 bool has_dcim = IsMediaDevice(mount_point.value()); |
| 483 MediaStorageUtil::Type type; | 474 MediaStorageUtil::Type type; |
| 484 if (removable) { | 475 if (removable) { |
| 485 if (has_dcim) { | 476 if (has_dcim) { |
| 486 type = MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM; | 477 type = MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM; |
| 487 } else { | 478 } else { |
| 488 type = MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; | 479 type = MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; |
| 489 } | 480 } |
| 490 } else { | 481 } else { |
| 491 type = MediaStorageUtil::FIXED_MASS_STORAGE; | 482 type = MediaStorageUtil::FIXED_MASS_STORAGE; |
| 492 } | 483 } |
| 484 | |
| 485 // Keep track of device info details to see how often we get invalid values. | |
| 486 RecordDeviceInfoHistogram(type, unique_id, name); | |
| 487 if (unique_id.empty() || name.empty()) | |
|
vandebo (ex-Chrome)
2012/09/16 22:27:46
No point in figuring out the precise type if we're
kmadhusu
2012/09/17 18:29:07
Fixed.
| |
| 488 return; | |
| 489 | |
| 493 std::string device_id = MediaStorageUtil::MakeDeviceId(type, unique_id); | 490 std::string device_id = MediaStorageUtil::MakeDeviceId(type, unique_id); |
| 494 | 491 |
| 495 MountPointInfo mount_point_info; | 492 MountPointInfo mount_point_info; |
| 496 mount_point_info.mount_device = mount_device; | 493 mount_point_info.mount_device = mount_device; |
| 497 mount_point_info.device_id = device_id; | 494 mount_point_info.device_id = device_id; |
| 498 mount_point_info.device_name = name; | 495 mount_point_info.device_name = name; |
| 499 | 496 |
| 500 mount_info_map_[mount_point] = mount_point_info; | 497 mount_info_map_[mount_point] = mount_point_info; |
| 501 mount_priority_map_[mount_device][mount_point] = removable; | 498 mount_priority_map_[mount_device][mount_point] = removable; |
| 502 | 499 |
| 503 if (removable) { | 500 if (removable) { |
| 504 SystemMonitor::Get()->ProcessRemovableStorageAttached(device_id, name, | 501 SystemMonitor::Get()->ProcessRemovableStorageAttached(device_id, name, |
| 505 mount_point.value()); | 502 mount_point.value()); |
| 506 } | 503 } |
| 507 } | 504 } |
| 508 | 505 |
| 509 } // namespace chrome | 506 } // namespace chrome |
| OLD | NEW |