| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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 // MTPDeviceObjectEnumerator implementation. |
| 6 |
| 7 #include "chrome/browser/media_gallery/win/mtp_device_object_enumerator.h" |
| 8 |
| 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "content/public/browser/browser_thread.h" |
| 11 |
| 12 namespace chrome { |
| 13 |
| 14 MTPDeviceObjectEnumerator::MTPDeviceObjectEnumerator( |
| 15 const MTPDeviceObjectEntries& entries) |
| 16 : object_entries_(entries), |
| 17 object_entry_iter_(object_entries_.begin()), |
| 18 current_object_(NULL) { |
| 19 base::ThreadRestrictions::AssertIOAllowed(); |
| 20 } |
| 21 |
| 22 MTPDeviceObjectEnumerator::~MTPDeviceObjectEnumerator() { |
| 23 DCHECK(thread_checker_.CalledOnValidThread()); |
| 24 } |
| 25 |
| 26 FilePath MTPDeviceObjectEnumerator::Next() { |
| 27 DCHECK(thread_checker_.CalledOnValidThread()); |
| 28 if (object_entry_iter_ == object_entries_.end()) { |
| 29 current_object_ = NULL; |
| 30 return FilePath(); |
| 31 } |
| 32 |
| 33 current_object_ = &(*(object_entry_iter_++)); |
| 34 return FilePath(current_object_->name); |
| 35 } |
| 36 |
| 37 int64 MTPDeviceObjectEnumerator::Size() { |
| 38 DCHECK(thread_checker_.CalledOnValidThread()); |
| 39 return current_object_ ? current_object_->size : 0; |
| 40 } |
| 41 |
| 42 bool MTPDeviceObjectEnumerator::IsDirectory() { |
| 43 DCHECK(thread_checker_.CalledOnValidThread()); |
| 44 return current_object_ ? current_object_->is_directory : false; |
| 45 } |
| 46 |
| 47 base::Time MTPDeviceObjectEnumerator::LastModifiedTime() { |
| 48 DCHECK(thread_checker_.CalledOnValidThread()); |
| 49 return current_object_ ? current_object_->last_modified_time : base::Time(); |
| 50 } |
| 51 |
| 52 } // namespace chrome |
| OLD | NEW |