| 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_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/files/file_path.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/time/time.h" | |
| 16 #include "device/media_transfer_protocol/mtp_file_entry.pb.h" | |
| 17 | |
| 18 // Used to enumerate top-level files of an media file system. | |
| 19 class MTPDeviceObjectEnumerator { | |
| 20 public: | |
| 21 explicit MTPDeviceObjectEnumerator(const std::vector<MtpFileEntry>& entries); | |
| 22 | |
| 23 ~MTPDeviceObjectEnumerator(); | |
| 24 | |
| 25 base::FilePath Next(); | |
| 26 int64_t Size(); | |
| 27 bool IsDirectory(); | |
| 28 base::Time LastModifiedTime(); | |
| 29 | |
| 30 // If the current file entry is valid, returns true and fills in |entry_id| | |
| 31 // with the entry identifier else returns false and |entry_id| is not set. | |
| 32 bool GetEntryId(uint32_t* entry_id) const; | |
| 33 | |
| 34 private: | |
| 35 // Returns true if the enumerator has more entries to traverse, false | |
| 36 // otherwise. | |
| 37 bool HasMoreEntries() const; | |
| 38 | |
| 39 // Returns true if Next() has been called at least once, and the enumerator | |
| 40 // has more entries to traverse. | |
| 41 bool IsIndexReadyAndInRange() const; | |
| 42 | |
| 43 // List of directory file entries information. | |
| 44 const std::vector<MtpFileEntry> file_entries_; | |
| 45 | |
| 46 // Index into |file_entries_|. | |
| 47 // Should only be used when |is_index_ready_| is true. | |
| 48 size_t index_; | |
| 49 | |
| 50 // Initially false. Set to true after Next() has been called. | |
| 51 bool is_index_ready_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(MTPDeviceObjectEnumerator); | |
| 54 }; | |
| 55 | |
| 56 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_ | |
| OLD | NEW |