| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 base::win::ScopedComPtr<IPortableDeviceManager> portable_device_mgr; | 408 base::win::ScopedComPtr<IPortableDeviceManager> portable_device_mgr; |
| 409 if (!GetPortableDeviceManager(&portable_device_mgr)) | 409 if (!GetPortableDeviceManager(&portable_device_mgr)) |
| 410 return false; | 410 return false; |
| 411 | 411 |
| 412 // Get the total number of devices found on the system. | 412 // Get the total number of devices found on the system. |
| 413 DWORD pnp_device_count = 0; | 413 DWORD pnp_device_count = 0; |
| 414 HRESULT hr = portable_device_mgr->GetDevices(NULL, &pnp_device_count); | 414 HRESULT hr = portable_device_mgr->GetDevices(NULL, &pnp_device_count); |
| 415 if (FAILED(hr)) | 415 if (FAILED(hr)) |
| 416 return false; | 416 return false; |
| 417 | 417 |
| 418 scoped_ptr<base::char16*[]> pnp_device_ids( | 418 std::unique_ptr<base::char16*[]> pnp_device_ids( |
| 419 new base::char16*[pnp_device_count]); | 419 new base::char16*[pnp_device_count]); |
| 420 hr = portable_device_mgr->GetDevices(pnp_device_ids.get(), &pnp_device_count); | 420 hr = portable_device_mgr->GetDevices(pnp_device_ids.get(), &pnp_device_count); |
| 421 if (FAILED(hr)) | 421 if (FAILED(hr)) |
| 422 return false; | 422 return false; |
| 423 | 423 |
| 424 for (DWORD index = 0; index < pnp_device_count; ++index) { | 424 for (DWORD index = 0; index < pnp_device_count; ++index) { |
| 425 PortableDeviceWatcherWin::DeviceDetails device_details; | 425 PortableDeviceWatcherWin::DeviceDetails device_details; |
| 426 if (GetDeviceInfoOnBlockingThread(portable_device_mgr.get(), | 426 if (GetDeviceInfoOnBlockingThread(portable_device_mgr.get(), |
| 427 pnp_device_ids[index], &device_details)) | 427 pnp_device_ids[index], &device_details)) |
| 428 devices->push_back(device_details); | 428 devices->push_back(device_details); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 if (storage_notifications_) { | 667 if (storage_notifications_) { |
| 668 storage_notifications_->ProcessDetach( | 668 storage_notifications_->ProcessDetach( |
| 669 storage_map_iter->second.device_id()); | 669 storage_map_iter->second.device_id()); |
| 670 } | 670 } |
| 671 storage_map_.erase(storage_map_iter); | 671 storage_map_.erase(storage_map_iter); |
| 672 } | 672 } |
| 673 device_map_.erase(device_iter); | 673 device_map_.erase(device_iter); |
| 674 } | 674 } |
| 675 | 675 |
| 676 } // namespace storage_monitor | 676 } // namespace storage_monitor |
| OLD | NEW |