diff options
author | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 14:11:03 +0000 |
---|---|---|
committer | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 14:11:03 +0000 |
commit | 4d99be5a3d20c3a3654f282328065f9ff54d6f39 (patch) | |
tree | b355c0c05f4879373ab23998dfb49253ff6f9e9e /content | |
parent | 58ae297434a9e33d1006c52b6d13d8a78e3b7e5e (diff) | |
download | chromium_src-4d99be5a3d20c3a3654f282328065f9ff54d6f39.zip chromium_src-4d99be5a3d20c3a3654f282328065f9ff54d6f39.tar.gz chromium_src-4d99be5a3d20c3a3654f282328065f9ff54d6f39.tar.bz2 |
Use base::Callback in Quota related code.
BUG=None
TEST='Compilation should finished successfull and all quota related tests should be passed.'
Review URL: http://codereview.chromium.org/8070001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
10 files changed, 112 insertions, 120 deletions
diff --git a/content/browser/file_system/file_system_browsertest.cc b/content/browser/file_system/file_system_browsertest.cc index 06715014..671d4fd 100644 --- a/content/browser/file_system/file_system_browsertest.cc +++ b/content/browser/file_system/file_system_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/bind.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" @@ -71,7 +72,7 @@ class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest { return; } DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - qm->SetTemporaryGlobalOverrideQuota(bytes, NULL); + qm->SetTemporaryGlobalOverrideQuota(bytes, quota::QuotaCallback()); // Don't return until the quota has been set. scoped_refptr<base::ThreadTestHelper> helper( new base::ThreadTestHelper( diff --git a/content/browser/in_process_webkit/indexed_db_browsertest.cc b/content/browser/in_process_webkit/indexed_db_browsertest.cc index 62b0a28..b112e30 100644 --- a/content/browser/in_process_webkit/indexed_db_browsertest.cc +++ b/content/browser/in_process_webkit/indexed_db_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/bind.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" @@ -233,7 +234,7 @@ class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { return; } DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - qm->SetTemporaryGlobalOverrideQuota(bytes, NULL); + qm->SetTemporaryGlobalOverrideQuota(bytes, quota::QuotaCallback()); // Don't return until the quota has been set. scoped_refptr<base::ThreadTestHelper> helper( new base::ThreadTestHelper( diff --git a/content/browser/in_process_webkit/indexed_db_context.cc b/content/browser/in_process_webkit/indexed_db_context.cc index 99b0330..59fc64a 100644 --- a/content/browser/in_process_webkit/indexed_db_context.cc +++ b/content/browser/in_process_webkit/indexed_db_context.cc @@ -4,6 +4,7 @@ #include "content/browser/in_process_webkit/indexed_db_context.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/logging.h" @@ -87,41 +88,6 @@ const FilePath::CharType IndexedDBContext::kIndexedDBDirectory[] = const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] = FILE_PATH_LITERAL(".leveldb"); -class IndexedDBContext::IndexedDBGetUsageAndQuotaCallback : - public quota::QuotaManager::GetUsageAndQuotaCallback { - public: - IndexedDBGetUsageAndQuotaCallback(IndexedDBContext* context, - const GURL& origin_url) - : context_(context), - origin_url_(origin_url) { - } - - void Run(quota::QuotaStatusCode status, int64 usage, int64 quota) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DCHECK(status == quota::kQuotaStatusOk || status == quota::kQuotaErrorAbort) - << "status was " << status; - if (status == quota::kQuotaErrorAbort) { - // We seem to no longer care to wait around for the answer. - return; - } - BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, - NewRunnableMethod(context_.get(), - &IndexedDBContext::GotUpdatedQuota, - origin_url_, - usage, - quota)); - } - - virtual void RunWithParams( - const Tuple3<quota::QuotaStatusCode, int64, int64>& params) { - Run(params.a, params.b, params.c); - } - - private: - scoped_refptr<IndexedDBContext> context_; - const GURL origin_url_; -}; - IndexedDBContext::IndexedDBContext( WebKitContext* webkit_context, quota::SpecialStoragePolicy* special_storage_policy, @@ -316,6 +282,25 @@ void IndexedDBContext::QueryDiskAndUpdateQuotaUsage(const GURL& origin_url) { } } +void IndexedDBContext::GotUsageAndQuota(const GURL& origin_url, + quota::QuotaStatusCode status, + int64 usage, int64 quota) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(status == quota::kQuotaStatusOk || status == quota::kQuotaErrorAbort) + << "status was " << status; + if (status == quota::kQuotaErrorAbort) { + // We seem to no longer care to wait around for the answer. + return; + } + BrowserThread::PostTask( + BrowserThread::WEBKIT, FROM_HERE, + NewRunnableMethod(this, + &IndexedDBContext::GotUpdatedQuota, + origin_url, + usage, + quota)); +} + void IndexedDBContext::GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); @@ -334,12 +319,11 @@ void IndexedDBContext::QueryAvailableQuota(const GURL& origin_url) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!quota_manager_proxy()->quota_manager()) return; - IndexedDBGetUsageAndQuotaCallback* callback = - new IndexedDBGetUsageAndQuotaCallback(this, origin_url); quota_manager_proxy()->quota_manager()->GetUsageAndQuota( origin_url, quota::kStorageTypeTemporary, - callback); + base::Bind(&IndexedDBContext::GotUsageAndQuota, + this, origin_url)); } std::set<GURL>* IndexedDBContext::GetOriginSet() { diff --git a/content/browser/in_process_webkit/indexed_db_context.h b/content/browser/in_process_webkit/indexed_db_context.h index a7207e6..19c6b91 100644 --- a/content/browser/in_process_webkit/indexed_db_context.h +++ b/content/browser/in_process_webkit/indexed_db_context.h @@ -18,6 +18,7 @@ #include "content/browser/browser_thread.h" #include "content/common/content_export.h" #include "googleurl/src/gurl.h" +#include "webkit/quota/quota_types.h" class GURL; class FilePath; @@ -94,6 +95,8 @@ class CONTENT_EXPORT IndexedDBContext int64 ReadUsageFromDisk(const GURL& origin_url) const; void EnsureDiskUsageCacheInitialized(const GURL& origin_url); void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); + void GotUsageAndQuota(const GURL& origin_url, quota::QuotaStatusCode, + int64 usage, int64 quota); void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); void QueryAvailableQuota(const GURL& origin_url); diff --git a/content/browser/in_process_webkit/indexed_db_quota_client.cc b/content/browser/in_process_webkit/indexed_db_quota_client.cc index 618f147..ce60d83 100644 --- a/content/browser/in_process_webkit/indexed_db_quota_client.cc +++ b/content/browser/in_process_webkit/indexed_db_quota_client.cc @@ -36,7 +36,7 @@ class IndexedDBQuotaClient::DeleteOriginTask : public HelperTask { DeleteOriginTask(IndexedDBQuotaClient* client, base::MessageLoopProxy* webkit_thread_message_loop, const GURL& origin_url, - DeletionCallback* callback) + const DeletionCallback& callback) : HelperTask(client, webkit_thread_message_loop), origin_url_(origin_url), callback_(callback) { } @@ -45,14 +45,14 @@ class IndexedDBQuotaClient::DeleteOriginTask : public HelperTask { indexed_db_context_->DeleteIndexedDBForOrigin(origin_url_); } virtual void Aborted() OVERRIDE { - callback_.reset(); + callback_.Reset(); } virtual void Completed() OVERRIDE { - callback_->Run(quota::kQuotaStatusOk); - callback_.reset(); + callback_.Run(quota::kQuotaStatusOk); + callback_.Reset(); } GURL origin_url_; - scoped_ptr<DeletionCallback> callback_; + DeletionCallback callback_; }; class IndexedDBQuotaClient::GetOriginUsageTask : public HelperTask { @@ -168,18 +168,17 @@ void IndexedDBQuotaClient::OnQuotaManagerDestroyed() { void IndexedDBQuotaClient::GetOriginUsage( const GURL& origin_url, quota::StorageType type, - GetUsageCallback* callback_ptr) { - DCHECK(callback_ptr); + const GetUsageCallback& callback) { + DCHECK(!callback.is_null()); DCHECK(indexed_db_context_.get()); - scoped_ptr<GetUsageCallback> callback(callback_ptr); // IndexedDB is in the temp namespace for now. if (type != quota::kStorageTypeTemporary) { - callback->Run(0); + callback.Run(0); return; } - if (usage_for_origin_callbacks_.Add(origin_url, callback.release())) { + if (usage_for_origin_callbacks_.Add(origin_url, callback)) { scoped_refptr<GetOriginUsageTask> task( new GetOriginUsageTask(this, webkit_thread_message_loop_, origin_url)); task->Start(); @@ -188,18 +187,17 @@ void IndexedDBQuotaClient::GetOriginUsage( void IndexedDBQuotaClient::GetOriginsForType( quota::StorageType type, - GetOriginsCallback* callback_ptr) { - DCHECK(callback_ptr); + const GetOriginsCallback& callback) { + DCHECK(!callback.is_null()); DCHECK(indexed_db_context_.get()); - scoped_ptr<GetOriginsCallback> callback(callback_ptr); // All databases are in the temp namespace for now. if (type != quota::kStorageTypeTemporary) { - callback->Run(std::set<GURL>(), type); + callback.Run(std::set<GURL>(), type); return; } - if (origins_for_type_callbacks_.Add(callback.release())) { + if (origins_for_type_callbacks_.Add(callback)) { scoped_refptr<GetAllOriginsTask> task( new GetAllOriginsTask(this, webkit_thread_message_loop_, type)); task->Start(); @@ -209,18 +207,17 @@ void IndexedDBQuotaClient::GetOriginsForType( void IndexedDBQuotaClient::GetOriginsForHost( quota::StorageType type, const std::string& host, - GetOriginsCallback* callback_ptr) { - DCHECK(callback_ptr); + const GetOriginsCallback& callback) { + DCHECK(!callback.is_null()); DCHECK(indexed_db_context_.get()); - scoped_ptr<GetOriginsCallback> callback(callback_ptr); // All databases are in the temp namespace for now. if (type != quota::kStorageTypeTemporary) { - callback->Run(std::set<GURL>(), type); + callback.Run(std::set<GURL>(), type); return; } - if (origins_for_host_callbacks_.Add(host, callback.release())) { + if (origins_for_host_callbacks_.Add(host, callback)) { scoped_refptr<GetOriginsForHostTask> task( new GetOriginsForHostTask( this, webkit_thread_message_loop_, host, type)); @@ -228,11 +225,12 @@ void IndexedDBQuotaClient::GetOriginsForHost( } } -void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, - quota::StorageType type, - DeletionCallback* callback) { +void IndexedDBQuotaClient::DeleteOriginData( + const GURL& origin, + quota::StorageType type, + const DeletionCallback& callback) { if (type != quota::kStorageTypeTemporary) { - callback->Run(quota::kQuotaErrorNotSupported); + callback.Run(quota::kQuotaErrorNotSupported); return; } scoped_refptr<DeleteOriginTask> task( diff --git a/content/browser/in_process_webkit/indexed_db_quota_client.h b/content/browser/in_process_webkit/indexed_db_quota_client.h index 8b2838e..90f13a2 100644 --- a/content/browser/in_process_webkit/indexed_db_quota_client.h +++ b/content/browser/in_process_webkit/indexed_db_quota_client.h @@ -33,15 +33,15 @@ class IndexedDBQuotaClient : public quota::QuotaClient, virtual void OnQuotaManagerDestroyed() OVERRIDE; virtual void GetOriginUsage(const GURL& origin_url, quota::StorageType type, - GetUsageCallback* callback) OVERRIDE; + const GetUsageCallback& callback) OVERRIDE; virtual void GetOriginsForType(quota::StorageType type, - GetOriginsCallback* callback) OVERRIDE; + const GetOriginsCallback& callback) OVERRIDE; virtual void GetOriginsForHost(quota::StorageType type, const std::string& host, - GetOriginsCallback* callback) OVERRIDE; + const GetOriginsCallback& callback) OVERRIDE; virtual void DeleteOriginData(const GURL& origin, quota::StorageType type, - DeletionCallback* callback) OVERRIDE; + const DeletionCallback& callback) OVERRIDE; private: class HelperTask; class GetOriginUsageTask; @@ -51,17 +51,17 @@ class IndexedDBQuotaClient : public quota::QuotaClient, class DeleteOriginTask; typedef quota::CallbackQueueMap1 - <GetUsageCallback*, + <GetUsageCallback, GURL, // origin int64 > UsageForOriginCallbackMap; typedef quota::CallbackQueue2 - <GetOriginsCallback*, + <GetOriginsCallback, const std::set<GURL>&, quota::StorageType > OriginsForTypeCallbackQueue; typedef quota::CallbackQueueMap2 - <GetOriginsCallback*, + <GetOriginsCallback, std::string, // host const std::set<GURL>&, quota::StorageType diff --git a/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc b/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc index d36f217..0b9d274 100644 --- a/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc +++ b/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc @@ -4,6 +4,7 @@ #include <map> +#include "base/bind.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/memory/scoped_callback_factory.h" @@ -35,7 +36,7 @@ class IndexedDBQuotaClientTest : public testing::Test { kOriginB("http://host:8000"), kOriginOther("http://other"), usage_(0), - callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), message_loop_(MessageLoop::TYPE_IO), webkit_thread_(BrowserThread::WEBKIT, &message_loop_), io_thread_(BrowserThread::IO, &message_loop_) { @@ -64,9 +65,10 @@ class IndexedDBQuotaClientTest : public testing::Test { const GURL& origin, quota::StorageType type) { usage_ = -1; - client->GetOriginUsage(origin, type, - callback_factory_.NewCallback( - &IndexedDBQuotaClientTest::OnGetOriginUsageComplete)); + client->GetOriginUsage( + origin, type, + base::Bind(&IndexedDBQuotaClientTest::OnGetOriginUsageComplete, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); EXPECT_GT(usage_, -1); return usage_; @@ -77,9 +79,10 @@ class IndexedDBQuotaClientTest : public testing::Test { quota::StorageType type) { origins_.clear(); type_ = quota::kStorageTypeTemporary; - client->GetOriginsForType(type, - callback_factory_.NewCallback( - &IndexedDBQuotaClientTest::OnGetOriginsComplete)); + client->GetOriginsForType( + type, + base::Bind(&IndexedDBQuotaClientTest::OnGetOriginsComplete, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); return origins_; } @@ -90,9 +93,10 @@ class IndexedDBQuotaClientTest : public testing::Test { const std::string& host) { origins_.clear(); type_ = quota::kStorageTypeTemporary; - client->GetOriginsForHost(type, host, - callback_factory_.NewCallback( - &IndexedDBQuotaClientTest::OnGetOriginsComplete)); + client->GetOriginsForHost( + type, host, + base::Bind(&IndexedDBQuotaClientTest::OnGetOriginsComplete, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); return origins_; } @@ -100,8 +104,10 @@ class IndexedDBQuotaClientTest : public testing::Test { quota::QuotaStatusCode DeleteOrigin(quota::QuotaClient* client, const GURL& origin_url) { delete_status_ = quota::kQuotaStatusUnknown; - client->DeleteOriginData(origin_url, kTemp, callback_factory_.NewCallback( - &IndexedDBQuotaClientTest::OnDeleteOriginComplete)); + client->DeleteOriginData( + origin_url, kTemp, + base::Bind(&IndexedDBQuotaClientTest::OnDeleteOriginComplete, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); return delete_status_; } @@ -145,7 +151,7 @@ class IndexedDBQuotaClientTest : public testing::Test { std::set<GURL> origins_; quota::StorageType type_; scoped_refptr<IndexedDBContext> idb_context_; - base::ScopedCallbackFactory<IndexedDBQuotaClientTest> callback_factory_; + base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_; MessageLoop message_loop_; BrowserThread webkit_thread_; BrowserThread io_thread_; diff --git a/content/browser/renderer_host/database_message_filter.cc b/content/browser/renderer_host/database_message_filter.cc index ffe68ad..0a36643 100644 --- a/content/browser/renderer_host/database_message_filter.cc +++ b/content/browser/renderer_host/database_message_filter.cc @@ -6,6 +6,7 @@ #include <string> +#include "base/bind.h" #include "base/platform_file.h" #include "base/string_util.h" #include "base/threading/thread.h" @@ -34,32 +35,6 @@ using webkit_database::VfsBackend; namespace { -class MyGetUsageAndQuotaCallback - : public QuotaManager::GetUsageAndQuotaCallback { - public: - MyGetUsageAndQuotaCallback( - DatabaseMessageFilter* sender, IPC::Message* reply_msg) - : sender_(sender), reply_msg_(reply_msg) {} - - virtual void RunWithParams( - const Tuple3<QuotaStatusCode, int64, int64>& params) { - Run(params.a, params.b, params.c); - } - - void Run(QuotaStatusCode status, int64 usage, int64 quota) { - int64 available = 0; - if ((status == quota::kQuotaStatusOk) && (usage < quota)) - available = quota - usage; - DatabaseHostMsg_GetSpaceAvailable::WriteReplyParams( - reply_msg_.get(), available); - sender_->Send(reply_msg_.release()); - } - - private: - scoped_refptr<DatabaseMessageFilter> sender_; - scoped_ptr<IPC::Message> reply_msg_; -}; - const int kNumDeleteRetries = 2; const int kDelayDeleteRetryMs = 100; @@ -293,7 +268,20 @@ void DatabaseMessageFilter::OnDatabaseGetSpaceAvailable( quota_manager->GetUsageAndQuota( DatabaseUtil::GetOriginFromIdentifier(origin_identifier), quota::kStorageTypeTemporary, - new MyGetUsageAndQuotaCallback(this, reply_msg)); + base::Bind(&DatabaseMessageFilter::OnDatabaseGetUsageAndQuota, + this, reply_msg)); +} + +void DatabaseMessageFilter::OnDatabaseGetUsageAndQuota( + IPC::Message* reply_msg, + quota::QuotaStatusCode status, + int64 usage, + int64 quota) { + int64 available = 0; + if ((status == quota::kQuotaStatusOk) && (usage < quota)) + available = quota - usage; + DatabaseHostMsg_GetSpaceAvailable::WriteReplyParams(reply_msg, available); + Send(reply_msg); } void DatabaseMessageFilter::OnDatabaseOpened(const string16& origin_identifier, diff --git a/content/browser/renderer_host/database_message_filter.h b/content/browser/renderer_host/database_message_filter.h index fa6acbb..a87b5d8 100644 --- a/content/browser/renderer_host/database_message_filter.h +++ b/content/browser/renderer_host/database_message_filter.h @@ -11,6 +11,7 @@ #include "content/browser/browser_message_filter.h" #include "webkit/database/database_connections.h" #include "webkit/database/database_tracker.h" +#include "webkit/quota/quota_types.h" class DatabaseMessageFilter : public BrowserMessageFilter, @@ -52,6 +53,10 @@ class DatabaseMessageFilter // Quota message handler (io thread) void OnDatabaseGetSpaceAvailable(const string16& origin_identifier, IPC::Message* reply_msg); + void OnDatabaseGetUsageAndQuota(IPC::Message* reply_msg, + quota::QuotaStatusCode status, + int64 usage, + int64 quota); // Database tracker message handlers (file thread) void OnDatabaseOpened(const string16& origin_identifier, diff --git a/content/browser/renderer_host/quota_dispatcher_host.cc b/content/browser/renderer_host/quota_dispatcher_host.cc index 882a56d..49c5afd 100644 --- a/content/browser/renderer_host/quota_dispatcher_host.cc +++ b/content/browser/renderer_host/quota_dispatcher_host.cc @@ -4,6 +4,7 @@ #include "content/browser/renderer_host/quota_dispatcher_host.h" +#include "base/bind.h" #include "base/memory/scoped_callback_factory.h" #include "content/browser/quota_permission_context.h" #include "content/common/quota_messages.h" @@ -57,13 +58,14 @@ class QuotaDispatcherHost::QueryUsageAndQuotaDispatcher QuotaDispatcherHost* dispatcher_host, int request_id) : RequestDispatcher(dispatcher_host, request_id), - callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} + weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} virtual ~QueryUsageAndQuotaDispatcher() {} void QueryStorageUsageAndQuota(const GURL& origin, StorageType type) { - quota_manager()->GetUsageAndQuota(origin, type, - callback_factory_.NewCallback( - &QueryUsageAndQuotaDispatcher::DidQueryStorageUsageAndQuota)); + quota_manager()->GetUsageAndQuota( + origin, type, + base::Bind(&QueryUsageAndQuotaDispatcher::DidQueryStorageUsageAndQuota, + weak_factory_.GetWeakPtr())); } private: @@ -79,7 +81,7 @@ class QuotaDispatcherHost::QueryUsageAndQuotaDispatcher Completed(); } - base::ScopedCallbackFactory<QueryUsageAndQuotaDispatcher> callback_factory_; + base::WeakPtrFactory<QueryUsageAndQuotaDispatcher> weak_factory_; }; class QuotaDispatcherHost::RequestQuotaDispatcher @@ -100,6 +102,7 @@ class QuotaDispatcherHost::RequestQuotaDispatcher current_quota_(0), requested_quota_(requested_quota), render_view_id_(render_view_id), + weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} virtual ~RequestQuotaDispatcher() {} @@ -109,12 +112,13 @@ class QuotaDispatcherHost::RequestQuotaDispatcher if (type_ == quota::kStorageTypePersistent) { quota_manager()->GetPersistentHostQuota( host_, - callback_factory_.NewCallback(&self_type::DidGetHostQuota)); + base::Bind(&self_type::DidGetHostQuota, + weak_factory_.GetWeakPtr())); } else { quota_manager()->GetUsageAndQuota( origin_, type_, - callback_factory_.NewCallback( - &self_type::DidGetTemporaryUsageAndQuota)); + base::Bind(&self_type::DidGetTemporaryUsageAndQuota, + weak_factory_.GetWeakPtr())); } } @@ -158,7 +162,8 @@ class QuotaDispatcherHost::RequestQuotaDispatcher // Now we're allowed to set the new quota. quota_manager()->SetPersistentHostQuota( host_, requested_quota_, - callback_factory_.NewCallback(&self_type::DidSetHostQuota)); + base::Bind(&self_type::DidSetHostQuota, + weak_factory_.GetWeakPtr())); } void DidSetHostQuota(QuotaStatusCode status, @@ -187,6 +192,7 @@ class QuotaDispatcherHost::RequestQuotaDispatcher int64 current_quota_; const int64 requested_quota_; const int render_view_id_; + base::WeakPtrFactory<self_type> weak_factory_; base::ScopedCallbackFactory<self_type> callback_factory_; }; |