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

Side by Side Diff: chrome/browser/system_monitor/volume_mount_watcher_win.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: Typedef, init observer 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/volume_mount_watcher_win.h" 5 #include "chrome/browser/system_monitor/volume_mount_watcher_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <dbt.h> 8 #include <dbt.h>
9 #include <fileapi.h> 9 #include <fileapi.h>
10 10
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" 14 #include "chrome/browser/system_monitor/media_device_notifications_utils.h"
15 #include "chrome/browser/system_monitor/media_storage_util.h" 15 #include "chrome/browser/system_monitor/media_storage_util.h"
16 #include "chrome/browser/system_monitor/removable_storage_notifications.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 18
18 using base::SystemMonitor;
19 using content::BrowserThread; 19 using content::BrowserThread;
20 20
21 namespace { 21 namespace {
22 22
23 const DWORD kMaxPathBufLen = MAX_PATH + 1; 23 const DWORD kMaxPathBufLen = MAX_PATH + 1;
24 24
25 bool IsRemovable(const string16& mount_point) { 25 bool IsRemovable(const string16& mount_point) {
26 if (GetDriveType(mount_point.c_str()) != DRIVE_REMOVABLE) 26 if (GetDriveType(mount_point.c_str()) != DRIVE_REMOVABLE)
27 return false; 27 return false;
28 28
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 void VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread( 235 void VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread(
236 const std::string& device_id, const string16& device_name, 236 const std::string& device_id, const string16& device_name,
237 const FilePath& device_path) { 237 const FilePath& device_path) {
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
239 239
240 // Remember metadata for this device. 240 // Remember metadata for this device.
241 MountPointInfo info; 241 MountPointInfo info;
242 info.device_id = device_id; 242 info.device_id = device_id;
243 device_metadata_[device_path.value()] = info; 243 device_metadata_[device_path.value()] = info;
244 244
245 SystemMonitor* monitor = SystemMonitor::Get(); 245 RemovableStorageNotifications* notifications =
246 if (monitor) { 246 RemovableStorageNotifications::GetInstance();
247 if (notifications) {
247 string16 display_name = GetDisplayNameForDevice(0, device_name); 248 string16 display_name = GetDisplayNameForDevice(0, device_name);
248 monitor->ProcessRemovableStorageAttached(device_id, display_name, 249 notifications->ProcessAttach(device_id, display_name, device_path.value());
249 device_path.value());
250 } 250 }
251 } 251 }
252 252
253 void VolumeMountWatcherWin::HandleDeviceDetachEventOnUIThread( 253 void VolumeMountWatcherWin::HandleDeviceDetachEventOnUIThread(
254 const string16& device_location) { 254 const string16& device_location) {
255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
256 MountPointDeviceMetadataMap::const_iterator device_info = 256 MountPointDeviceMetadataMap::const_iterator device_info =
257 device_metadata_.find(device_location); 257 device_metadata_.find(device_location);
258 // If the devices isn't type removable (like a CD), it won't be there. 258 // If the devices isn't type removable (like a CD), it won't be there.
259 if (device_info == device_metadata_.end()) 259 if (device_info == device_metadata_.end())
260 return; 260 return;
261 261
262 SystemMonitor* monitor = SystemMonitor::Get(); 262 RemovableStorageNotifications* notifications =
263 if (monitor) 263 RemovableStorageNotifications::GetInstance();
264 monitor->ProcessRemovableStorageDetached(device_info->second.device_id); 264 if (notifications)
265 notifications->ProcessDetach(device_info->second.device_id);
265 device_metadata_.erase(device_info); 266 device_metadata_.erase(device_info);
266 } 267 }
267 268
268 } // namespace chrome 269 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698