chrome/browser/system_monitor/portable_device_watcher_win.cc
// Constructs a unique identifier for the object specified by the |object_id|.
// On success, returns true and fills in |unique_id|.
Constructs a unique identifier for the object specified by the |object_id|.
On success, returns true and fills in |unique_id|.
Constructs a unique identifier for the object specified by the |object_id| . On success returns true and fills in |unique_id| .
bool GetObjectUniqueId(IPortableDevice* device,
                       const string16& object_id,
                       string16* unique_id) {
  DCHECK(device);
  DCHECK(unique_id);
  base::win::ScopedComPtr<IPortableDeviceContent> content;
  HRESULT hr = device->Content(content.Receive());
  if (FAILED(hr)) {
    DPLOG(ERROR) << "Failed to get IPortableDeviceContent interface";
    return false;
  }
  base::win::ScopedComPtr<IPortableDeviceProperties> properties;
  hr = content->Properties(properties.Receive());
  if (FAILED(hr)) {
    DPLOG(ERROR) << "Failed to get IPortableDeviceProperties interface";
    return false;
  }
  base::win::ScopedComPtr<IPortableDeviceKeyCollection> properties_to_read;
  if (!PopulatePropertyKeyCollection(object_id, &properties_to_read))
    return false;
  base::win::ScopedComPtr<IPortableDeviceValues> properties_values;
  if (FAILED(properties->GetValues(object_id.c_str(),
                                   properties_to_read.get(),
                                   properties_values.Receive()))) {
    return false;
  }
  REFPROPERTYKEY key = GetUniqueIdPropertyKey(object_id);
  return GetStringPropertyValue(properties_values.get(), key, unique_id);
}
bool GetObjectUniqueId ( IPortableDevice * device , const string16 & object_id , string16 * unique_id ) { DCHECK ( device ) ; DCHECK ( unique_id ) ; base :: win :: ScopedComPtr < IPortableDeviceContent > content ; HRESULT hr = device -> Content ( content . Receive ( ) ) ; if ( FAILED ( hr ) ) { DPLOG ( ERROR ) << " " ; return false ; } base :: win :: ScopedComPtr < IPortableDeviceProperties > properties ; hr = content -> Properties ( properties . Receive ( ) ) ; if ( FAILED ( hr ) ) { DPLOG ( ERROR ) << " " ; return false ; } base :: win :: ScopedComPtr < IPortableDeviceKeyCollection > properties_to_read ; if ( ! PopulatePropertyKeyCollection ( object_id , & properties_to_read ) ) return false ; base :: win :: ScopedComPtr < IPortableDeviceValues > properties_values ; if ( FAILED ( properties -> GetValues ( object_id . c_str ( ) , properties_to_read . get ( ) , properties_values . Receive ( ) ) ) ) { return false ; } REFPROPERTYKEY key = GetUniqueIdPropertyKey ( object_id ) ; return GetStringPropertyValue ( properties_values . get ( ) , key , unique_id ) ; }
Constructs a unique identifier for the object specified by the |object_id|.
Constructs a unique identifier for the object specified by the |object_id| .