diff options
Diffstat (limited to 'chromium/components/storage_monitor/portable_device_watcher_win.cc')
-rw-r--r-- | chromium/components/storage_monitor/portable_device_watcher_win.cc | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/chromium/components/storage_monitor/portable_device_watcher_win.cc b/chromium/components/storage_monitor/portable_device_watcher_win.cc index 1fa2e2320f5..62a08a0c39a 100644 --- a/chromium/components/storage_monitor/portable_device_watcher_win.cc +++ b/chromium/components/storage_monitor/portable_device_watcher_win.cc @@ -9,6 +9,7 @@ #include "components/storage_monitor/portable_device_watcher_win.h" #include <dbt.h> +#include <objbase.h> #include <portabledevice.h> #include "base/files/file_path.h" @@ -20,7 +21,6 @@ #include "base/win/scoped_co_mem.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_propvariant.h" -#include "components/storage_monitor/media_storage_util.h" #include "components/storage_monitor/removable_device_constants.h" #include "components/storage_monitor/storage_info.h" #include "content/public/browser/browser_thread.h" @@ -123,8 +123,9 @@ bool GetDeviceDescription(const base::string16& pnp_device_id, // application that communicates with the device. bool GetClientInformation( base::win::ScopedComPtr<IPortableDeviceValues>* client_info) { - HRESULT hr = client_info->CreateInstance(__uuidof(PortableDeviceValues), - NULL, CLSCTX_INPROC_SERVER); + HRESULT hr = ::CoCreateInstance(__uuidof(PortableDeviceValues), NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(client_info->GetAddressOf())); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to create an instance of IPortableDeviceValues"; return false; @@ -151,14 +152,15 @@ bool SetUp(const base::string16& pnp_device_id, if (!GetClientInformation(&client_info)) return false; - HRESULT hr = device->CreateInstance(__uuidof(PortableDevice), NULL, - CLSCTX_INPROC_SERVER); + HRESULT hr = + ::CoCreateInstance(__uuidof(PortableDevice), NULL, CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(device->GetAddressOf())); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to create an instance of IPortableDevice"; return false; } - hr = (*device)->Open(pnp_device_id.c_str(), client_info.get()); + hr = (*device)->Open(pnp_device_id.c_str(), client_info.Get()); if (SUCCEEDED(hr)) return true; @@ -179,8 +181,9 @@ REFPROPERTYKEY GetUniqueIdPropertyKey(const base::string16& object_id) { bool PopulatePropertyKeyCollection( const base::string16& object_id, base::win::ScopedComPtr<IPortableDeviceKeyCollection>* properties_to_read) { - HRESULT hr = properties_to_read->CreateInstance( - __uuidof(PortableDeviceKeyCollection), NULL, CLSCTX_INPROC_SERVER); + HRESULT hr = ::CoCreateInstance( + __uuidof(PortableDeviceKeyCollection), NULL, CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(properties_to_read->GetAddressOf())); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to create IPortableDeviceKeyCollection instance"; return false; @@ -212,14 +215,14 @@ bool GetObjectUniqueId(IPortableDevice* device, DCHECK(device); DCHECK(unique_id); base::win::ScopedComPtr<IPortableDeviceContent> content; - HRESULT hr = device->Content(content.Receive()); + HRESULT hr = device->Content(content.GetAddressOf()); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to get IPortableDeviceContent interface"; return false; } base::win::ScopedComPtr<IPortableDeviceProperties> properties; - hr = content->Properties(properties.Receive()); + hr = content->Properties(properties.GetAddressOf()); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to get IPortableDeviceProperties interface"; return false; @@ -230,14 +233,13 @@ bool GetObjectUniqueId(IPortableDevice* device, return false; base::win::ScopedComPtr<IPortableDeviceValues> properties_values; - if (FAILED(properties->GetValues(object_id.c_str(), - properties_to_read.get(), - properties_values.Receive()))) { + if (FAILED(properties->GetValues(object_id.c_str(), properties_to_read.Get(), + properties_values.GetAddressOf()))) { return false; } REFPROPERTYKEY key = GetUniqueIdPropertyKey(object_id); - return GetStringPropertyValue(properties_values.get(), key, unique_id); + return GetStringPropertyValue(properties_values.Get(), key, unique_id); } // Constructs the device storage unique identifier using |device_serial_num| and @@ -263,7 +265,7 @@ bool GetRemovableStorageObjectIds( DCHECK(device); DCHECK(storage_object_ids); base::win::ScopedComPtr<IPortableDeviceCapabilities> capabilities; - HRESULT hr = device->Capabilities(capabilities.Receive()); + HRESULT hr = device->Capabilities(capabilities.GetAddressOf()); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to get IPortableDeviceCapabilities interface"; return false; @@ -271,7 +273,7 @@ bool GetRemovableStorageObjectIds( base::win::ScopedComPtr<IPortableDevicePropVariantCollection> storage_ids; hr = capabilities->GetFunctionalObjects(WPD_FUNCTIONAL_CATEGORY_STORAGE, - storage_ids.Receive()); + storage_ids.GetAddressOf()); if (FAILED(hr)) { DPLOG(ERROR) << "Failed to get IPortableDevicePropVariantCollection"; return false; @@ -336,18 +338,18 @@ bool GetDeviceStorageObjectsOnBlockingThread( return false; base::string16 device_serial_num; - if (!GetObjectUniqueId(device.get(), WPD_DEVICE_OBJECT_ID, + if (!GetObjectUniqueId(device.Get(), WPD_DEVICE_OBJECT_ID, &device_serial_num)) { return false; } PortableDeviceWatcherWin::StorageObjectIDs storage_obj_ids; - if (!GetRemovableStorageObjectIds(device.get(), &storage_obj_ids)) + if (!GetRemovableStorageObjectIds(device.Get(), &storage_obj_ids)) return false; for (PortableDeviceWatcherWin::StorageObjectIDs::const_iterator id_iter = storage_obj_ids.begin(); id_iter != storage_obj_ids.end(); ++id_iter) { base::string16 storage_persistent_id; - if (!GetObjectUniqueId(device.get(), *id_iter, &storage_persistent_id)) + if (!GetObjectUniqueId(device.Get(), *id_iter, &storage_persistent_id)) continue; std::string device_storage_id; @@ -387,8 +389,9 @@ bool GetDeviceInfoOnBlockingThread( bool GetPortableDeviceManager( base::win::ScopedComPtr<IPortableDeviceManager>* portable_device_mgr) { DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); - HRESULT hr = portable_device_mgr->CreateInstance( - __uuidof(PortableDeviceManager), NULL, CLSCTX_INPROC_SERVER); + HRESULT hr = ::CoCreateInstance( + __uuidof(PortableDeviceManager), NULL, CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(portable_device_mgr->GetAddressOf())); if (SUCCEEDED(hr)) return true; @@ -423,7 +426,7 @@ bool EnumerateAttachedDevicesOnBlockingThread( for (DWORD index = 0; index < pnp_device_count; ++index) { PortableDeviceWatcherWin::DeviceDetails device_details; - if (GetDeviceInfoOnBlockingThread(portable_device_mgr.get(), + if (GetDeviceInfoOnBlockingThread(portable_device_mgr.Get(), pnp_device_ids[index], &device_details)) devices->push_back(device_details); CoTaskMemFree(pnp_device_ids[index]); @@ -446,7 +449,7 @@ bool HandleDeviceAttachedEventOnBlockingThread( // Sometimes, portable device manager doesn't have the new device details. // Refresh the manager device list to update its details. portable_device_mgr->RefreshDeviceList(); - return GetDeviceInfoOnBlockingThread(portable_device_mgr.get(), pnp_device_id, + return GetDeviceInfoOnBlockingThread(portable_device_mgr.Get(), pnp_device_id, device_details); } @@ -632,9 +635,6 @@ void PortableDeviceWatcherWin::OnDidHandleDeviceAttachEvent( const std::string& storage_id = storage_iter->object_persistent_id; DCHECK(!base::ContainsKey(storage_map_, storage_id)); - // Keep track of storage id and storage name to see how often we receive - // empty values. - MediaStorageUtil::RecordDeviceInfoHistogram(false, storage_id, name); if (storage_id.empty() || name.empty()) return; |