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

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

Issue 15294020: StorageMonitor: Make StorageInfo a real class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address nits Created 7 years, 7 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 // chromeos::StorageMonitorCros implementation. 5 // chromeos::StorageMonitorCros implementation.
6 6
7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // values. 63 // values.
64 string16 device_label = UTF8ToUTF16(disk->device_label()); 64 string16 device_label = UTF8ToUTF16(disk->device_label());
65 chrome::MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, 65 chrome::MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id,
66 device_label); 66 device_label);
67 if (unique_id.empty()) 67 if (unique_id.empty())
68 return false; 68 return false;
69 69
70 chrome::StorageInfo::Type type = has_dcim ? 70 chrome::StorageInfo::Type type = has_dcim ?
71 chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM : 71 chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM :
72 chrome::StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; 72 chrome::StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
73 info->device_id = chrome::StorageInfo::MakeDeviceId(type, unique_id); 73
74 info->location = mount_info.mount_path; 74 *info = chrome::StorageInfo(
75 info->vendor_name = UTF8ToUTF16(disk->vendor_name()); 75 chrome::StorageInfo::MakeDeviceId(type, unique_id),
76 info->model_name = UTF8ToUTF16(disk->product_name()); 76 string16(),
77 info->storage_label = device_label; 77 mount_info.mount_path,
78 info->total_size_in_bytes = disk->total_size_in_bytes(); 78 device_label,
79 UTF8ToUTF16(disk->vendor_name()),
80 UTF8ToUTF16(disk->product_name()),
81 disk->total_size_in_bytes());
79 return true; 82 return true;
80 } 83 }
81 84
82 // Returns whether the mount point in |mount_info| is a media device or not. 85 // Returns whether the mount point in |mount_info| is a media device or not.
83 bool CheckMountedPathOnFileThread( 86 bool CheckMountedPathOnFileThread(
84 const disks::DiskMountManager::MountPointInfo& mount_info) { 87 const disks::DiskMountManager::MountPointInfo& mount_info) {
85 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
86 return chrome::MediaStorageUtil::HasDcim( 89 return chrome::MediaStorageUtil::HasDcim(
87 base::FilePath(mount_info.mount_path)); 90 base::FilePath(mount_info.mount_path));
88 } 91 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 BrowserThread::FILE, FROM_HERE, 187 BrowserThread::FILE, FROM_HERE,
185 base::Bind(&CheckMountedPathOnFileThread, mount_info), 188 base::Bind(&CheckMountedPathOnFileThread, mount_info),
186 base::Bind(&StorageMonitorCros::AddMountedPath, 189 base::Bind(&StorageMonitorCros::AddMountedPath,
187 weak_ptr_factory_.GetWeakPtr(), mount_info)); 190 weak_ptr_factory_.GetWeakPtr(), mount_info));
188 break; 191 break;
189 } 192 }
190 case disks::DiskMountManager::UNMOUNTING: { 193 case disks::DiskMountManager::UNMOUNTING: {
191 MountMap::iterator it = mount_map_.find(mount_info.mount_path); 194 MountMap::iterator it = mount_map_.find(mount_info.mount_path);
192 if (it == mount_map_.end()) 195 if (it == mount_map_.end())
193 return; 196 return;
194 receiver()->ProcessDetach(it->second.device_id); 197 receiver()->ProcessDetach(it->second.device_id());
195 mount_map_.erase(it); 198 mount_map_.erase(it);
196 break; 199 break;
197 } 200 }
198 } 201 }
199 } 202 }
200 203
201 void StorageMonitorCros::OnFormatEvent( 204 void StorageMonitorCros::OnFormatEvent(
202 disks::DiskMountManager::FormatEvent event, 205 disks::DiskMountManager::FormatEvent event,
203 FormatError error_code, 206 FormatError error_code,
204 const std::string& device_path) { 207 const std::string& device_path) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 else 251 else
249 callback.Run(chrome::StorageMonitor::EJECT_FAILURE); 252 callback.Run(chrome::StorageMonitor::EJECT_FAILURE);
250 } 253 }
251 254
252 void StorageMonitorCros::EjectDevice( 255 void StorageMonitorCros::EjectDevice(
253 const std::string& device_id, 256 const std::string& device_id,
254 base::Callback<void(EjectStatus)> callback) { 257 base::Callback<void(EjectStatus)> callback) {
255 std::string mount_path; 258 std::string mount_path;
256 for (MountMap::const_iterator info_it = mount_map_.begin(); 259 for (MountMap::const_iterator info_it = mount_map_.begin();
257 info_it != mount_map_.end(); ++info_it) { 260 info_it != mount_map_.end(); ++info_it) {
258 if (info_it->second.device_id == device_id) 261 if (info_it->second.device_id() == device_id)
259 mount_path = info_it->first; 262 mount_path = info_it->first;
260 } 263 }
261 264
262 if (mount_path.empty()) { 265 if (mount_path.empty()) {
263 callback.Run(EJECT_NO_SUCH_DEVICE); 266 callback.Run(EJECT_NO_SUCH_DEVICE);
264 return; 267 return;
265 } 268 }
266 269
267 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); 270 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance();
268 if (!manager) { 271 if (!manager) {
(...skipping 19 matching lines...) Expand all
288 // in the map before the device attached handler is called. Therefore, an 291 // in the map before the device attached handler is called. Therefore, an
289 // entry for the device already exists in the map. 292 // entry for the device already exists in the map.
290 return; 293 return;
291 } 294 }
292 295
293 // Get the media device uuid and label if exists. 296 // Get the media device uuid and label if exists.
294 chrome::StorageInfo info; 297 chrome::StorageInfo info;
295 if (!GetDeviceInfo(mount_info, has_dcim, &info)) 298 if (!GetDeviceInfo(mount_info, has_dcim, &info))
296 return; 299 return;
297 300
298 if (info.device_id.empty()) 301 if (info.device_id().empty())
299 return; 302 return;
300 303
301 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); 304 mount_map_.insert(std::make_pair(mount_info.mount_path, info));
302 305
303 receiver()->ProcessAttach(info); 306 receiver()->ProcessAttach(info);
304 } 307 }
305 308
306 } // namespace chromeos 309 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor.cc ('k') | chrome/browser/storage_monitor/storage_monitor_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698