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