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

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

Issue 307463002: [fsp] Polish FakeProvidedFileSystem methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 52e1c68011722df35d4d33059d76a017f3229c4f..145758dddbbebeb810f0854335c9ebd4ec09d60a 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
@@ -148,13 +148,17 @@ void FakeProvidedFileSystem::OpenFile(const base::FilePath& file_path,
const OpenFileCallback& callback) {
if (file_path.AsUTF8Unsafe() != "/hello.txt" ||
mode == OPEN_FILE_MODE_WRITE || create) {
- callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY);
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ callback, 0 /* file_handle */, base::File::FILE_ERROR_SECURITY));
return;
}
const int file_handle = ++last_file_handle_;
opened_files_[file_handle] = file_path;
- callback.Run(file_handle, base::File::FILE_OK);
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE, base::Bind(callback, file_handle, base::File::FILE_OK));
}
void FakeProvidedFileSystem::CloseFile(
@@ -196,8 +200,8 @@ void FakeProvidedFileSystem::ReadFile(
size_t current_offset = static_cast<size_t>(offset);
size_t current_length = static_cast<size_t>(length);
- // Reading behind EOF, is fine, it will just read 0 bytes.
- if (current_offset > kFakeFileSize || !current_length) {
+ // Reading behind EOF is fine, it will just return 0 bytes.
+ if (current_offset >= kFakeFileSize || !current_length) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(callback,
@@ -210,7 +214,10 @@ void FakeProvidedFileSystem::ReadFile(
buffer->data()[current_offset - offset] = kFakeFileText[current_offset];
const bool has_next =
(current_offset + 1 < kFakeFileSize) && (current_length - 1);
- callback.Run(1, has_next, base::File::FILE_OK);
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ callback, 1 /* chunk_length */, has_next, base::File::FILE_OK));
current_offset++;
current_length--;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698