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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor_linux.cc

Issue 16041004: Cleanup: Remove ScopedGenericObj usage in chrome/. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix compile Created 7 years, 6 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 // StorageMonitorLinux implementation. 5 // StorageMonitorLinux implementation.
6 6
7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 char device_type; 154 char device_type;
155 if (S_ISCHR(device_stat.st_mode)) 155 if (S_ISCHR(device_stat.st_mode))
156 device_type = 'c'; 156 device_type = 'c';
157 else if (S_ISBLK(device_stat.st_mode)) 157 else if (S_ISBLK(device_stat.st_mode))
158 device_type = 'b'; 158 device_type = 'b';
159 else 159 else
160 return storage_info.Pass(); // Not a supported type. 160 return storage_info.Pass(); // Not a supported type.
161 161
162 ScopedUdevDeviceObject device( 162 ScopedUdevDeviceObject device(
163 udev_device_new_from_devnum(udev_obj, device_type, device_stat.st_rdev)); 163 udev_device_new_from_devnum(udev_obj.get(), device_type,
164 device_stat.st_rdev));
164 if (!device.get()) 165 if (!device.get())
165 return storage_info.Pass(); 166 return storage_info.Pass();
166 167
167 string16 volume_label = UTF8ToUTF16(GetUdevDevicePropertyValue(device, 168 string16 volume_label = UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(),
168 kLabel)); 169 kLabel));
169 string16 vendor_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device, 170 string16 vendor_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(),
170 kVendor)); 171 kVendor));
171 string16 model_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device, kModel)); 172 string16 model_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(),
173 kModel));
172 174
173 std::string unique_id = MakeDeviceUniqueId(device); 175 std::string unique_id = MakeDeviceUniqueId(device.get());
174 176
175 // Keep track of device info details to see how often we get invalid values. 177 // Keep track of device info details to see how often we get invalid values.
176 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label); 178 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label);
177 179
178 const char* value = udev_device_get_sysattr_value(device, kRemovableSysAttr); 180 const char* value =
181 udev_device_get_sysattr_value(device.get(), kRemovableSysAttr);
179 if (!value) { 182 if (!value) {
180 // |parent_device| is owned by |device| and does not need to be cleaned 183 // |parent_device| is owned by |device| and does not need to be cleaned
181 // up. 184 // up.
182 struct udev_device* parent_device = 185 struct udev_device* parent_device =
183 udev_device_get_parent_with_subsystem_devtype(device, 186 udev_device_get_parent_with_subsystem_devtype(device.get(),
184 kBlockSubsystemKey, 187 kBlockSubsystemKey,
185 kDiskDeviceTypeKey); 188 kDiskDeviceTypeKey);
186 value = udev_device_get_sysattr_value(parent_device, kRemovableSysAttr); 189 value = udev_device_get_sysattr_value(parent_device, kRemovableSysAttr);
187 } 190 }
188 const bool is_removable = (value && atoi(value) == 1); 191 const bool is_removable = (value && atoi(value) == 1);
189 192
190 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE; 193 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE;
191 if (is_removable) { 194 if (is_removable) {
192 if (MediaStorageUtil::HasDcim(mount_point)) 195 if (MediaStorageUtil::HasDcim(mount_point))
193 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; 196 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
194 else 197 else
195 type = StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; 198 type = StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
196 } 199 }
197 200
198 results_recorder.set_result(true); 201 results_recorder.set_result(true);
199 202
200 storage_info.reset(new StorageInfo( 203 storage_info.reset(new StorageInfo(
201 StorageInfo::MakeDeviceId(type, unique_id), 204 StorageInfo::MakeDeviceId(type, unique_id),
202 string16(), 205 string16(),
203 mount_point.value(), 206 mount_point.value(),
204 volume_label, 207 volume_label,
205 vendor_name, 208 vendor_name,
206 model_name, 209 model_name,
207 GetDeviceStorageSize(device_path, device))); 210 GetDeviceStorageSize(device_path, device.get())));
208 return storage_info.Pass(); 211 return storage_info.Pass();
209 } 212 }
210 213
211 MtabWatcherLinux* CreateMtabWatcherLinuxOnFileThread( 214 MtabWatcherLinux* CreateMtabWatcherLinuxOnFileThread(
212 const base::FilePath& mtab_path, 215 const base::FilePath& mtab_path,
213 base::WeakPtr<MtabWatcherLinux::Delegate> delegate) { 216 base::WeakPtr<MtabWatcherLinux::Delegate> delegate) {
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
215 // Owned by caller. 218 // Owned by caller.
216 return new MtabWatcherLinux(mtab_path, delegate); 219 return new MtabWatcherLinux(mtab_path, delegate);
217 } 220 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 MountPointInfo mount_point_info; 508 MountPointInfo mount_point_info;
506 mount_point_info.mount_device = mount_device; 509 mount_point_info.mount_device = mount_device;
507 mount_point_info.storage_info = *storage_info; 510 mount_point_info.storage_info = *storage_info;
508 mount_info_map_[mount_point] = mount_point_info; 511 mount_info_map_[mount_point] = mount_point_info;
509 mount_priority_map_[mount_device][mount_point] = removable; 512 mount_priority_map_[mount_device][mount_point] = removable;
510 if (removable) 513 if (removable)
511 receiver()->ProcessAttach(*storage_info); 514 receiver()->ProcessAttach(*storage_info);
512 } 515 }
513 516
514 } // namespace chrome 517 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/fileapi/native_media_file_util.cc ('k') | chrome/browser/storage_monitor/udev_util_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698