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

Side by Side Diff: chrome/browser/system_monitor/portable_device_watcher_win.cc

Issue 11743008: Clean up: Use scoped_ptr<Foo[]> instead of scoped_array<Foo> in PortableDeviceWatcherWin::Enumerate… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comment Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 "chrome/browser/system_monitor/portable_device_watcher_win.h" 9 #include "chrome/browser/system_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_array<char16*> pnp_device_ids(new char16*[pnp_device_count]); 418 scoped_ptr<char16*[]> pnp_device_ids(new char16*[pnp_device_count]);
419 ZeroMemory(pnp_device_ids.get(), pnp_device_count);
420 hr = portable_device_mgr->GetDevices(pnp_device_ids.get(), &pnp_device_count); 419 hr = portable_device_mgr->GetDevices(pnp_device_ids.get(), &pnp_device_count);
421 if (FAILED(hr)) 420 if (FAILED(hr))
422 return false; 421 return false;
423 422
424 for (DWORD index = 0; index < pnp_device_count; ++index) { 423 for (DWORD index = 0; index < pnp_device_count; ++index) {
425 PortableDeviceWatcherWin::DeviceDetails device_details; 424 PortableDeviceWatcherWin::DeviceDetails device_details;
426 if (GetDeviceInfoOnBlockingThread( 425 if (GetDeviceInfoOnBlockingThread(
427 portable_device_mgr, pnp_device_ids[index], &device_details)) 426 portable_device_mgr, pnp_device_ids[index], &device_details))
428 devices->push_back(device_details); 427 devices->push_back(device_details);
428 CoTaskMemFree(pnp_device_ids[index]);
429 } 429 }
430 return !devices->empty(); 430 return !devices->empty();
431 } 431 }
432 432
433 // Handles the device attach event message on a media task runner. 433 // Handles the device attach event message on a media task runner.
434 // |pnp_device_id| specifies the attached plug and play device ID string. On 434 // |pnp_device_id| specifies the attached plug and play device ID string. On
435 // success, returns true and populates |device_details| with device information. 435 // success, returns true and populates |device_details| with device information.
436 // On failure, returns false. 436 // On failure, returns false.
437 bool HandleDeviceAttachedEventOnBlockingThread( 437 bool HandleDeviceAttachedEventOnBlockingThread(
438 const string16& pnp_device_id, 438 const string16& pnp_device_id,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id); 609 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id);
610 DCHECK(storage_map_iter != storage_map_.end()); 610 DCHECK(storage_map_iter != storage_map_.end());
611 system_monitor->ProcessRemovableStorageDetached( 611 system_monitor->ProcessRemovableStorageDetached(
612 storage_map_iter->second.device_id); 612 storage_map_iter->second.device_id);
613 storage_map_.erase(storage_map_iter); 613 storage_map_.erase(storage_map_iter);
614 } 614 }
615 device_map_.erase(device_iter); 615 device_map_.erase(device_iter);
616 } 616 }
617 617
618 } // namespace chrome 618 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698