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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_chromeos.cc

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 // chromeos::RemovableDeviceNotificationsCros implementation. 5 // chromeos::RemovableDeviceNotificationsCros implementation.
6 6
7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h" 7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" 15 #include "chrome/browser/system_monitor/media_device_notifications_utils.h"
16 #include "chrome/browser/system_monitor/media_storage_util.h" 16 #include "chrome/browser/system_monitor/media_storage_util.h"
17 #include "chrome/browser/system_monitor/removable_device_constants.h" 17 #include "chrome/browser/system_monitor/removable_device_constants.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 using base::SystemMonitor;
23
24 namespace { 22 namespace {
25 23
26 // Constructs a device name using label or manufacturer (vendor and product) 24 // Constructs a device name using label or manufacturer (vendor and product)
27 // name details. 25 // name details.
28 string16 GetDeviceName(const disks::DiskMountManager::Disk& disk) { 26 string16 GetDeviceName(const disks::DiskMountManager::Disk& disk) {
29 if (disk.device_type() == DEVICE_TYPE_SD) { 27 if (disk.device_type() == DEVICE_TYPE_SD) {
30 // Mount path of an SD card will be one of the following: 28 // Mount path of an SD card will be one of the following:
31 // (1) /media/removable/<volume_label> 29 // (1) /media/removable/<volume_label>
32 // (2) /media/removable/SD Card 30 // (2) /media/removable/SD Card
33 // If the volume label is available, mount path will be (1) else (2). 31 // If the volume label is available, mount path will be (1) else (2).
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 BrowserThread::FILE, FROM_HERE, 156 BrowserThread::FILE, FROM_HERE,
159 base::Bind( 157 base::Bind(
160 &RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread, 158 &RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread,
161 this, mount_info)); 159 this, mount_info));
162 break; 160 break;
163 } 161 }
164 case disks::DiskMountManager::UNMOUNTING: { 162 case disks::DiskMountManager::UNMOUNTING: {
165 MountMap::iterator it = mount_map_.find(mount_info.mount_path); 163 MountMap::iterator it = mount_map_.find(mount_info.mount_path);
166 if (it == mount_map_.end()) 164 if (it == mount_map_.end())
167 return; 165 return;
168 SystemMonitor::Get()->ProcessRemovableStorageDetached( 166 ProcessRemovableStorageDetached(
169 it->second.storage_info.device_id); 167 it->second.storage_info.device_id);
170 mount_map_.erase(it); 168 mount_map_.erase(it);
171 break; 169 break;
172 } 170 }
173 } 171 }
174 } 172 }
175 173
176 void RemovableDeviceNotificationsCros::OnFormatEvent( 174 void RemovableDeviceNotificationsCros::OnFormatEvent(
177 disks::DiskMountManager::FormatEvent event, 175 disks::DiskMountManager::FormatEvent event,
178 FormatError error_code, 176 FormatError error_code,
179 const std::string& device_path) { 177 const std::string& device_path) {
180 } 178 }
181 179
182 bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath( 180 bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath(
183 const FilePath& path, 181 const FilePath& path,
184 SystemMonitor::RemovableStorageInfo* device_info) const { 182 RemovableStorageInfo* device_info) const {
185 if (!path.IsAbsolute()) 183 if (!path.IsAbsolute())
186 return false; 184 return false;
187 185
188 FilePath current = path; 186 FilePath current = path;
189 while (!ContainsKey(mount_map_, current.value()) && 187 while (!ContainsKey(mount_map_, current.value()) &&
190 current != current.DirName()) { 188 current != current.DirName()) {
191 current = current.DirName(); 189 current = current.DirName();
192 } 190 }
193 191
194 MountMap::const_iterator info_it = mount_map_.find(current.value()); 192 MountMap::const_iterator info_it = mount_map_.find(current.value());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (unique_id.empty() || device_label.empty()) 243 if (unique_id.empty() || device_label.empty())
246 return; 244 return;
247 245
248 chrome::MediaStorageUtil::Type type = has_dcim ? 246 chrome::MediaStorageUtil::Type type = has_dcim ?
249 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : 247 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM :
250 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; 248 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM;
251 249
252 std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type, 250 std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type,
253 unique_id); 251 unique_id);
254 StorageObjectInfo object_info = { 252 StorageObjectInfo object_info = {
255 base::SystemMonitor::RemovableStorageInfo(device_id, device_label, 253 RemovableStorageInfo(device_id, device_label,
256 mount_info.mount_path), 254 mount_info.mount_path),
257 storage_size_in_bytes 255 storage_size_in_bytes
258 }; 256 };
259 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); 257 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info));
260 SystemMonitor::Get()->ProcessRemovableStorageAttached( 258 ProcessRemovableStorageAttached(
261 device_id, 259 device_id,
262 chrome::GetDisplayNameForDevice(storage_size_in_bytes, device_label), 260 chrome::GetDisplayNameForDevice(storage_size_in_bytes, device_label),
263 mount_info.mount_path); 261 mount_info.mount_path);
264 } 262 }
265 263
266 } // namespace chromeos 264 } // namespace chromeos
267 265
268 namespace chrome { 266 namespace chrome {
269 267
270 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { 268 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() {
271 return chromeos::g_removable_device_notifications_chromeos; 269 return chromeos::g_removable_device_notifications_chromeos;
272 } 270 }
273 271
274 } // namespace chrome 272 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698