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

Unified Diff: content/common/quota_dispatcher.cc

Issue 6811022: Add IPC plumbing code for Quota API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments reflected Created 9 years, 8 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
« no previous file with comments | « content/common/quota_dispatcher.h ('k') | content/common/quota_dispatcher_dummy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/quota_dispatcher.cc
diff --git a/content/common/quota_dispatcher.cc b/content/common/quota_dispatcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0ecf1c412be77e43eb8add01081edaf38184f107
--- /dev/null
+++ b/content/common/quota_dispatcher.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/quota_dispatcher.h"
+
+#include "content/common/child_thread.h"
+#include "content/common/quota_messages.h"
+#include "googleurl/src/gurl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallbacks.h"
+
+using WebKit::WebStorageQuotaCallbacks;
+using WebKit::WebStorageQuotaError;
+using WebKit::WebStorageQuotaType;
+
+QuotaDispatcher::QuotaDispatcher() {
+}
+
+QuotaDispatcher::~QuotaDispatcher() {
+ IDMap<WebStorageQuotaCallbacks>::iterator iter(&pending_quota_callbacks_);
+ while (!iter.IsAtEnd()) {
+ iter.GetCurrentValue()->didFail(WebKit::WebStorageQuotaErrorAbort);
+ iter.Advance();
+ }
+}
+
+bool QuotaDispatcher::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(QuotaDispatcher, msg)
+ IPC_MESSAGE_HANDLER(QuotaMsg_DidGrantStorageQuota,
+ DidGrantStorageQuota)
+ IPC_MESSAGE_HANDLER(QuotaMsg_DidQueryStorageUsageAndQuota,
+ DidQueryStorageUsageAndQuota);
+ IPC_MESSAGE_HANDLER(QuotaMsg_DidFail, DidFail);
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void QuotaDispatcher::QueryStorageUsageAndQuota(
+ const GURL& origin_url,
+ WebStorageQuotaType type,
+ WebStorageQuotaCallbacks* callbacks) {
+ DCHECK(callbacks);
+ int request_id = pending_quota_callbacks_.Add(callbacks);
+ ChildThread::current()->Send(new QuotaHostMsg_QueryStorageUsageAndQuota(
+ request_id, origin_url, type));
+}
+
+void QuotaDispatcher::RequestStorageQuota(
+ const GURL& origin_url,
+ WebStorageQuotaType type,
+ unsigned long long requested_size,
+ WebStorageQuotaCallbacks* callbacks) {
+ DCHECK(callbacks);
+ int request_id = pending_quota_callbacks_.Add(callbacks);
+ ChildThread::current()->Send(new QuotaHostMsg_RequestStorageQuota(
+ request_id, origin_url, type, requested_size));
+}
+
+void QuotaDispatcher::DidGrantStorageQuota(
+ int request_id,
+ int64 granted_quota) {
+ WebStorageQuotaCallbacks* callbacks = pending_quota_callbacks_.Lookup(
+ request_id);
+ DCHECK(callbacks);
+ callbacks->didGrantStorageQuota(granted_quota);
+ pending_quota_callbacks_.Remove(request_id);
+}
+
+void QuotaDispatcher::DidQueryStorageUsageAndQuota(
+ int request_id,
+ int64 current_usage,
+ int64 current_quota) {
+ WebStorageQuotaCallbacks* callbacks = pending_quota_callbacks_.Lookup(
+ request_id);
+ DCHECK(callbacks);
+ callbacks->didQueryStorageUsageAndQuota(current_usage, current_quota);
+ pending_quota_callbacks_.Remove(request_id);
+}
+
+void QuotaDispatcher::DidFail(
+ int request_id,
+ WebStorageQuotaError error) {
+ WebStorageQuotaCallbacks* callbacks = pending_quota_callbacks_.Lookup(
+ request_id);
+ DCHECK(callbacks);
+ callbacks->didFail(error);
+ pending_quota_callbacks_.Remove(request_id);
+}
« no previous file with comments | « content/common/quota_dispatcher.h ('k') | content/common/quota_dispatcher_dummy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698