| 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 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" | 5 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" | 7 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 namespace chrome { | 10 namespace chrome { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (info.bsd_name().empty()) | 91 if (info.bsd_name().empty()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 std::map<std::string, DiskInfoMac>::iterator it = | 94 std::map<std::string, DiskInfoMac>::iterator it = |
| 95 disk_info_map_.find(info.bsd_name()); | 95 disk_info_map_.find(info.bsd_name()); |
| 96 if (it != disk_info_map_.end()) { | 96 if (it != disk_info_map_.end()) { |
| 97 // If an attached notification was previously posted then post a detached | 97 // If an attached notification was previously posted then post a detached |
| 98 // notification now. This is used for devices that are being removed or | 98 // notification now. This is used for devices that are being removed or |
| 99 // devices that have changed. | 99 // devices that have changed. |
| 100 if (ShouldPostNotificationForDisk(it->second)) { | 100 if (ShouldPostNotificationForDisk(it->second)) { |
| 101 base::SystemMonitor::Get()->ProcessRemovableStorageDetached( | 101 ProcessDetach(it->second.device_id()); |
| 102 it->second.device_id()); | |
| 103 } | 102 } |
| 104 } | 103 } |
| 105 | 104 |
| 106 if (update_type == UPDATE_DEVICE_REMOVED) { | 105 if (update_type == UPDATE_DEVICE_REMOVED) { |
| 107 if (it != disk_info_map_.end()) | 106 if (it != disk_info_map_.end()) |
| 108 disk_info_map_.erase(it); | 107 disk_info_map_.erase(it); |
| 109 } else { | 108 } else { |
| 110 disk_info_map_[info.bsd_name()] = info; | 109 disk_info_map_[info.bsd_name()] = info; |
| 111 MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(), | 110 MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(), |
| 112 info.device_name()); | 111 info.device_name()); |
| 113 if (ShouldPostNotificationForDisk(info)) { | 112 if (ShouldPostNotificationForDisk(info)) { |
| 114 string16 display_name = GetDisplayNameForDevice( | 113 string16 display_name = GetDisplayNameForDevice( |
| 115 info.total_size_in_bytes(), info.device_name()); | 114 info.total_size_in_bytes(), info.device_name()); |
| 116 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( | 115 ProcessAttach(info.device_id(), display_name, info.mount_point().value()); |
| 117 info.device_id(), display_name, info.mount_point().value()); | |
| 118 } | 116 } |
| 119 } | 117 } |
| 120 } | 118 } |
| 121 | 119 |
| 122 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( | 120 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( |
| 123 const FilePath& path, | 121 const FilePath& path, |
| 124 base::SystemMonitor::RemovableStorageInfo* device_info) const { | 122 StorageInfo* device_info) const { |
| 125 if (!path.IsAbsolute()) | 123 if (!path.IsAbsolute()) |
| 126 return false; | 124 return false; |
| 127 | 125 |
| 128 FilePath current = path; | 126 FilePath current = path; |
| 129 const FilePath root(FilePath::kSeparators); | 127 const FilePath root(FilePath::kSeparators); |
| 130 while (current != root) { | 128 while (current != root) { |
| 131 DiskInfoMac info; | 129 DiskInfoMac info; |
| 132 if (FindDiskWithMountPoint(current, &info)) { | 130 if (FindDiskWithMountPoint(current, &info)) { |
| 133 device_info->device_id = info.device_id(); | 131 device_info->device_id = info.device_id(); |
| 134 device_info->name = info.device_name(); | 132 device_info->name = info.device_name(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return false; | 207 return false; |
| 210 } | 208 } |
| 211 | 209 |
| 212 // static | 210 // static |
| 213 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { | 211 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { |
| 214 DCHECK(g_removable_device_notifications_mac != NULL); | 212 DCHECK(g_removable_device_notifications_mac != NULL); |
| 215 return g_removable_device_notifications_mac; | 213 return g_removable_device_notifications_mac; |
| 216 } | 214 } |
| 217 | 215 |
| 218 } // namespace chrome | 216 } // namespace chrome |
| OLD | NEW |