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

Unified Diff: chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc

Issue 246913003: [fsp] Add support for reading directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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/chromeos/file_system_provider/fake_provided_file_system.cc
diff --git a/chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc b/chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc
index 8e54dd05d96b22eab5de8cd248f98179b3fa1f4f..f27aeb01fb4ad1f32c00f6802c0a272a72cf68fd 100644
--- a/chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc
+++ b/chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc
@@ -4,12 +4,31 @@
#include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system.h"
+#include <string>
+
#include "base/files/file.h"
#include "base/message_loop/message_loop_proxy.h"
#include "extensions/browser/event_router.h"
namespace chromeos {
namespace file_system_provider {
+namespace {
+
+// Adds a fake entry to the entry list.
+void AddDirectoryEntry(fileapi::AsyncFileUtil::EntryList* entry_list,
+ const std::string& name,
+ fileapi::DirectoryEntry::DirectoryEntryType type,
+ int64 size,
+ std::string last_modified_time_string) {
+ base::Time last_modified_time;
+ const bool result = base::Time::FromString(last_modified_time_string.c_str(),
+ &last_modified_time);
+ DCHECK(result);
+ entry_list->push_back(
+ fileapi::DirectoryEntry(name, type, size, last_modified_time));
+}
+
+} // namespace
FakeProvidedFileSystem::FakeProvidedFileSystem(
const ProvidedFileSystemInfo& file_system_info)
@@ -50,6 +69,55 @@ void FakeProvidedFileSystem::GetMetadata(
FROM_HERE, base::Bind(callback, base::File::FILE_OK, file_info));
}
+void FakeProvidedFileSystem::ReadDirectory(
+ const base::FilePath& directory_path,
+ const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) {
+ // Return fake contents for the root directory only.
+ if (directory_path.AsUTF8Unsafe() != "/") {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback,
+ base::File::FILE_ERROR_NOT_FOUND,
+ fileapi::AsyncFileUtil::EntryList(),
+ false /* has_more */));
+ return;
+ }
+
+ {
+ fileapi::AsyncFileUtil::EntryList entry_list;
+ AddDirectoryEntry(&entry_list,
+ "hello.txt",
+ fileapi::DirectoryEntry::FILE,
+ 1024 /* size */,
+ "Thu Apr 24 00:46:52 UTC 2014");
+
+ AddDirectoryEntry(&entry_list,
+ "world.txt",
+ fileapi::DirectoryEntry::FILE,
+ 1024 /* size */,
+ "Wed Apr 23 00:20:30 UTC 2014");
+
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ callback, base::File::FILE_OK, entry_list, true /* has_more */));
+ }
+
+ {
+ fileapi::AsyncFileUtil::EntryList entry_list;
+ AddDirectoryEntry(&entry_list,
+ "pictures",
+ fileapi::DirectoryEntry::DIRECTORY,
+ 0 /* size */,
+ "Tue May 22 00:40:50 UTC 2014");
+
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ callback, base::File::FILE_OK, entry_list, false /* has_more */));
+ }
+}
+
const ProvidedFileSystemInfo& FakeProvidedFileSystem::GetFileSystemInfo()
const {
return file_system_info_;

Powered by Google App Engine
This is Rietveld 408576698