Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5508)

Unified Diff: chrome/browser/media_gallery/win/mtp_device_object_enumerator.cc

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + IWYU Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 22:35:50 You should initialize |current_object_| to NULL.
kmadhusu 2013/01/15 23:41:58 Done.
+ base::ThreadRestrictions::AssertIOAllowed();
+}
+
+MTPDeviceObjectEnumerator::~MTPDeviceObjectEnumerator() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+FilePath MTPDeviceObjectEnumerator::Next() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (object_entry_iter_ == object_entries_.end())
Lei Zhang 2013/01/15 22:35:50 If we reached the end, |current_object_| still poi
kmadhusu 2013/01/15 23:41:58 Fixed.
+ 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

Powered by Google App Engine
This is Rietveld 408576698