| 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 | 8 |
| 9 #include <dbt.h> | 9 #include <dbt.h> |
| 10 #include <fileapi.h> | 10 #include <fileapi.h> |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 kMaxPathBufLen)) { | 141 kMaxPathBufLen)) { |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // If we're adding a floppy drive, return without querying any more | 145 // If we're adding a floppy drive, return without querying any more |
| 146 // drive metadata -- it will cause the floppy drive to seek. | 146 // drive metadata -- it will cause the floppy drive to seek. |
| 147 // Note: treats FLOPPY as FIXED_MASS_STORAGE. This is intentional. | 147 // Note: treats FLOPPY as FIXED_MASS_STORAGE. This is intentional. |
| 148 DeviceType device_type = GetDeviceType(mount_point); | 148 DeviceType device_type = GetDeviceType(mount_point); |
| 149 if (device_type == FLOPPY) { | 149 if (device_type == FLOPPY) { |
| 150 info->set_device_id(StorageInfo::MakeDeviceId( | 150 info->set_device_id(StorageInfo::MakeDeviceId( |
| 151 StorageInfo::FIXED_MASS_STORAGE, UTF16ToUTF8(guid))); | 151 StorageInfo::FIXED_MASS_STORAGE, base::UTF16ToUTF8(guid))); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE; | 155 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE; |
| 156 if (device_type == REMOVABLE) { | 156 if (device_type == REMOVABLE) { |
| 157 type = StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; | 157 type = StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; |
| 158 if (MediaStorageUtil::HasDcim(base::FilePath(mount_point))) | 158 if (MediaStorageUtil::HasDcim(base::FilePath(mount_point))) |
| 159 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; | 159 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; |
| 160 } | 160 } |
| 161 | 161 |
| 162 // NOTE: experimentally, this function returns false if there is no volume | 162 // NOTE: experimentally, this function returns false if there is no volume |
| 163 // name set. | 163 // name set. |
| 164 base::string16 volume_label; | 164 base::string16 volume_label; |
| 165 GetVolumeInformationW(device_path.value().c_str(), | 165 GetVolumeInformationW(device_path.value().c_str(), |
| 166 WriteInto(&volume_label, kMaxPathBufLen), | 166 WriteInto(&volume_label, kMaxPathBufLen), |
| 167 kMaxPathBufLen, NULL, NULL, NULL, NULL, 0); | 167 kMaxPathBufLen, NULL, NULL, NULL, NULL, 0); |
| 168 | 168 |
| 169 uint64 total_size_in_bytes = GetVolumeSize(mount_point); | 169 uint64 total_size_in_bytes = GetVolumeSize(mount_point); |
| 170 std::string device_id = StorageInfo::MakeDeviceId(type, UTF16ToUTF8(guid)); | 170 std::string device_id = |
| 171 StorageInfo::MakeDeviceId(type, base::UTF16ToUTF8(guid)); |
| 171 | 172 |
| 172 // TODO(gbillock): if volume_label.empty(), get the vendor/model information | 173 // TODO(gbillock): if volume_label.empty(), get the vendor/model information |
| 173 // for the volume. | 174 // for the volume. |
| 174 *info = StorageInfo(device_id, base::string16(), mount_point, | 175 *info = StorageInfo(device_id, base::string16(), mount_point, |
| 175 volume_label, base::string16(), base::string16(), | 176 volume_label, base::string16(), base::string16(), |
| 176 total_size_in_bytes); | 177 total_size_in_bytes); |
| 177 return true; | 178 return true; |
| 178 } | 179 } |
| 179 | 180 |
| 180 // Returns a vector of all the removable mass storage devices that are | 181 // Returns a vector of all the removable mass storage devices that are |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 519 } |
| 519 if (device_metadata_.erase(device) == 0) { | 520 if (device_metadata_.erase(device) == 0) { |
| 520 callback.Run(StorageMonitor::EJECT_FAILURE); | 521 callback.Run(StorageMonitor::EJECT_FAILURE); |
| 521 return; | 522 return; |
| 522 } | 523 } |
| 523 | 524 |
| 524 task_runner_->PostTask( | 525 task_runner_->PostTask( |
| 525 FROM_HERE, | 526 FROM_HERE, |
| 526 base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0)); | 527 base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0)); |
| 527 } | 528 } |
| OLD | NEW |