Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / media_galleries / linux / mtp_device_object_enumerator.h
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 <vector>
9
10 #include "base/files/file_path.h"
11 #include "base/time/time.h"
12 #include "device/media_transfer_protocol/mtp_file_entry.pb.h"
13
14 // Used to enumerate top-level files of an media file system.
15 class MTPDeviceObjectEnumerator {
16  public:
17   explicit MTPDeviceObjectEnumerator(const std::vector<MtpFileEntry>& entries);
18
19   ~MTPDeviceObjectEnumerator();
20
21   base::FilePath Next();
22   int64 Size();
23   bool IsDirectory();
24   base::Time LastModifiedTime();
25
26   // 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.
28   bool GetEntryId(uint32* entry_id) const;
29
30  private:
31   // Returns true if the enumerator has more entries to traverse, false
32   // otherwise.
33   bool HasMoreEntries() const;
34
35   // Returns true if Next() has been called at least once, and the enumerator
36   // has more entries to traverse.
37   bool IsIndexReadyAndInRange() const;
38
39   // List of directory file entries information.
40   const std::vector<MtpFileEntry> file_entries_;
41
42   // Index into |file_entries_|.
43   // Should only be used when |is_index_ready_| is true.
44   size_t index_;
45
46   // Initially false. Set to true after Next() has been called.
47   bool is_index_ready_;
48
49   DISALLOW_COPY_AND_ASSIGN(MTPDeviceObjectEnumerator);
50 };
51
52 #endif  // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_