This source file includes following definitions.
- is_index_ready_
- Next
- Size
- IsDirectory
- LastModifiedTime
- GetObjectId
- HasMoreEntries
- IsIndexReadyAndInRange
#include "chrome/browser/media_galleries/win/mtp_device_object_enumerator.h"
#include "base/logging.h"
#include "base/threading/thread_restrictions.h"
MTPDeviceObjectEnumerator::MTPDeviceObjectEnumerator(
const MTPDeviceObjectEntries& entries)
: object_entries_(entries),
index_(0U),
is_index_ready_(false) {
base::ThreadRestrictions::AssertIOAllowed();
}
MTPDeviceObjectEnumerator::~MTPDeviceObjectEnumerator() {
DCHECK(thread_checker_.CalledOnValidThread());
}
base::FilePath MTPDeviceObjectEnumerator::Next() {
DCHECK(thread_checker_.CalledOnValidThread());
if (IsIndexReadyAndInRange())
++index_;
else if (!is_index_ready_)
is_index_ready_ = true;
if (!HasMoreEntries())
return base::FilePath();
return base::FilePath(object_entries_[index_].name);
}
int64 MTPDeviceObjectEnumerator::Size() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!IsIndexReadyAndInRange())
return 0;
return object_entries_[index_].size;
}
bool MTPDeviceObjectEnumerator::IsDirectory() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!IsIndexReadyAndInRange())
return false;
return object_entries_[index_].is_directory;
}
base::Time MTPDeviceObjectEnumerator::LastModifiedTime() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!IsIndexReadyAndInRange())
return base::Time();
return object_entries_[index_].last_modified_time;
}
base::string16 MTPDeviceObjectEnumerator::GetObjectId() const {
DCHECK(thread_checker_.CalledOnValidThread());
if (!IsIndexReadyAndInRange())
return base::string16();
return object_entries_[index_].object_id;
}
bool MTPDeviceObjectEnumerator::HasMoreEntries() const {
return index_ < object_entries_.size();
}
bool MTPDeviceObjectEnumerator::IsIndexReadyAndInRange() const {
return is_index_ready_ && HasMoreEntries();
}