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

Side by Side Diff: components/storage_monitor/portable_device_watcher_win.cc

Issue 1884743002: Convert a few components from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 4 years, 8 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
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698