| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // MTPDeviceObjectEnumerator implementation. | 5 // MTPDeviceObjectEnumerator implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/media_galleries/win/mtp_device_object_enumerator.h" | 7 #include "chrome/browser/media_galleries/win/mtp_device_object_enumerator.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 if (IsIndexReadyAndInRange()) | 26 if (IsIndexReadyAndInRange()) |
| 27 ++index_; // Normal traversal. | 27 ++index_; // Normal traversal. |
| 28 else if (!is_index_ready_) | 28 else if (!is_index_ready_) |
| 29 is_index_ready_ = true; // First time calling Next(). | 29 is_index_ready_ = true; // First time calling Next(). |
| 30 | 30 |
| 31 if (!HasMoreEntries()) | 31 if (!HasMoreEntries()) |
| 32 return base::FilePath(); | 32 return base::FilePath(); |
| 33 return base::FilePath(object_entries_[index_].name); | 33 return base::FilePath(object_entries_[index_].name); |
| 34 } | 34 } |
| 35 | 35 |
| 36 int64 MTPDeviceObjectEnumerator::Size() { | 36 int64_t MTPDeviceObjectEnumerator::Size() { |
| 37 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 38 if (!IsIndexReadyAndInRange()) | 38 if (!IsIndexReadyAndInRange()) |
| 39 return 0; | 39 return 0; |
| 40 return object_entries_[index_].size; | 40 return object_entries_[index_].size; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool MTPDeviceObjectEnumerator::IsDirectory() { | 43 bool MTPDeviceObjectEnumerator::IsDirectory() { |
| 44 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
| 45 if (!IsIndexReadyAndInRange()) | 45 if (!IsIndexReadyAndInRange()) |
| 46 return false; | 46 return false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 return object_entries_[index_].object_id; | 61 return object_entries_[index_].object_id; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool MTPDeviceObjectEnumerator::HasMoreEntries() const { | 64 bool MTPDeviceObjectEnumerator::HasMoreEntries() const { |
| 65 return index_ < object_entries_.size(); | 65 return index_ < object_entries_.size(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool MTPDeviceObjectEnumerator::IsIndexReadyAndInRange() const { | 68 bool MTPDeviceObjectEnumerator::IsIndexReadyAndInRange() const { |
| 69 return is_index_ready_ && HasMoreEntries(); | 69 return is_index_ready_ && HasMoreEntries(); |
| 70 } | 70 } |
| OLD | NEW |