thestig@: Addressed review comments. PTAL.
Thanks.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.cc
File chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.cc
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.cc#newcode135
chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.cc:135: if
(root.value().empty() || !LazyInit())
On 2013/01/14 23:25:30, Lei Zhang wrote:
> nit: root.empty()
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.cc#newcode170
chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.cc:170:
base::PlatformFileError error = GetFileInfo(device_file_path,
file_info);
On 2013/01/14 23:25:30, Lei Zhang wrote:
> You should do this before writing the file to disk. Otherwise you can
fail, but
> wrote a file to disk.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h
File chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h#newcode46
chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h:46: //
Defer the device initializations until the first file operation request.
On 2013/01/14 23:25:30, Lei Zhang wrote:
> nit: Defers
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h#newcode81
chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h:81: //
The Pnp Device Id, used to open the device for communication,
On 2013/01/14 23:25:30, Lei Zhang wrote:
> nit: plug & play abbreviates to PnP.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_object_entry.h
File chrome/browser/media_gallery/win/mtp_device_object_entry.h (right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_object_entry.h#newcode16
chrome/browser/media_gallery/win/mtp_device_object_entry.h:16: //
MTPDeviceObjectEntry contains information about the media transfer
protocol
On 2013/01/14 20:49:02, Lei Zhang wrote:
> This comment is not helpful. It just says foo contains info about foo.
It might
> be more helpful to know what Windows data structure this is capturing
> information from.
Rephrased the comment to include details about the interface that is
used to retrieve the object property values. MSDN documentation only
provides details about the interface that is used to retrieve the values
and do not specify any data structure name.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_object_entry.h#newcode26
chrome/browser/media_gallery/win/mtp_device_object_entry.h:26: // The
object identifier, e.g. "o299".
On 2013/01/14 20:49:02, Lei Zhang wrote:
> Where does this ID come from?
ID is obtained from IEnumPortableDeviceObjectIDs interface.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_object_entry.h#newcode29
chrome/browser/media_gallery/win/mtp_device_object_entry.h:29: //
Friendly name of the object, e.g. "IMG_9911.jpeg".
On 2013/01/14 20:49:02, Lei Zhang wrote:
> Is this always just the file name or the full path?
This field always store the file name.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_object_enumerator.h
File chrome/browser/media_gallery/win/mtp_device_object_enumerator.h
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_object_enumerator.h#newcode43
chrome/browser/media_gallery/win/mtp_device_object_enumerator.h:43:
MTPDeviceObjectEntry current_object_;
On 2013/01/14 23:25:30, Lei Zhang wrote:
> const ref
This field changes in .cc line 30. Changed to a pointer field.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc
File chrome/browser/media_gallery/win/mtp_device_operations_util.cc
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode66
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:66: bool
GetDeviceObjectEnumerator(IPortableDevice* device,
On 2013/01/14 23:25:30, Lei Zhang wrote:
> This can also just return an IEnumPortableDeviceObjectIDs* instead of
using a
> bool + out param.
Done and also fixed GetDeviceContent.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode90
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:90:
DCHECK_GT(optimal_transfer_size, 0u);
On 2013/01/14 23:25:30, Lei Zhang wrote:
> I don't see any guarantee from IPortableDeviceResources::GetStream
that this
> will be true.
If the optimal_transfer_size is equal to 0, this function will now
return false.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode92
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:92: DWORD
read = 0;
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Doesn't IStream::Read return a ULONG? Is a ULONG always equal in size
to a
> DWORD?
As per
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx,
both DWORD and ULONG are the same.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode106
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:106:
buffer.erase(read);
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Can't you avoid manipulating the buffer, and instead just write
std::min(read,
> buffer.length()) to file?
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode113
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:113: }
while ((read > 0) && SUCCEEDED(hr));
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Why do you need the SUCCEEDED() part? You've already checked the value
of |hr|
> at line 103. SUCCEEDED(hr) is always true here.
If |hr| is S_FALSE, SUCCEEDED(hr) will be false. Please refer to comment
at line 98 for more details.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode126
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:126:
return ((content_type == WPD_CONTENT_TYPE_AUDIO_ALBUM) ||
On 2013/01/14 23:25:30, Lei Zhang wrote:
> I'm not sure albums (aka playlists??) are directories. Have you tested
this with
> an audio or video album?
As per
http://msdn.microsoft.com/en-us/library/windows/desktop/dd389020(v=vs.85).aspx,
albums contains actual objects. Albums and playlists are equivalent but
albums stores the actual objects instead of a virtual object or
reference to the some object metadata. If the object is a playlist, it
will describe its content type as WPD_CONTENT_TYPE_PLAYLIST. I tested
with an IMAGE_ALBUM object.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode283
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:283: bool
get_all_entries,
On 2013/01/14 23:25:30, Lei Zhang wrote:
> You can just indicate this with a non empty |object_name| instead.
This is more clearer than the suggested solution.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode296
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:296:
DWORD num_objects_to_request = 10;
On 2013/01/14 23:25:30, Lei Zhang wrote:
> const?
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode297
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:297: for
(HRESULT hr = S_OK; hr == S_OK;) {
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Isn't this just do { } while (hr == S_OK)
Yes. Leaving it as it is.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode378
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:378:
DCHECK(!local_path.value().empty());
On 2013/01/14 23:25:30, Lei Zhang wrote:
> !local_path.empty() ?
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.cc#newcode407
chrome/browser/media_gallery/win/mtp_device_operations_util.cc:407:
DCHECK_EQ(1U, object_entries.size());
On 2013/01/14 23:25:30, Lei Zhang wrote:
> FWIW, this DCHECK can fail. In MTP, it is perfectly legal to have
object A with
> id 1 and object B with id 2, and both objects can have the same parent
id and
> can have the same friendly name. Though this case is probably rare. I
don't
> think the Linux MTP code handles this situation gracefully either. You
can put a
> TODO in here with my name and
http://crbug.com/169930.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.h
File chrome/browser/media_gallery/win/mtp_device_operations_util.h
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.h#newcode31
chrome/browser/media_gallery/win/mtp_device_operations_util.h:31:
base::win::ScopedComPtr<IPortableDevice>* device);
On 2013/01/14 23:25:30, Lei Zhang wrote:
> You can return a NULL ScopedComPtr right? If so, there's no need to
have
> |device| as an out param. Just return NULL to indicate failure.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.h#newcode53
chrome/browser/media_gallery/win/mtp_device_operations_util.h:53: bool
WriteFileObjectData(IPortableDevice* device,
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Can you rename this to WriteFileObjectContentToPath ?
"WriteFileObjectData"
> sounds like it is trying to save data into a file object.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/mtp_device_operations_util.h#newcode57
chrome/browser/media_gallery/win/mtp_device_operations_util.h:57: //
Returns the identifier of the object specified by the |object_name|.
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Is |object_name| the friendly name?
Yes.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.cc
File
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.cc
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.cc#newcode39
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.cc:39:
MTPDeviceObjectEntry current_object_entry = *(object_entry_iter_++);
On 2013/01/14 23:25:30, Lei Zhang wrote:
> const ref
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h
File
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h#newcode8
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h:8:
#include <portabledeviceapi.h>
On 2013/01/14 23:25:30, Lei Zhang wrote:
> nit: empty line between C and C++ headers. Here and elsewhere.
I had an empty line before. Reviewers asked me to remove the extra line.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h#newcode26
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h:26:
// object entries set. RecursiveMTPDeviceObjectEnumerator communicates
with the
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Doesn't it go through MTPDeviceObjectEnumerator?
RecursiveMTPDeviceObjectEnumerator communicates with the device to get
the subdirectory object entries. RecursiveMTPDeviceObjectEnumerator uses
MTPDeviceObjectEnumerator to iterate the current directory objects.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h#newcode28
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h:28:
// RecursiveMTPDeviceObjectEnumerator supports media file system
operations.
On 2013/01/14 23:25:30, Lei Zhang wrote:
> What does this mean exactly? Are you trying to say it implements
> AbstractFileEnumerator?
RecursiveMTPDeviceObjectEnumerator is used to complete the DOMFileSystem
operation, e.g DirectoryEntry.removeRecursively interface. In our case,
it is a media gallery file system operation.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h#newcode30
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h:30:
// device is already opened for communication.
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Are you trying to say the |device| passed into the ctor should already
be
> initialized and ready for communication? Shouldn't this statement be
in the ctor
> comment?
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h#newcode52
chrome/browser/media_gallery/win/recursive_mtp_device_object_enumerator.h:52:
// List of current directory object entries.
On 2013/01/14 23:25:30, Lei Zhang wrote:
> Can you add a TODO to remove |curr_object_entries_| and
|object_entry_iter_| ?
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/portable_device_watcher_win.cc
File chrome/browser/system_monitor/portable_device_watcher_win.cc
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/portable_device_watcher_win.cc#newcode531
chrome/browser/system_monitor/portable_device_watcher_win.cc:531:
*device_location = storage_map_iter->second.location;
On 2013/01/14 23:25:30, Lei Zhang wrote:
> If you delay assigning to |device_location| until line 540, then you
can avoid
> returning any info in the out params if you return false.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/portable_device_watcher_win.cc#newcode541
chrome/browser/system_monitor/portable_device_watcher_win.cc:541: break;
On 2013/01/14 20:49:02, Lei Zhang wrote:
> You can just return true here and return false at line 544.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/removable_device_notifications_window_win_unittest.cc
File
chrome/browser/system_monitor/removable_device_notifications_window_win_unittest.cc
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/removable_device_notifications_window_win_unittest.cc#newcode665
chrome/browser/system_monitor/removable_device_notifications_window_win_unittest.cc:665:
TEST_F(RemovableDeviceNotificationsWindowWinTest, GetMTPStorageInfo) {
On 2013/01/14 20:49:02, Lei Zhang wrote:
> nit: isn't this really testing GetMTPStorageInfoFromDeviceId ?
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/removable_storage_notifications.h
File chrome/browser/system_monitor/removable_storage_notifications.h
(right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/chrome/browser/system_monitor/removable_storage_notifications.h#newcode37
chrome/browser/system_monitor/removable_storage_notifications.h:37: //
interface details and |storage_object_id| with storage object temporary
On 2013/01/14 20:49:02, Lei Zhang wrote:
> Both here and in portable_device_watcher_win.h, you use the term
"storage object
> temporary identifier". At some level, you should define what a
"storage object
> temporary identifier" is, because it's not a well known term.
Done.
https://chromiumcodereview.appspot.com/11297002/diff/178004/webkit/fileapi/media/mtp_device_file_system_config.h
File webkit/fileapi/media/mtp_device_file_system_config.h (right):
https://chromiumcodereview.appspot.com/11297002/diff/178004/webkit/fileapi/media/mtp_device_file_system_config.h#newcode11
webkit/fileapi/media/mtp_device_file_system_config.h:11: // OS_CHROMEOS
implies OS_LINUX.
On 2013/01/14 20:49:02, Lei Zhang wrote:
> This comment has the defined values flipped around.
Fixed.
https://chromiumcodereview.appspot.com/11297002/