| 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/removable_device_notifications_histogram
.h" |
| 7 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 8 | 9 |
| 9 namespace chrome { | 10 namespace chrome { |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 void GetDiskInfoAndUpdateOnFileThread( | 14 void GetDiskInfoAndUpdateOnFileThread( |
| 14 const base::WeakPtr<RemovableDeviceNotificationsMac>& notifications, | 15 const base::WeakPtr<RemovableDeviceNotificationsMac>& notifications, |
| 15 base::mac::ScopedCFTypeRef<CFDictionaryRef> dict, | 16 base::mac::ScopedCFTypeRef<CFDictionaryRef> dict, |
| 16 RemovableDeviceNotificationsMac::UpdateType update_type) { | 17 RemovableDeviceNotificationsMac::UpdateType update_type) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 base::SystemMonitor::Get()->ProcessRemovableStorageDetached( | 90 base::SystemMonitor::Get()->ProcessRemovableStorageDetached( |
| 90 it->second.device_id()); | 91 it->second.device_id()); |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 | 94 |
| 94 if (update_type == UPDATE_DEVICE_REMOVED) { | 95 if (update_type == UPDATE_DEVICE_REMOVED) { |
| 95 if (it != disk_info_map_.end()) | 96 if (it != disk_info_map_.end()) |
| 96 disk_info_map_.erase(it); | 97 disk_info_map_.erase(it); |
| 97 } else { | 98 } else { |
| 98 disk_info_map_[info.bsd_name()] = info; | 99 disk_info_map_[info.bsd_name()] = info; |
| 100 RecordDeviceInfoHistogram(info.type(), info.device_id(), |
| 101 info.display_name()); |
| 99 if (ShouldPostNotificationForDisk(info)) { | 102 if (ShouldPostNotificationForDisk(info)) { |
| 100 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( | 103 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( |
| 101 info.device_id(), info.display_name(), info.mount_point().value()); | 104 info.device_id(), info.display_name(), info.mount_point().value()); |
| 102 } | 105 } |
| 103 } | 106 } |
| 104 } | 107 } |
| 105 | 108 |
| 106 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( | 109 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( |
| 107 const FilePath& path, | 110 const FilePath& path, |
| 108 base::SystemMonitor::RemovableStorageInfo* device_info) const { | 111 base::SystemMonitor::RemovableStorageInfo* device_info) const { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { | 181 it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { |
| 179 if (it->second.mount_point() == mount_point) { | 182 if (it->second.mount_point() == mount_point) { |
| 180 *info = it->second; | 183 *info = it->second; |
| 181 return true; | 184 return true; |
| 182 } | 185 } |
| 183 } | 186 } |
| 184 return false; | 187 return false; |
| 185 } | 188 } |
| 186 | 189 |
| 187 } // namespace chrome | 190 } // namespace chrome |
| OLD | NEW |