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

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

Issue 12544005: Consolidate storage_monitor/MediaDeviceNotificationsUtils into MediaStorageUtil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac apply patch Created 7 years, 9 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
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_mac.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/storage_monitor/volume_mount_watcher_win.h" 5 #include "chrome/browser/storage_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/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/storage_monitor/media_device_notifications_utils.h"
16 #include "chrome/browser/storage_monitor/media_storage_util.h" 15 #include "chrome/browser/storage_monitor/media_storage_util.h"
17 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
18 17
19 using content::BrowserThread; 18 using content::BrowserThread;
20 19
21 namespace { 20 namespace {
22 21
23 const DWORD kMaxPathBufLen = MAX_PATH + 1; 22 const DWORD kMaxPathBufLen = MAX_PATH + 1;
24 23
25 enum DeviceType { 24 enum DeviceType {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 &unique_id, &device_name, &removable, 255 &unique_id, &device_name, &removable,
257 &total_size_in_bytes)) { 256 &total_size_in_bytes)) {
258 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 257 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
259 &chrome::VolumeMountWatcherWin::DeviceCheckComplete, 258 &chrome::VolumeMountWatcherWin::DeviceCheckComplete,
260 volume_watcher, device_path)); 259 volume_watcher, device_path));
261 return; 260 return;
262 } 261 }
263 262
264 chrome::MediaStorageUtil::Type type = 263 chrome::MediaStorageUtil::Type type =
265 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; 264 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM;
266 if (chrome::IsMediaDevice(device_path.value())) 265 if (MediaStorageUtil::HasDcim(device_path.value()))
267 type = chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM; 266 type = chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM;
268 std::string device_id = 267 std::string device_id =
269 chrome::MediaStorageUtil::MakeDeviceId(type, unique_id); 268 chrome::MediaStorageUtil::MakeDeviceId(type, unique_id);
270 269
271 chrome::VolumeMountWatcherWin::MountPointInfo info; 270 chrome::VolumeMountWatcherWin::MountPointInfo info;
272 info.device_id = device_id; 271 info.device_id = device_id;
273 info.location = device_location; 272 info.location = device_location;
274 info.unique_id = unique_id; 273 info.unique_id = unique_id;
275 info.name = device_name; 274 info.name = device_name;
276 info.removable = removable; 275 info.removable = removable;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 374
376 device_metadata_[device_path.value()] = info; 375 device_metadata_[device_path.value()] = info;
377 376
378 DeviceCheckComplete(device_path); 377 DeviceCheckComplete(device_path);
379 378
380 // Don't call removable storage observers for fixed volumes. 379 // Don't call removable storage observers for fixed volumes.
381 if (!info.removable) 380 if (!info.removable)
382 return; 381 return;
383 382
384 if (notifications_) { 383 if (notifications_) {
385 string16 display_name = 384 string16 display_name = MediaStorageUtil::GetDisplayNameForDevice(
386 GetDisplayNameForDevice(info.total_size_in_bytes, info.name); 385 info.total_size_in_bytes, info.name);
386
387 notifications_->ProcessAttach(StorageInfo(info.device_id, display_name, 387 notifications_->ProcessAttach(StorageInfo(info.device_id, display_name,
388 device_path.value())); 388 device_path.value()));
389 } 389 }
390 } 390 }
391 391
392 void VolumeMountWatcherWin::HandleDeviceDetachEventOnUIThread( 392 void VolumeMountWatcherWin::HandleDeviceDetachEventOnUIThread(
393 const string16& device_location) { 393 const string16& device_location) {
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
395 395
396 MountPointDeviceMetadataMap::const_iterator device_info = 396 MountPointDeviceMetadataMap::const_iterator device_info =
397 device_metadata_.find(device_location); 397 device_metadata_.find(device_location);
398 // If the device isn't type removable (like a CD), it won't be there. 398 // If the device isn't type removable (like a CD), it won't be there.
399 if (device_info == device_metadata_.end()) 399 if (device_info == device_metadata_.end())
400 return; 400 return;
401 401
402 if (notifications_) 402 if (notifications_)
403 notifications_->ProcessDetach(device_info->second.device_id); 403 notifications_->ProcessDetach(device_info->second.device_id);
404 device_metadata_.erase(device_info); 404 device_metadata_.erase(device_info);
405 } 405 }
406 406
407 } // namespace chrome 407 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_mac.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698