Chromium Code Reviews| Index: content/common/fileapi/webfilewriter_impl.cc |
| diff --git a/content/common/fileapi/webfilewriter_impl.cc b/content/common/fileapi/webfilewriter_impl.cc |
| index ac685e1b78fbb7358aead0a4b94da71286b435da..fed77f57f9ec23217119e4c138a50b13142f0916 100644 |
| --- a/content/common/fileapi/webfilewriter_impl.cc |
| +++ b/content/common/fileapi/webfilewriter_impl.cc |
| @@ -4,60 +4,19 @@ |
| #include "content/common/fileapi/webfilewriter_impl.h" |
| +#include "base/bind.h" |
| #include "content/common/child_thread.h" |
| #include "content/common/fileapi/file_system_dispatcher.h" |
| namespace content { |
| + |
| namespace { |
| inline FileSystemDispatcher* GetFileSystemDispatcher() { |
| return ChildThread::current()->file_system_dispatcher(); |
| } |
| -} |
| - |
| -class WebFileWriterImpl::CallbackDispatcher |
| - : public fileapi::FileSystemCallbackDispatcher { |
| - public: |
| - explicit CallbackDispatcher( |
| - const base::WeakPtr<WebFileWriterImpl>& writer) : writer_(writer) { |
| - } |
| - virtual ~CallbackDispatcher() { |
| - } |
| - virtual void DidReadMetadata( |
| - const base::PlatformFileInfo&, |
| - const base::FilePath&) OVERRIDE { |
| - NOTREACHED(); |
| - } |
| - virtual void DidCreateSnapshotFile( |
| - const base::PlatformFileInfo&, |
| - const base::FilePath&) OVERRIDE { |
| - NOTREACHED(); |
| - } |
| - virtual void DidReadDirectory( |
| - const std::vector<base::FileUtilProxy::Entry>& entries, |
| - bool has_more) OVERRIDE { |
| - NOTREACHED(); |
| - } |
| - virtual void DidOpenFileSystem(const std::string& name, |
| - const GURL& root) OVERRIDE { |
| - NOTREACHED(); |
| - } |
| - virtual void DidSucceed() OVERRIDE { |
| - if (writer_) |
| - writer_->DidSucceed(); |
| - } |
| - virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { |
| - if (writer_) |
| - writer_->DidFail(error_code); |
| - } |
| - virtual void DidWrite(int64 bytes, bool complete) OVERRIDE { |
| - if (writer_) |
| - writer_->DidWrite(bytes, complete); |
| - } |
| - private: |
| - base::WeakPtr<WebFileWriterImpl> writer_; |
| -}; |
| +} // namespace |
| WebFileWriterImpl::WebFileWriterImpl( |
| const GURL& path, WebKit::WebFileWriterClient* client) |
| @@ -70,20 +29,23 @@ WebFileWriterImpl::~WebFileWriterImpl() { |
| void WebFileWriterImpl::DoTruncate(const GURL& path, int64 offset) { |
| // The FileSystemDispatcher takes ownership of the CallbackDispatcher. |
| - GetFileSystemDispatcher()->Truncate(path, offset, &request_id_, |
| - new CallbackDispatcher(AsWeakPtr())); |
| + GetFileSystemDispatcher()->Truncate( |
| + path, offset, &request_id_, |
| + base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr())); |
| } |
| void WebFileWriterImpl::DoWrite( |
| const GURL& path, const GURL& blob_url, int64 offset) { |
| GetFileSystemDispatcher()->Write( |
| path, blob_url, offset, &request_id_, |
| - new CallbackDispatcher(AsWeakPtr())); |
| + base::Bind(&WebFileWriterImpl::DidWrite, AsWeakPtr()), |
| + base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr())); |
|
michaeln
2013/05/15 20:18:26
since this is a subclass, shouldn't need to be pub
kinuko
2013/05/16 09:29:38
Done.
|
| } |
| void WebFileWriterImpl::DoCancel() { |
| - GetFileSystemDispatcher()->Cancel(request_id_, |
| - new CallbackDispatcher(AsWeakPtr())); |
| + GetFileSystemDispatcher()->Cancel( |
| + request_id_, |
| + base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr())); |
| } |
| } // namespace content |