12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
11eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "device/media_transfer_protocol/mtp_file_entry.pb.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Used to enumerate top-level files of an media file system.
158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class MTPDeviceObjectEnumerator {
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  explicit MTPDeviceObjectEnumerator(const std::vector<MtpFileEntry>& entries);
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  ~MTPDeviceObjectEnumerator();
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  base::FilePath Next();
228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  int64 Size();
238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool IsDirectory();
248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  base::Time LastModifiedTime();
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If the current file entry is valid, returns true and fills in |entry_id|
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // with the entry identifier else returns false and |entry_id| is not set.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool GetEntryId(uint32_t* entry_id) const;
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns true if the enumerator has more entries to traverse, false
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // otherwise.
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool HasMoreEntries() const;
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns true if Next() has been called at least once, and the enumerator
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // has more entries to traverse.
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool IsIndexReadyAndInRange() const;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // List of directory file entries information.
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const std::vector<MtpFileEntry> file_entries_;
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Index into |file_entries_|.
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Should only be used when |is_index_ready_| is true.
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  size_t index_;
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Initially false. Set to true after Next() has been called.
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_index_ready_;
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(MTPDeviceObjectEnumerator);
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_OBJECT_ENUMERATOR_H_
53