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

Side by Side Diff: webkit/browser/fileapi/file_writer_delegate.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/browser/fileapi/file_writer_delegate.h" 5 #include "webkit/browser/fileapi/file_writer_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_util_proxy.h" 9 #include "base/files/file_util_proxy.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 void FileWriterDelegate::OnDataReceived(int bytes_read) { 138 void FileWriterDelegate::OnDataReceived(int bytes_read) {
139 bytes_read_ = bytes_read; 139 bytes_read_ = bytes_read;
140 if (!bytes_read_) { // We're done. 140 if (!bytes_read_) { // We're done.
141 OnProgress(0, true); 141 OnProgress(0, true);
142 } else { 142 } else {
143 // This could easily be optimized to rotate between a pool of buffers, so 143 // This could easily be optimized to rotate between a pool of buffers, so
144 // that we could read and write at the same time. It's not yet clear that 144 // that we could read and write at the same time. It's not yet clear that
145 // it's necessary. 145 // it's necessary.
146 cursor_ = new net::DrainableIOBuffer(io_buffer_, bytes_read_); 146 cursor_ = new net::DrainableIOBuffer(io_buffer_.get(), bytes_read_);
147 Write(); 147 Write();
148 } 148 }
149 } 149 }
150 150
151 void FileWriterDelegate::Write() { 151 void FileWriterDelegate::Write() {
152 writing_started_ = true; 152 writing_started_ = true;
153 int64 bytes_to_write = bytes_read_ - bytes_written_; 153 int64 bytes_to_write = bytes_read_ - bytes_written_;
154 int write_response = 154 int write_response =
155 file_stream_writer_->Write(cursor_, 155 file_stream_writer_->Write(cursor_.get(),
156 static_cast<int>(bytes_to_write), 156 static_cast<int>(bytes_to_write),
157 base::Bind(&FileWriterDelegate::OnDataWritten, 157 base::Bind(&FileWriterDelegate::OnDataWritten,
158 weak_factory_.GetWeakPtr())); 158 weak_factory_.GetWeakPtr()));
159 if (write_response > 0) 159 if (write_response > 0)
160 base::MessageLoop::current()->PostTask( 160 base::MessageLoop::current()->PostTask(
161 FROM_HERE, 161 FROM_HERE,
162 base::Bind(&FileWriterDelegate::OnDataWritten, 162 base::Bind(&FileWriterDelegate::OnDataWritten,
163 weak_factory_.GetWeakPtr(), 163 weak_factory_.GetWeakPtr(),
164 write_response)); 164 write_response));
165 else if (net::ERR_IO_PENDING != write_response) 165 else if (net::ERR_IO_PENDING != write_response)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) { 244 if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) {
245 // If the Flush introduced an error, overwrite the status. 245 // If the Flush introduced an error, overwrite the status.
246 // Otherwise, keep the original error status. 246 // Otherwise, keep the original error status.
247 error = NetErrorToPlatformFileError(flush_error); 247 error = NetErrorToPlatformFileError(flush_error);
248 progress_status = GetCompletionStatusOnError(); 248 progress_status = GetCompletionStatusOnError();
249 } 249 }
250 write_callback_.Run(error, bytes_written, progress_status); 250 write_callback_.Run(error, bytes_written, progress_status);
251 } 251 }
252 252
253 } // namespace fileapi 253 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_usage_cache.cc ('k') | webkit/browser/fileapi/file_writer_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698