Index: chrome/browser/storage_monitor/storage_monitor_mac.mm |
=================================================================== |
--- chrome/browser/storage_monitor/storage_monitor_mac.mm (revision 201619) |
+++ chrome/browser/storage_monitor/storage_monitor_mac.mm (working copy) |
@@ -47,8 +47,6 @@ |
CFDictionaryRef dict, std::string* bsd_name) { |
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
- StorageInfo info; |
- |
CFStringRef device_bsd_name = base::mac::GetValueFromDictionary<CFStringRef>( |
dict, kDADiskDescriptionMediaBSDNameKey); |
if (device_bsd_name && bsd_name) |
@@ -57,20 +55,19 @@ |
CFURLRef url = base::mac::GetValueFromDictionary<CFURLRef>( |
dict, kDADiskDescriptionVolumePathKey); |
NSURL* nsurl = base::mac::CFToNSCast(url); |
- info.location = base::mac::NSStringToFilePath([nsurl path]).value(); |
+ base::FilePath location = base::mac::NSStringToFilePath([nsurl path]); |
CFNumberRef size_number = |
base::mac::GetValueFromDictionary<CFNumberRef>( |
dict, kDADiskDescriptionMediaSizeKey); |
- if (size_number) { |
- CFNumberGetValue(size_number, kCFNumberLongLongType, |
- &(info.total_size_in_bytes)); |
- } |
+ uint64 size_in_bytes = 0; |
+ if (size_number) |
+ CFNumberGetValue(size_number, kCFNumberLongLongType, &size_in_bytes); |
- info.vendor_name = GetUTF16FromDictionary( |
+ string16 vendor = GetUTF16FromDictionary( |
dict, kDADiskDescriptionDeviceVendorKey); |
- info.model_name = GetUTF16FromDictionary( |
+ string16 model = GetUTF16FromDictionary( |
dict, kDADiskDescriptionDeviceModelKey); |
- info.storage_label = GetUTF16FromDictionary( |
+ string16 label = GetUTF16FromDictionary( |
dict, kDADiskDescriptionVolumeNameKey); |
CFUUIDRef uuid = base::mac::GetValueFromDictionary<CFUUIDRef>( |
@@ -85,8 +82,8 @@ |
if (unique_id.empty()) { |
string16 revision = GetUTF16FromDictionary( |
dict, kDADiskDescriptionDeviceRevisionKey); |
- string16 unique_id2 = info.vendor_name; |
- unique_id2 = JoinName(unique_id2, info.model_name); |
+ string16 unique_id2 = vendor; |
+ unique_id2 = JoinName(unique_id2, model); |
unique_id2 = JoinName(unique_id2, revision); |
unique_id = UTF16ToUTF8(unique_id2); |
} |
@@ -96,14 +93,14 @@ |
dict, kDADiskDescriptionMediaRemovableKey); |
bool is_removable = is_removable_ref && CFBooleanGetValue(is_removable_ref); |
// Checking for DCIM only matters on removable devices. |
- bool has_dcim = is_removable && |
- MediaStorageUtil::HasDcim(base::FilePath(info.location)); |
+ bool has_dcim = is_removable && MediaStorageUtil::HasDcim(location); |
StorageInfo::Type device_type = GetDeviceType(is_removable, has_dcim); |
+ std::string device_id; |
if (!unique_id.empty()) |
- info.device_id = StorageInfo::MakeDeviceId(device_type, |
- unique_id); |
+ device_id = StorageInfo::MakeDeviceId(device_type, unique_id); |
- return info; |
+ return StorageInfo(device_id, string16(), location.value(), label, vendor, |
+ model, size_in_bytes); |
} |
void GetDiskInfoAndUpdateOnFileThread( |
@@ -217,7 +214,7 @@ |
if (!IsInitialized() && pending_disk_updates_ == 0) |
initialization_complete = true; |
- if (info.device_id.empty() || bsd_name.empty()) { |
+ if (info.device_id().empty() || bsd_name.empty()) { |
if (initialization_complete) |
MarkInitialized(); |
return; |
@@ -230,7 +227,7 @@ |
// notification now. This is used for devices that are being removed or |
// devices that have changed. |
if (ShouldPostNotificationForDisk(it->second)) { |
- receiver()->ProcessDetach(it->second.device_id); |
+ receiver()->ProcessDetach(it->second.device_id()); |
} |
} |
@@ -239,8 +236,8 @@ |
disk_info_map_.erase(it); |
} else { |
disk_info_map_[bsd_name] = info; |
- MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id, |
- info.storage_label); |
+ MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(), |
+ info.storage_label()); |
if (ShouldPostNotificationForDisk(info)) |
receiver()->ProcessAttach(info); |
} |
@@ -278,7 +275,7 @@ |
std::string bsd_name; |
for (std::map<std::string, StorageInfo>::iterator |
it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { |
- if (it->second.device_id == device_id) { |
+ if (it->second.device_id() == device_id) { |
bsd_name = it->first; |
disk_info_map_.erase(it); |
break; |
@@ -353,11 +350,11 @@ |
const StorageInfo& info) const { |
// Only post notifications about disks that have no empty fields and |
// are removable. Also exclude disk images (DMGs). |
- return !info.device_id.empty() && |
- !info.location.empty() && |
- info.model_name != ASCIIToUTF16(kDiskImageModelName) && |
- StorageInfo::IsRemovableDevice(info.device_id) && |
- StorageInfo::IsMassStorageDevice(info.device_id); |
+ return !info.device_id().empty() && |
+ !info.location().empty() && |
+ info.model_name() != ASCIIToUTF16(kDiskImageModelName) && |
+ StorageInfo::IsRemovableDevice(info.device_id()) && |
+ StorageInfo::IsMassStorageDevice(info.device_id()); |
} |
bool StorageMonitorMac::FindDiskWithMountPoint( |
@@ -365,7 +362,7 @@ |
StorageInfo* info) const { |
for (std::map<std::string, StorageInfo>::const_iterator |
it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { |
- if (it->second.location == mount_point.value()) { |
+ if (it->second.location() == mount_point.value()) { |
*info = it->second; |
return true; |
} |