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_LINUX_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATO
R_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERY_LINUX_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATO
R_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/time.h" |
| 14 #include "chrome/browser/media_transfer_protocol/mtp_file_entry.pb.h" |
| 15 #include "webkit/fileapi/file_system_file_util.h" |
| 16 |
| 17 namespace base { |
| 18 class SequencedTaskRunner; |
| 19 class WaitableEvent; |
| 20 } |
| 21 |
| 22 namespace chrome { |
| 23 |
| 24 // Recursively enumerate each file entry from a given media file entry set. |
| 25 class RecursiveMTPDeviceObjectEnumerator |
| 26 : public fileapi::FileSystemFileUtil::AbstractFileEnumerator { |
| 27 public: |
| 28 RecursiveMTPDeviceObjectEnumerator(const std::string& handle, |
| 29 base::SequencedTaskRunner* task_runner, |
| 30 const std::vector<MtpFileEntry>& entries, |
| 31 base::WaitableEvent* task_completed_event, |
| 32 base::WaitableEvent* shutdown_event); |
| 33 |
| 34 virtual ~RecursiveMTPDeviceObjectEnumerator(); |
| 35 |
| 36 // AbstractFileEnumerator: |
| 37 virtual FilePath Next() OVERRIDE; |
| 38 virtual int64 Size() OVERRIDE; |
| 39 virtual bool IsDirectory() OVERRIDE; |
| 40 virtual base::Time LastModifiedTime() OVERRIDE; |
| 41 |
| 42 private: |
| 43 // Stores the device handle that was used to open the device. |
| 44 const std::string device_handle_; |
| 45 |
| 46 // Stores a reference to |media_task_runner_| to construct and destruct |
| 47 // ReadMTPDirectoryWorker object on the correct thread. |
| 48 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; |
| 49 |
| 50 // List of top-level directory file entries. |
| 51 const std::vector<MtpFileEntry> file_entries_; |
| 52 |
| 53 // Iterator to access the individual file entries. |
| 54 std::vector<MtpFileEntry>::const_iterator file_entry_iter_; |
| 55 |
| 56 // Enumerator to access current directory Id/path entries. |
| 57 scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> |
| 58 current_enumerator_; |
| 59 |
| 60 // |media_task_runner_| can wait on this event until the requested operation |
| 61 // is complete. |
| 62 base::WaitableEvent* on_task_completed_event_; |
| 63 |
| 64 // Stores a reference to waitable event associated with the shut down message. |
| 65 base::WaitableEvent* on_shutdown_event_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(RecursiveMTPDeviceObjectEnumerator); |
| 68 }; |
| 69 |
| 70 } // namespace chrome |
| 71 |
| 72 #endif // CHROME_BROWSER_MEDIA_GALLERY_LINUX_RECURSIVE_MTP_DEVICE_OBJECT_ENUMER
ATOR_H_ |
OLD | NEW |