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

Unified Diff: webkit/fileapi/file_writer_delegate.cc

Issue 10956064: Send OnModifyFile Notification when File Write Finishes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added write status inside FileWriteDelegate so onFileModify notifications are only sent when a file… Created 8 years, 3 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: webkit/fileapi/file_writer_delegate.cc
diff --git a/webkit/fileapi/file_writer_delegate.cc b/webkit/fileapi/file_writer_delegate.cc
index 98dbaabecf839daa6626a88dadb436063a9ad832..c202e7a22341c5839abce871426db306da6d162f 100644
--- a/webkit/fileapi/file_writer_delegate.cc
+++ b/webkit/fileapi/file_writer_delegate.cc
@@ -38,10 +38,11 @@ base::PlatformFileError NetErrorToPlatformFileError(int error) {
} // namespace
FileWriterDelegate::FileWriterDelegate(
- const FileSystemOperation::WriteCallback& write_callback,
+ const DelegateWriteCallback& write_callback,
scoped_ptr<FileStreamWriter> file_stream_writer)
: write_callback_(write_callback),
file_stream_writer_(file_stream_writer.Pass()),
+ writing_started_(false),
bytes_written_backlog_(0),
bytes_written_(0),
bytes_read_(0),
@@ -145,6 +146,7 @@ void FileWriterDelegate::OnDataReceived(int bytes_read) {
}
void FileWriterDelegate::Write() {
+ writing_started_ = true;
int64 bytes_to_write = bytes_read_ - bytes_written_;
int write_response =
file_stream_writer_->Write(cursor_,
@@ -174,13 +176,18 @@ void FileWriterDelegate::OnDataWritten(int write_response) {
}
}
+FileWriterDelegate::WriteCompletionStatus
+FileWriterDelegate::ErrorCompletionStatus() {
+ return (writing_started_) ? ERROR_WRITE_STARTED : ERROR_WRITE_NOT_STARTED;
kinuko 2012/09/25 14:00:49 nit: no parens needed around writing_started_
calvinlo 2012/09/26 05:23:07 Done.
+}
+
void FileWriterDelegate::OnError(base::PlatformFileError error) {
if (request_.get()) {
request_->set_delegate(NULL);
request_->Cancel();
}
- write_callback_.Run(error, 0, true);
+ write_callback_.Run(error, 0, ErrorCompletionStatus());
}
void FileWriterDelegate::OnProgress(int bytes_written, bool done) {
@@ -193,15 +200,17 @@ void FileWriterDelegate::OnProgress(int bytes_written, bool done) {
bytes_written += bytes_written_backlog_;
last_progress_event_time_ = currentTime;
bytes_written_backlog_ = 0;
- write_callback_.Run(
- base::PLATFORM_FILE_OK, bytes_written, done);
+
+ WriteCompletionStatus status = (done) ? COMPLETE_SUCCESSFUL : NOT_COMPLETE;
kinuko 2012/09/25 14:00:49 nit: no parens needed
calvinlo 2012/09/26 05:23:07 Done.
+ write_callback_.Run(base::PLATFORM_FILE_OK, bytes_written, status);
return;
}
bytes_written_backlog_ += bytes_written;
}
void FileWriterDelegate::OnWriteCancelled(int status) {
- write_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT, 0, true);
+ write_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT, 0,
+ ErrorCompletionStatus());
}
} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698