diff options
author | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 02:04:25 +0000 |
---|---|---|
committer | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 02:04:25 +0000 |
commit | 8df9747bff840d1a63b9fe1309b18e5fb21e8340 (patch) | |
tree | 1e87c4c5797484c81818f78387dc40305895321c /webkit/fileapi | |
parent | 69d0aa9b0c8675c1ddde22dc1bbd03d9f9cbdde3 (diff) | |
download | chromium_src-8df9747bff840d1a63b9fe1309b18e5fb21e8340.zip chromium_src-8df9747bff840d1a63b9fe1309b18e5fb21e8340.tar.gz chromium_src-8df9747bff840d1a63b9fe1309b18e5fb21e8340.tar.bz2 |
Fix memory leak in FileWriterDelegate by passing FileStream::Write a callback owned by the delegate.
Remove the suppression of this memory leak.
R=ericu@chromium.org
BUG=75741
TEST=none
Review URL: http://codereview.chromium.org/6685056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/file_writer_delegate.cc | 12 | ||||
-rw-r--r-- | webkit/fileapi/file_writer_delegate.h | 5 |
2 files changed, 8 insertions, 9 deletions
diff --git a/webkit/fileapi/file_writer_delegate.cc b/webkit/fileapi/file_writer_delegate.cc index 49a4ecd..c0574fca 100644 --- a/webkit/fileapi/file_writer_delegate.cc +++ b/webkit/fileapi/file_writer_delegate.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,7 +23,8 @@ FileWriterDelegate::FileWriterDelegate( bytes_written_(0), bytes_read_(0), io_buffer_(new net::IOBufferWithSize(kReadBufSize)), - callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + io_callback_(ALLOW_THIS_IN_INITIALIZER_LIST(this), + &FileWriterDelegate::OnDataWritten), method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -119,10 +120,9 @@ void FileWriterDelegate::OnDataReceived(int bytes_read) { } void FileWriterDelegate::Write() { - int write_response = file_stream_->Write( - io_buffer_->data() + bytes_written_, - bytes_read_ - bytes_written_, - callback_factory_.NewCallback(&FileWriterDelegate::OnDataWritten)); + int write_response = file_stream_->Write(io_buffer_->data() + bytes_written_, + bytes_read_ - bytes_written_, + &io_callback_); 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 8e90a23..f5de184 100644 --- a/webkit/fileapi/file_writer_delegate.h +++ b/webkit/fileapi/file_writer_delegate.h @@ -8,10 +8,10 @@ #include "base/file_path.h" #include "base/platform_file.h" #include "base/ref_counted.h" -#include "base/scoped_callback_factory.h" #include "base/scoped_ptr.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" @@ -61,11 +61,10 @@ class FileWriterDelegate : public net::URLRequest::Delegate { scoped_refptr<net::IOBufferWithSize> io_buffer_; scoped_ptr<net::FileStream> file_stream_; net::URLRequest* request_; - base::ScopedCallbackFactory<FileWriterDelegate> callback_factory_; + net::CompletionCallbackImpl<FileWriterDelegate> io_callback_; ScopedRunnableMethodFactory<FileWriterDelegate> method_factory_; }; } // namespace fileapi #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ - |