Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: content/browser/renderer_host/database_message_filter.cc

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/database_message_filter.cc
diff --git a/content/browser/renderer_host/database_message_filter.cc b/content/browser/renderer_host/database_message_filter.cc
index ffe68add2fb438784c2a018ff2afd12ad2410567..0a3664335be4cc4c23b78147a66105562b34364e 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,
« no previous file with comments | « content/browser/renderer_host/database_message_filter.h ('k') | content/browser/renderer_host/quota_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698