Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_mac.mm

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to head Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 ProcessRemovableStorageDetached(
102 it->second.device_id()); 102 it->second.device_id());
103 } 103 }
104 } 104 }
105 105
106 if (update_type == UPDATE_DEVICE_REMOVED) { 106 if (update_type == UPDATE_DEVICE_REMOVED) {
107 if (it != disk_info_map_.end()) 107 if (it != disk_info_map_.end())
108 disk_info_map_.erase(it); 108 disk_info_map_.erase(it);
109 } else { 109 } else {
110 disk_info_map_[info.bsd_name()] = info; 110 disk_info_map_[info.bsd_name()] = info;
111 MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(), 111 MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(),
112 info.device_name()); 112 info.device_name());
113 if (ShouldPostNotificationForDisk(info)) { 113 if (ShouldPostNotificationForDisk(info)) {
114 string16 display_name = GetDisplayNameForDevice( 114 string16 display_name = GetDisplayNameForDevice(
115 info.total_size_in_bytes(), info.device_name()); 115 info.total_size_in_bytes(), info.device_name());
116 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( 116 ProcessRemovableStorageAttached(
117 info.device_id(), display_name, info.mount_point().value()); 117 info.device_id(), display_name, info.mount_point().value());
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( 122 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath(
123 const FilePath& path, 123 const FilePath& path,
124 base::SystemMonitor::RemovableStorageInfo* device_info) const { 124 RemovableStorageInfo* device_info) const {
125 if (!path.IsAbsolute()) 125 if (!path.IsAbsolute())
126 return false; 126 return false;
127 127
128 FilePath current = path; 128 FilePath current = path;
129 const FilePath root(FilePath::kSeparators); 129 const FilePath root(FilePath::kSeparators);
130 while (current != root) { 130 while (current != root) {
131 DiskInfoMac info; 131 DiskInfoMac info;
132 if (FindDiskWithMountPoint(current, &info)) { 132 if (FindDiskWithMountPoint(current, &info)) {
133 device_info->device_id = info.device_id(); 133 device_info->device_id = info.device_id();
134 device_info->name = info.device_name(); 134 device_info->name = info.device_name();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return false; 209 return false;
210 } 210 }
211 211
212 // static 212 // static
213 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { 213 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() {
214 DCHECK(g_removable_device_notifications_mac != NULL); 214 DCHECK(g_removable_device_notifications_mac != NULL);
215 return g_removable_device_notifications_mac; 215 return g_removable_device_notifications_mac;
216 } 216 }
217 217
218 } // namespace chrome 218 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698