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

Unified Diff: content/browser/in_process_webkit/indexed_db_context.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/in_process_webkit/indexed_db_context.cc
diff --git a/content/browser/in_process_webkit/indexed_db_context.cc b/content/browser/in_process_webkit/indexed_db_context.cc
index 99b0330743c4cde5c10aad3c6f2a427ade68c159..59fc64ae14849029a2b46fe608ed553f2b76fff6 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() {
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_context.h ('k') | content/browser/in_process_webkit/indexed_db_quota_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698