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

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

Issue 279213002: [fsp] Add support for closing files. (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 aab2a8310d14f352024dcf890f1122d6e21c9dc5..1d297cdb44a89f10a25372b41e87894822c644bc 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
@@ -32,7 +32,7 @@ void AddDirectoryEntry(fileapi::AsyncFileUtil::EntryList* entry_list,
FakeProvidedFileSystem::FakeProvidedFileSystem(
const ProvidedFileSystemInfo& file_system_info)
- : file_system_info_(file_system_info) {
+ : file_system_info_(file_system_info), last_file_handle_(0) {
}
FakeProvidedFileSystem::~FakeProvidedFileSystem() {}
@@ -118,17 +118,31 @@ void FakeProvidedFileSystem::ReadDirectory(
}
}
-void FakeProvidedFileSystem::OpenFile(
- const base::FilePath& file_path,
- OpenFileMode mode,
- bool create,
- const fileapi::AsyncFileUtil::StatusCallback& callback) {
+void FakeProvidedFileSystem::OpenFile(const base::FilePath& file_path,
+ OpenFileMode mode,
+ bool create,
+ const OpenFileCallback& callback) {
if (file_path.AsUTF8Unsafe() != "/hello.txt" ||
mode == OPEN_FILE_MODE_WRITE || create) {
- callback.Run(base::File::FILE_ERROR_SECURITY);
+ callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY);
+ return;
+ }
+
+ const int file_handle = ++last_file_handle_;
+ callback.Run(file_handle, base::File::FILE_OK);
+}
+
+void FakeProvidedFileSystem::CloseFile(
+ int file_handle,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) {
+ const std::set<int>::iterator opened_file_it =
+ opened_files_.find(file_handle);
+ if (opened_file_it == opened_files_.end()) {
+ callback.Run(base::File::FILE_ERROR_NOT_FOUND);
return;
}
+ opened_files_.erase(opened_file_it);
callback.Run(base::File::FILE_OK);
}

Powered by Google App Engine
This is Rietveld 408576698