OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Any tasks that communicates with the portable device may take >100ms to | 5 // Any tasks that communicates with the portable device may take >100ms to |
6 // complete. Those tasks should be run on an blocking thread instead of the | 6 // complete. Those tasks should be run on an blocking thread instead of the |
7 // UI thread. | 7 // UI thread. |
8 | 8 |
9 #include "components/storage_monitor/portable_device_watcher_win.h" | 9 #include "components/storage_monitor/portable_device_watcher_win.h" |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 // Returns true if the portable device belongs to a mass storage class. | 297 // Returns true if the portable device belongs to a mass storage class. |
298 // |pnp_device_id| specifies the plug and play device id. | 298 // |pnp_device_id| specifies the plug and play device id. |
299 // |device_name| specifies the name of the device. | 299 // |device_name| specifies the name of the device. |
300 bool IsMassStoragePortableDevice(const base::string16& pnp_device_id, | 300 bool IsMassStoragePortableDevice(const base::string16& pnp_device_id, |
301 const base::string16& device_name) { | 301 const base::string16& device_name) { |
302 // Based on testing, if the pnp device id starts with "\\?\wpdbusenumroot#", | 302 // Based on testing, if the pnp device id starts with "\\?\wpdbusenumroot#", |
303 // then the attached device belongs to a mass storage class. | 303 // then the attached device belongs to a mass storage class. |
304 if (base::StartsWith(pnp_device_id, L"\\\\?\\wpdbusenumroot#", false)) | 304 if (base::StartsWith(pnp_device_id, L"\\\\?\\wpdbusenumroot#", |
| 305 base::CompareCase::INSENSITIVE_ASCII)) |
305 return true; | 306 return true; |
306 | 307 |
307 // If the device is a volume mounted device, |device_name| will be | 308 // If the device is a volume mounted device, |device_name| will be |
308 // the volume name. | 309 // the volume name. |
309 return ((device_name.length() >= 2) && (device_name[1] == L':') && | 310 return ((device_name.length() >= 2) && (device_name[1] == L':') && |
310 (((device_name[0] >= L'A') && (device_name[0] <= L'Z')) || | 311 (((device_name[0] >= L'A') && (device_name[0] <= L'Z')) || |
311 ((device_name[0] >= L'a') && (device_name[0] <= L'z')))); | 312 ((device_name[0] >= L'a') && (device_name[0] <= L'z')))); |
312 } | 313 } |
313 | 314 |
314 // Returns the name of the device specified by |pnp_device_id|. | 315 // Returns the name of the device specified by |pnp_device_id|. |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 if (storage_notifications_) { | 668 if (storage_notifications_) { |
668 storage_notifications_->ProcessDetach( | 669 storage_notifications_->ProcessDetach( |
669 storage_map_iter->second.device_id()); | 670 storage_map_iter->second.device_id()); |
670 } | 671 } |
671 storage_map_.erase(storage_map_iter); | 672 storage_map_.erase(storage_map_iter); |
672 } | 673 } |
673 device_map_.erase(device_iter); | 674 device_map_.erase(device_iter); |
674 } | 675 } |
675 | 676 |
676 } // namespace storage_monitor | 677 } // namespace storage_monitor |
OLD | NEW |