summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_util_proxy.cc13
-rw-r--r--base/file_util_proxy.h9
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc7
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.h4
-rw-r--r--webkit/blob/blob_url_request_job.cc6
-rw-r--r--webkit/blob/blob_url_request_job.h2
-rw-r--r--webkit/fileapi/file_system_file_util_proxy.cc13
-rw-r--r--webkit/fileapi/file_system_file_util_proxy.h2
-rw-r--r--webkit/fileapi/file_system_operation.cc22
-rw-r--r--webkit/fileapi/file_system_operation.h2
-rw-r--r--webkit/fileapi/file_system_url_request_job.cc7
-rw-r--r--webkit/fileapi/file_system_url_request_job.h4
-rw-r--r--webkit/fileapi/file_system_url_request_job_unittest.cc1
13 files changed, 48 insertions, 44 deletions
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index 7757c42..bd9807b 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -120,14 +120,14 @@ class RelayCreateOrOpen : public MessageLoopRelay {
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
int file_flags,
- base::FileUtilProxy::CreateOrOpenCallback* callback)
+ const base::FileUtilProxy::CreateOrOpenCallback& callback)
: message_loop_proxy_(message_loop_proxy),
file_path_(file_path),
file_flags_(file_flags),
callback_(callback),
file_handle_(base::kInvalidPlatformFileValue),
created_(false) {
- DCHECK(callback);
+ DCHECK_EQ(false, callback.is_null());
}
protected:
@@ -149,16 +149,15 @@ class RelayCreateOrOpen : public MessageLoopRelay {
}
virtual void RunCallback() {
- callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
- created_);
- delete callback_;
+ callback_.Run(error_code(), base::PassPlatformFile(&file_handle_),
+ created_);
}
private:
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
FilePath file_path_;
int file_flags_;
- base::FileUtilProxy::CreateOrOpenCallback* callback_;
+ base::FileUtilProxy::CreateOrOpenCallback callback_;
base::PlatformFile file_handle_;
bool created_;
};
@@ -739,7 +738,7 @@ namespace base {
bool FileUtilProxy::CreateOrOpen(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path, int file_flags,
- CreateOrOpenCallback* callback) {
+ const CreateOrOpenCallback& callback) {
return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(
message_loop_proxy, file_path, file_flags, callback));
}
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h
index 30f051b..808c60e 100644
--- a/base/file_util_proxy.h
+++ b/base/file_util_proxy.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/base_export.h"
+#include "base/callback.h"
#include "base/callback_old.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -38,9 +39,9 @@ class BASE_EXPORT FileUtilProxy {
// deleted by the function even on failure.
typedef Callback1<PlatformFileError /* error code */>::Type StatusCallback;
- typedef Callback3<PlatformFileError /* error code */,
- PassPlatformFile,
- bool /* created */>::Type CreateOrOpenCallback;
+ typedef base::Callback<void(PlatformFileError /* error code */,
+ PassPlatformFile,
+ bool /* created */)> CreateOrOpenCallback;
typedef Callback3<PlatformFileError /* error code */,
PassPlatformFile,
FilePath>::Type CreateTemporaryCallback;
@@ -66,7 +67,7 @@ class BASE_EXPORT FileUtilProxy {
static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
int file_flags,
- CreateOrOpenCallback* callback);
+ const CreateOrOpenCallback& callback);
// Creates a temporary file for writing. The path and an open file handle
// are returned. It is invalid to pass NULL for the callback. The additional
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 3957c5b..195a2fa 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -10,6 +10,7 @@
#include <fcntl.h>
#endif
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/stringprintf.h"
@@ -56,7 +57,7 @@ NaClProcessHost::NaClProcessHost(const std::wstring& url)
reply_msg_(NULL),
internal_(new NaClInternal()),
running_on_wow64_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
set_name(WideToUTF16Hack(url));
#if defined(OS_WIN)
running_on_wow64_ = (base::win::OSInfo::GetInstance()->wow64_status() ==
@@ -263,8 +264,8 @@ void NaClProcessHost::OnProcessLaunched() {
irt_path = plugin_dir.Append(GetIrtLibraryFilename());
}
- base::FileUtilProxy::CreateOrOpenCallback* callback =
- callback_factory_.NewCallback(&NaClProcessHost::OpenIrtFileDone);
+ base::FileUtilProxy::CreateOrOpenCallback callback =
+ base::Bind(&NaClProcessHost::OpenIrtFileDone, weak_factory_.GetWeakPtr());
if (!base::FileUtilProxy::CreateOrOpen(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
irt_path,
diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h
index a6fd8b2..59f4f50 100644
--- a/chrome/browser/nacl_host/nacl_process_host.h
+++ b/chrome/browser/nacl_host/nacl_process_host.h
@@ -11,7 +11,7 @@
#include "base/file_path.h"
#include "base/file_util_proxy.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_callback_factory.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/common/nacl_types.h"
#include "content/browser/browser_child_process_host.h"
@@ -76,7 +76,7 @@ class NaClProcessHost : public BrowserChildProcessHost {
// Windows platform flag
bool running_on_wow64_;
- base::ScopedCallbackFactory<NaClProcessHost> callback_factory_;
+ base::WeakPtrFactory<NaClProcessHost> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NaClProcessHost);
};
diff --git a/webkit/blob/blob_url_request_job.cc b/webkit/blob/blob_url_request_job.cc
index a02096f..d70536a 100644
--- a/webkit/blob/blob_url_request_job.cc
+++ b/webkit/blob/blob_url_request_job.cc
@@ -52,7 +52,8 @@ BlobURLRequestJob::BlobURLRequestJob(
BlobData* blob_data,
base::MessageLoopProxy* file_thread_proxy)
: net::URLRequestJob(request),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
blob_data_(blob_data),
file_thread_proxy_(file_thread_proxy),
item_index_(0),
@@ -111,6 +112,7 @@ void BlobURLRequestJob::Kill() {
net::URLRequestJob::Kill();
callback_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
method_factory_.RevokeAll();
}
@@ -316,7 +318,7 @@ bool BlobURLRequestJob::DispatchReadFile(const BlobData::Item& item) {
base::FileUtilProxy::CreateOrOpen(
file_thread_proxy_, item.file_path(), kFileOpenFlags,
- callback_factory_.NewCallback(&BlobURLRequestJob::DidOpen));
+ base::Bind(&BlobURLRequestJob::DidOpen, weak_factory_.GetWeakPtr()));
SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
return false;
}
diff --git a/webkit/blob/blob_url_request_job.h b/webkit/blob/blob_url_request_job.h
index ff563b86..160dfac 100644
--- a/webkit/blob/blob_url_request_job.h
+++ b/webkit/blob/blob_url_request_job.h
@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "base/task.h"
#include "net/http/http_byte_range.h"
@@ -69,6 +70,7 @@ class BlobURLRequestJob : public net::URLRequestJob {
void DidRead(int result);
base::ScopedCallbackFactory<BlobURLRequestJob> callback_factory_;
+ base::WeakPtrFactory<BlobURLRequestJob> weak_factory_;
scoped_refptr<BlobData> blob_data_;
scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
std::vector<int64> item_length_list_;
diff --git a/webkit/fileapi/file_system_file_util_proxy.cc b/webkit/fileapi/file_system_file_util_proxy.cc
index 1906258..1372657 100644
--- a/webkit/fileapi/file_system_file_util_proxy.cc
+++ b/webkit/fileapi/file_system_file_util_proxy.cc
@@ -79,7 +79,7 @@ class RelayCreateOrOpen : public MessageLoopRelay {
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
int file_flags,
- fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback)
+ const fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback& callback)
: MessageLoopRelay(context),
message_loop_proxy_(message_loop_proxy),
file_path_(file_path),
@@ -87,7 +87,7 @@ class RelayCreateOrOpen : public MessageLoopRelay {
callback_(callback),
file_handle_(base::kInvalidPlatformFileValue),
created_(false) {
- DCHECK(callback);
+ DCHECK_EQ(false, callback.is_null());
}
protected:
@@ -103,16 +103,15 @@ class RelayCreateOrOpen : public MessageLoopRelay {
}
virtual void RunCallback() {
- callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
- created_);
- delete callback_;
+ callback_.Run(error_code(), base::PassPlatformFile(&file_handle_),
+ created_);
}
private:
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
FilePath file_path_;
int file_flags_;
- fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback_;
+ fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback callback_;
base::PlatformFile file_handle_;
bool created_;
};
@@ -432,7 +431,7 @@ bool FileSystemFileUtilProxy::CreateOrOpen(
const FileSystemOperationContext& context,
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path, int file_flags,
- CreateOrOpenCallback* callback) {
+ const CreateOrOpenCallback& callback) {
return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(context,
message_loop_proxy, file_path, file_flags, callback));
}
diff --git a/webkit/fileapi/file_system_file_util_proxy.h b/webkit/fileapi/file_system_file_util_proxy.h
index e376314..e05b81a 100644
--- a/webkit/fileapi/file_system_file_util_proxy.h
+++ b/webkit/fileapi/file_system_file_util_proxy.h
@@ -54,7 +54,7 @@ class FileSystemFileUtilProxy {
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
int file_flags,
- CreateOrOpenCallback* callback);
+ const CreateOrOpenCallback& callback);
// Close the given file handle.
static bool Close(const FileSystemOperationContext& context,
diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc
index a02e2a7..93bd3ae 100644
--- a/webkit/fileapi/file_system_operation.cc
+++ b/webkit/fileapi/file_system_operation.cc
@@ -4,6 +4,7 @@
#include "webkit/fileapi/file_system_operation.h"
+#include "base/bind.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "net/base/escape.h"
@@ -64,7 +65,8 @@ FileSystemOperation::FileSystemOperation(
: proxy_(proxy),
dispatcher_(dispatcher),
file_system_operation_context_(file_system_context, file_util),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
DCHECK(dispatcher);
#ifndef NDEBUG
pending_operation_ = kOperationNone;
@@ -179,10 +181,7 @@ void FileSystemOperation::DelayedCreateDirectoryForQuota(
file_system_operation_context_.src_type()));
FileSystemFileUtilProxy::CreateDirectory(
- file_system_operation_context_,
- proxy_,
- src_virtual_path_,
- exclusive_,
+ file_system_operation_context_, proxy_, src_virtual_path_, exclusive_,
recursive_,
callback_factory_.NewCallback(
&FileSystemOperation::DidFinishFileOperation));
@@ -461,8 +460,8 @@ void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status,
src_virtual_path_,
base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE |
base::PLATFORM_FILE_ASYNC,
- callback_factory_.NewCallback(
- &FileSystemOperation::OnFileOpenedForWrite));
+ base::Bind(&FileSystemOperation::OnFileOpenedForWrite,
+ weak_factory_.GetWeakPtr()));
}
void FileSystemOperation::Truncate(const GURL& path, int64 length) {
@@ -588,12 +587,9 @@ void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status,
file_system_operation_context_.src_type()));
FileSystemFileUtilProxy::CreateOrOpen(
- file_system_operation_context_,
- proxy_,
- src_virtual_path_,
- file_flags_,
- callback_factory_.NewCallback(
- &FileSystemOperation::DidOpenFile));
+ file_system_operation_context_, proxy_, src_virtual_path_, file_flags_,
+ base::Bind(&FileSystemOperation::DidOpenFile,
+ weak_factory_.GetWeakPtr()));
}
// We can only get here on a write or truncate that's not yet completed.
diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h
index b38633a..5876692 100644
--- a/webkit/fileapi/file_system_operation.h
+++ b/webkit/fileapi/file_system_operation.h
@@ -13,6 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop_proxy.h"
#include "base/platform_file.h"
#include "base/process.h"
@@ -241,6 +242,7 @@ class FileSystemOperation {
FileSystemOperationContext file_system_operation_context_;
base::ScopedCallbackFactory<FileSystemOperation> callback_factory_;
+ base::WeakPtrFactory<FileSystemOperation> weak_factory_;
scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_;
diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc
index 8cdf9d4..8c28ded 100644
--- a/webkit/fileapi/file_system_url_request_job.cc
+++ b/webkit/fileapi/file_system_url_request_job.cc
@@ -107,7 +107,7 @@ FileSystemURLRequestJob::FileSystemURLRequestJob(
file_system_context_(file_system_context),
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(weak_factory_(this)),
stream_(NULL),
is_directory_(false),
remaining_bytes_(0) {
@@ -133,7 +133,7 @@ void FileSystemURLRequestJob::Kill() {
}
URLRequestJob::Kill();
method_factory_.RevokeAll();
- callback_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
}
bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size,
@@ -239,7 +239,8 @@ void FileSystemURLRequestJob::DidGetMetadata(
if (!is_directory_) {
base::FileUtilProxy::CreateOrOpen(
file_thread_proxy_, platform_path, kFileFlags,
- callback_factory_.NewCallback(&FileSystemURLRequestJob::DidOpen));
+ base::Bind(&FileSystemURLRequestJob::DidOpen,
+ weak_factory_.GetWeakPtr()));
} else {
NotifyHeadersComplete();
}
diff --git a/webkit/fileapi/file_system_url_request_job.h b/webkit/fileapi/file_system_url_request_job.h
index 1c66708..945e257 100644
--- a/webkit/fileapi/file_system_url_request_job.h
+++ b/webkit/fileapi/file_system_url_request_job.h
@@ -8,8 +8,8 @@
#include <string>
-#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop_proxy.h"
#include "base/platform_file.h"
#include "base/task.h"
@@ -62,7 +62,7 @@ class FileSystemURLRequestJob : public net::URLRequestJob {
FileSystemContext* file_system_context_;
scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
ScopedRunnableMethodFactory<FileSystemURLRequestJob> method_factory_;
- base::ScopedCallbackFactory<FileSystemURLRequestJob> callback_factory_;
+ base::WeakPtrFactory<FileSystemURLRequestJob> weak_factory_;
scoped_ptr<net::FileStream> stream_;
bool is_directory_;
scoped_ptr<net::HttpResponseInfo> response_info_;
diff --git a/webkit/fileapi/file_system_url_request_job_unittest.cc b/webkit/fileapi/file_system_url_request_job_unittest.cc
index 0070033..33e0e7c 100644
--- a/webkit/fileapi/file_system_url_request_job_unittest.cc
+++ b/webkit/fileapi/file_system_url_request_job_unittest.cc
@@ -17,6 +17,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/format_macros.h"
+#include "base/memory/scoped_callback_factory.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/platform_file.h"