OLD | NEW |
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 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 if (name) | 315 if (name) |
316 *name = iter->second.name; | 316 *name = iter->second.name; |
317 if (removable) | 317 if (removable) |
318 *removable = iter->second.removable; | 318 *removable = iter->second.removable; |
319 if (total_size_in_bytes) | 319 if (total_size_in_bytes) |
320 *total_size_in_bytes = iter->second.total_size_in_bytes; | 320 *total_size_in_bytes = iter->second.total_size_in_bytes; |
321 | 321 |
322 return true; | 322 return true; |
323 } | 323 } |
324 | 324 |
325 uint64 VolumeMountWatcherWin::GetStorageSize( | |
326 const base::FilePath::StringType& mount_point) const { | |
327 MountPointDeviceMetadataMap::const_iterator iter = | |
328 device_metadata_.find(mount_point); | |
329 if (iter != device_metadata_.end()) | |
330 return iter->second.total_size_in_bytes; | |
331 return 0; | |
332 } | |
333 | |
334 void VolumeMountWatcherWin::OnWindowMessage(UINT event_type, LPARAM data) { | 325 void VolumeMountWatcherWin::OnWindowMessage(UINT event_type, LPARAM data) { |
335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
336 switch (event_type) { | 327 switch (event_type) { |
337 case DBT_DEVICEARRIVAL: { | 328 case DBT_DEVICEARRIVAL: { |
338 if (IsLogicalVolumeStructure(data)) { | 329 if (IsLogicalVolumeStructure(data)) { |
339 DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data); | 330 DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data); |
340 std::vector<base::FilePath> paths; | 331 std::vector<base::FilePath> paths; |
341 for (int i = 0; unitmask; ++i, unitmask >>= 1) { | 332 for (int i = 0; unitmask; ++i, unitmask >>= 1) { |
342 if (!(unitmask & 0x01)) | 333 if (!(unitmask & 0x01)) |
343 continue; | 334 continue; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // If the device isn't type removable (like a CD), it won't be there. | 393 // If the device isn't type removable (like a CD), it won't be there. |
403 if (device_info == device_metadata_.end()) | 394 if (device_info == device_metadata_.end()) |
404 return; | 395 return; |
405 | 396 |
406 if (notifications_) | 397 if (notifications_) |
407 notifications_->ProcessDetach(device_info->second.device_id); | 398 notifications_->ProcessDetach(device_info->second.device_id); |
408 device_metadata_.erase(device_info); | 399 device_metadata_.erase(device_info); |
409 } | 400 } |
410 | 401 |
411 } // namespace chrome | 402 } // namespace chrome |
OLD | NEW |