| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATOR_
H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATOR_
H_ |
| 7 |
| 8 #include <portabledeviceapi.h> |
| 9 #include <queue> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" |
| 14 #include "base/threading/thread_checker.h" |
| 15 #include "base/time.h" |
| 16 #include "base/win/scoped_comptr.h" |
| 17 #include "chrome/browser/media_gallery/win/mtp_device_object_entry.h" |
| 18 #include "webkit/fileapi/file_system_file_util.h" |
| 19 |
| 20 class FilePath; |
| 21 |
| 22 namespace chrome { |
| 23 |
| 24 // RecursiveMTPDeviceObjectEnumerator is used to recursively enumerate the |
| 25 // media transfer protocol (MTP) device storage objects from a given media file |
| 26 // object entries set. RecursiveMTPDeviceObjectEnumerator communicates with the |
| 27 // MTP device to get the removable storage objects details. |
| 28 // RecursiveMTPDeviceObjectEnumerator supports media file system operations. |
| 29 // RecursiveMTPDeviceObjectEnumerator may only be used on a single thread. |
| 30 class RecursiveMTPDeviceObjectEnumerator |
| 31 : public fileapi::FileSystemFileUtil::AbstractFileEnumerator { |
| 32 public: |
| 33 // MTP |device| should already be initialized and ready for communication. |
| 34 RecursiveMTPDeviceObjectEnumerator(IPortableDevice* device, |
| 35 const MTPDeviceObjectEntries& entries); |
| 36 virtual ~RecursiveMTPDeviceObjectEnumerator(); |
| 37 |
| 38 // AbstractFileEnumerator: |
| 39 virtual FilePath Next() OVERRIDE; |
| 40 virtual int64 Size() OVERRIDE; |
| 41 virtual bool IsDirectory() OVERRIDE; |
| 42 virtual base::Time LastModifiedTime() OVERRIDE; |
| 43 |
| 44 private: |
| 45 typedef string16 DirectoryObjectId; |
| 46 |
| 47 void MaybeUpdateCurrentObjectList(); |
| 48 |
| 49 // The portable device. |
| 50 base::win::ScopedComPtr<IPortableDevice> device_; |
| 51 |
| 52 // TODO(kmadhusu): Remove |curr_object_entries_| and |object_entry_iter_|. |
| 53 // Implement GetObjectId() and HasMoreEntries() in MTPDeviceObjectEnumerator |
| 54 // and remove |curr_object_entries_| and |object_entry_iter_|. |
| 55 |
| 56 // List of current directory object entries. |
| 57 MTPDeviceObjectEntries curr_object_entries_; |
| 58 |
| 59 // Iterator to access the individual file object entries. |
| 60 MTPDeviceObjectEntries::const_iterator object_entry_iter_; |
| 61 |
| 62 // Enumerator to access current directory object entries. |
| 63 scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> |
| 64 current_enumerator_; |
| 65 |
| 66 // Used to recursively enumerate the sub-directory objects. |
| 67 std::queue<DirectoryObjectId> unparsed_directory_object_ids_; |
| 68 |
| 69 base::ThreadChecker thread_checker_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(RecursiveMTPDeviceObjectEnumerator); |
| 72 }; |
| 73 |
| 74 } // namespace chrome |
| 75 |
| 76 #endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERAT
OR_H_ |
| OLD | NEW |