From 5eb431e2dfe9d55eaff2acc7a3ea64f403dec669 Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Wed, 12 Oct 2011 08:51:38 +0000 Subject: Switch FileStream to use new CompletionCallback. BUG=98719 TEST=none Review URL: http://codereview.chromium.org/8139019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105042 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/fileapi/file_system_url_request_job.cc | 7 ++++--- webkit/fileapi/file_system_url_request_job.h | 2 -- webkit/fileapi/file_writer_delegate.cc | 11 ++++++----- webkit/fileapi/file_writer_delegate.h | 2 -- 4 files changed, 10 insertions(+), 12 deletions(-) (limited to 'webkit/fileapi') diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc index 34fec21..8cdf9d4 100644 --- a/webkit/fileapi/file_system_url_request_job.cc +++ b/webkit/fileapi/file_system_url_request_job.cc @@ -4,6 +4,7 @@ #include "webkit/fileapi/file_system_url_request_job.h" +#include "base/bind.h" #include "base/compiler_specific.h" #include "base/file_path.h" #include "base/file_util_proxy.h" @@ -107,8 +108,6 @@ FileSystemURLRequestJob::FileSystemURLRequestJob( file_thread_proxy_(file_thread_proxy), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), - ALLOW_THIS_IN_INITIALIZER_LIST( - io_callback_(this, &FileSystemURLRequestJob::DidRead)), stream_(NULL), is_directory_(false), remaining_bytes_(0) { @@ -154,7 +153,9 @@ bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, return true; } - int rv = stream_->Read(dest->data(), dest_size, &io_callback_); + int rv = stream_->Read(dest->data(), dest_size, + base::Bind(&FileSystemURLRequestJob::DidRead, + base::Unretained(this))); if (rv >= 0) { // Data is immediately available. *bytes_read = rv; diff --git a/webkit/fileapi/file_system_url_request_job.h b/webkit/fileapi/file_system_url_request_job.h index 1caa988..1c66708 100644 --- a/webkit/fileapi/file_system_url_request_job.h +++ b/webkit/fileapi/file_system_url_request_job.h @@ -13,7 +13,6 @@ #include "base/message_loop_proxy.h" #include "base/platform_file.h" #include "base/task.h" -#include "net/base/completion_callback.h" #include "net/http/http_byte_range.h" #include "net/url_request/url_request_job.h" @@ -64,7 +63,6 @@ class FileSystemURLRequestJob : public net::URLRequestJob { scoped_refptr file_thread_proxy_; ScopedRunnableMethodFactory method_factory_; base::ScopedCallbackFactory callback_factory_; - net::OldCompletionCallbackImpl io_callback_; scoped_ptr stream_; bool is_directory_; scoped_ptr response_info_; diff --git a/webkit/fileapi/file_writer_delegate.cc b/webkit/fileapi/file_writer_delegate.cc index 34339a5..4c4ab24 100644 --- a/webkit/fileapi/file_writer_delegate.cc +++ b/webkit/fileapi/file_writer_delegate.cc @@ -4,6 +4,7 @@ #include "webkit/fileapi/file_writer_delegate.h" +#include "base/bind.h" #include "base/file_util_proxy.h" #include "base/message_loop.h" #include "base/threading/thread_restrictions.h" @@ -94,8 +95,6 @@ FileWriterDelegate::FileWriterDelegate( total_bytes_written_(0), allowed_bytes_to_write_(0), io_buffer_(new net::IOBufferWithSize(kReadBufSize)), - io_callback_(ALLOW_THIS_IN_INITIALIZER_LIST(this), - &FileWriterDelegate::OnDataWritten), method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -232,9 +231,11 @@ void FileWriterDelegate::Write() { if (bytes_to_write > allowed_bytes_to_write_ - total_bytes_written_) bytes_to_write = allowed_bytes_to_write_ - total_bytes_written_; - int write_response = file_stream_->Write(io_buffer_->data() + bytes_written_, - static_cast(bytes_to_write), - &io_callback_); + int write_response = + file_stream_->Write(io_buffer_->data() + bytes_written_, + static_cast(bytes_to_write), + base::Bind(&FileWriterDelegate::OnDataWritten, + base::Unretained(this))); if (write_response > 0) MessageLoop::current()->PostTask( FROM_HERE, diff --git a/webkit/fileapi/file_writer_delegate.h b/webkit/fileapi/file_writer_delegate.h index 18677fb..1fe4a8d 100644 --- a/webkit/fileapi/file_writer_delegate.h +++ b/webkit/fileapi/file_writer_delegate.h @@ -13,7 +13,6 @@ #include "base/platform_file.h" #include "base/task.h" #include "base/time.h" -#include "net/base/completion_callback.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/url_request/url_request.h" @@ -81,7 +80,6 @@ class FileWriterDelegate : public net::URLRequest::Delegate { scoped_refptr io_buffer_; scoped_ptr file_stream_; net::URLRequest* request_; - net::OldCompletionCallbackImpl io_callback_; ScopedRunnableMethodFactory method_factory_; base::ScopedCallbackFactory callback_factory_; }; -- cgit v1.1