diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-17 20:12:05 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-17 20:12:05 +0000 |
commit | 0f695a70c914d3acb1c2ec08e4f07f4e4eebccdd (patch) | |
tree | 5bbfca2ef2591f78302c3d29245f85ac20eed942 /webkit/plugins | |
parent | b6a4ac2bccf88f27be2c2017dddeddf2aac1ff3b (diff) | |
download | chromium_src-0f695a70c914d3acb1c2ec08e4f07f4e4eebccdd.zip chromium_src-0f695a70c914d3acb1c2ec08e4f07f4e4eebccdd.tar.gz chromium_src-0f695a70c914d3acb1c2ec08e4f07f4e4eebccdd.tar.bz2 |
base::Bind: Convert FileUtilProxy::GetFileInfoCallback.
BUG=none
TEST=none
R=csilv@chromium.org
Review URL: http://codereview.chromium.org/8315012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.h | 1 | ||||
-rw-r--r-- | webkit/plugins/ppapi/quota_file_io.cc | 12 | ||||
-rw-r--r-- | webkit/plugins/ppapi/quota_file_io.h | 9 |
4 files changed, 14 insertions, 12 deletions
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc index 213071e..7cd8263 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc @@ -52,6 +52,7 @@ PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() { PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) : Resource(instance), ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), file_(base::kInvalidPlatformFileValue), file_system_type_(PP_FILESYSTEMTYPE_INVALID), pending_op_(OPERATION_NONE), @@ -132,7 +133,8 @@ int32_t PPB_FileIO_Impl::Query(PP_FileInfo* info, if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( plugin_delegate->GetFileThreadMessageLoopProxy(), file_, - callback_factory_.NewCallback(&PPB_FileIO_Impl::QueryInfoCallback))) + base::Bind(&PPB_FileIO_Impl::QueryInfoCallback, + weak_factory_.GetWeakPtr()))) return PP_ERROR_FAILED; RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h index ec55fb5..85429f3 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.h +++ b/webkit/plugins/ppapi/ppb_file_io_impl.h @@ -126,6 +126,7 @@ class PPB_FileIO_Impl : public ::ppapi::Resource, void WillWriteCallback(base::PlatformFileError error_code, int bytes_written); base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; + base::WeakPtrFactory<PPB_FileIO_Impl> weak_factory_; base::PlatformFile file_; PP_FileSystemType file_system_type_; diff --git a/webkit/plugins/ppapi/quota_file_io.cc b/webkit/plugins/ppapi/quota_file_io.cc index 4a26f67..c0210a3 100644 --- a/webkit/plugins/ppapi/quota_file_io.cc +++ b/webkit/plugins/ppapi/quota_file_io.cc @@ -7,8 +7,9 @@ #include <algorithm> #include "base/bind.h" -#include "base/stl_util.h" +#include "base/memory/scoped_callback_factory.h" #include "base/message_loop_proxy.h" +#include "base/stl_util.h" #include "base/task.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource_helper.h" @@ -224,8 +225,7 @@ QuotaFileIO::QuotaFileIO( outstanding_errors_(0), max_written_offset_(0), inflight_operations_(0), - callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), - weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { DCHECK_NE(base::kInvalidPlatformFileValue, file_); DCHECK_NE(quota::kStorageTypeUnknown, storage_type_); } @@ -294,8 +294,8 @@ bool QuotaFileIO::RegisterOperationForQuotaChecks( ++outstanding_quota_queries_; if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( plugin_delegate->GetFileThreadMessageLoopProxy(), file_, - callback_factory_.NewCallback( - &QuotaFileIO::DidQueryInfoForQuota))) { + base::Bind(&QuotaFileIO::DidQueryInfoForQuota, + weak_factory_.GetWeakPtr()))) { // This makes the call fail synchronously; we do not fire the callback // here but just delete the operation and return false. return false; @@ -306,7 +306,7 @@ bool QuotaFileIO::RegisterOperationForQuotaChecks( plugin_delegate->QueryAvailableSpace( GURL(file_url_.path()).GetOrigin(), storage_type_, base::Bind(&QuotaFileIO::DidQueryAvailableSpace, - weak_ptr_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr())); } pending_operations_.push_back(op.release()); return true; diff --git a/webkit/plugins/ppapi/quota_file_io.h b/webkit/plugins/ppapi/quota_file_io.h index 02abdd1..9c47113 100644 --- a/webkit/plugins/ppapi/quota_file_io.h +++ b/webkit/plugins/ppapi/quota_file_io.h @@ -8,7 +8,6 @@ #include <deque> #include "base/file_util_proxy.h" -#include "base/memory/scoped_callback_factory.h" #include "base/memory/weak_ptr.h" #include "base/platform_file.h" #include "googleurl/src/gurl.h" @@ -42,7 +41,7 @@ class QuotaFileIO { // Otherwise it returns false and |callback| will not be dispatched. // |callback| will not be dispatched either when this instance is // destroyed before the operation completes. - // SetLength/WillSetLength cannot be called while there're any inflight + // SetLength/WillSetLength cannot be called while there're any in-flight // operations. For Write/WillWrite it is guaranteed that |callback| are // always dispatched in the same order as Write being called. bool Write(int64_t offset, @@ -96,7 +95,7 @@ class QuotaFileIO { int64_t cached_file_size_; int64_t cached_available_space_; - // Quota-related queries and errors occured during inflight quota checks. + // Quota-related queries and errors occurred during in-flight quota checks. int outstanding_quota_queries_; int outstanding_errors_; @@ -104,8 +103,8 @@ class QuotaFileIO { int64_t max_written_offset_; int inflight_operations_; - base::ScopedCallbackFactory<QuotaFileIO> callback_factory_; - base::WeakPtrFactory<QuotaFileIO> weak_ptr_factory_; + base::WeakPtrFactory<QuotaFileIO> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(QuotaFileIO); }; |