Chromium Code Reviews| Index: chrome/browser/media_gallery/win/mtp_device_object_enumerator.cc |
| diff --git a/chrome/browser/media_gallery/win/mtp_device_object_enumerator.cc b/chrome/browser/media_gallery/win/mtp_device_object_enumerator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e8d87f961c5af9da9c2d3ed28a397c54f836e9ab |
| --- /dev/null |
| +++ b/chrome/browser/media_gallery/win/mtp_device_object_enumerator.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +// |
| +// MTPDeviceObjectEnumerator implementation. |
| + |
| +#include "chrome/browser/media_gallery/win/mtp_device_object_enumerator.h" |
| + |
| +#include "base/threading/thread_restrictions.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +namespace chrome { |
| + |
| +MTPDeviceObjectEnumerator::MTPDeviceObjectEnumerator( |
| + const MTPDeviceObjectEntries& entries) |
| + : object_entries_(entries), |
| + object_entry_iter_(object_entries_.begin()) { |
|
Lei Zhang
2013/01/15 23:54:48
still need to initialize |current_object_|.
kmadhusu
2013/01/16 00:14:24
Done
|
| + base::ThreadRestrictions::AssertIOAllowed(); |
| +} |
| + |
| +MTPDeviceObjectEnumerator::~MTPDeviceObjectEnumerator() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| +} |
| + |
| +FilePath MTPDeviceObjectEnumerator::Next() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + if (object_entry_iter_ == object_entries_.end()) |
| + return FilePath(); |
| + |
| + current_object_ = &(*(object_entry_iter_++)); |
| + if (current_object_) |
| + return FilePath(current_object_->name); |
| + return FilePath(); |
| +} |
| + |
| +int64 MTPDeviceObjectEnumerator::Size() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + return current_object_ ? current_object_->size : 0; |
| +} |
| + |
| +bool MTPDeviceObjectEnumerator::IsDirectory() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + return current_object_ ? current_object_->is_directory : false; |
| +} |
| + |
| +base::Time MTPDeviceObjectEnumerator::LastModifiedTime() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + return current_object_ ? current_object_->last_modified_time : base::Time(); |
| +} |
| + |
| +} // namespace chrome |