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

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

Issue 20015002: Make Platform::queryStorageUsageAndQuota work from worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/quota_dispatcher_host.cc
diff --git a/content/browser/renderer_host/quota_dispatcher_host.cc b/content/browser/renderer_host/quota_dispatcher_host.cc
index b6348203225f49a0aa3f0496f99c755eb4061bb8..707599da489c797c25913b6d62bae12247730626 100644
--- a/content/browser/renderer_host/quota_dispatcher_host.cc
+++ b/content/browser/renderer_host/quota_dispatcher_host.cc
@@ -19,6 +19,10 @@ using quota::StorageType;
namespace content {
+namespace {
+const int kDefaultThreadId = 0;
+}
+
// Created one per request to carry the request's request_id around.
// Dispatches requests from renderer/worker to the QuotaManager and
// sends back the response to the renderer/worker.
@@ -58,8 +62,10 @@ class QuotaDispatcherHost::QueryUsageAndQuotaDispatcher
public:
QueryUsageAndQuotaDispatcher(
QuotaDispatcherHost* dispatcher_host,
+ int ipc_thread_id,
int request_id)
: RequestDispatcher(dispatcher_host, request_id),
+ ipc_thread_id_(ipc_thread_id),
weak_factory_(this) {}
virtual ~QueryUsageAndQuotaDispatcher() {}
@@ -75,14 +81,16 @@ class QuotaDispatcherHost::QueryUsageAndQuotaDispatcher
QuotaStatusCode status, int64 usage, int64 quota) {
DCHECK(dispatcher_host());
if (status != quota::kQuotaStatusOk) {
- dispatcher_host()->Send(new QuotaMsg_DidFail(request_id(), status));
+ dispatcher_host()->Send(new QuotaMsg_DidFail(
+ ipc_thread_id_, request_id(), status));
} else {
dispatcher_host()->Send(new QuotaMsg_DidQueryStorageUsageAndQuota(
- request_id(), usage, quota));
+ ipc_thread_id_, request_id(), usage, quota));
}
Completed();
}
+ int ipc_thread_id_;
base::WeakPtrFactory<QueryUsageAndQuotaDispatcher> weak_factory_;
};
@@ -180,10 +188,11 @@ class QuotaDispatcherHost::RequestQuotaDispatcher
void DidFinish(QuotaStatusCode status, int64 granted_quota) {
DCHECK(dispatcher_host());
if (status != quota::kQuotaStatusOk) {
- dispatcher_host()->Send(new QuotaMsg_DidFail(request_id(), status));
+ dispatcher_host()->Send(
+ new QuotaMsg_DidFail(kDefaultThreadId, request_id(), status));
} else {
dispatcher_host()->Send(new QuotaMsg_DidGrantStorageQuota(
- request_id(), granted_quota));
+ kDefaultThreadId, request_id(), granted_quota));
}
Completed();
}
@@ -223,11 +232,12 @@ bool QuotaDispatcherHost::OnMessageReceived(
QuotaDispatcherHost::~QuotaDispatcherHost() {}
void QuotaDispatcherHost::OnQueryStorageUsageAndQuota(
+ int ipc_thread_id,
int request_id,
const GURL& origin,
StorageType type) {
QueryUsageAndQuotaDispatcher* dispatcher = new QueryUsageAndQuotaDispatcher(
- this, request_id);
+ this, ipc_thread_id, request_id);
dispatcher->QueryStorageUsageAndQuota(origin, type);
}
@@ -239,14 +249,16 @@ void QuotaDispatcherHost::OnRequestStorageQuota(
int64 requested_size) {
if (quota_manager_->IsStorageUnlimited(origin, type)) {
// If the origin is marked 'unlimited' we always just return ok.
- Send(new QuotaMsg_DidGrantStorageQuota(request_id, requested_size));
+ Send(new QuotaMsg_DidGrantStorageQuota(
+ kDefaultThreadId, request_id, requested_size));
return;
}
if (type != quota::kStorageTypeTemporary &&
type != quota::kStorageTypePersistent) {
// Unsupported storage types.
- Send(new QuotaMsg_DidFail(request_id, quota::kQuotaErrorNotSupported));
+ Send(new QuotaMsg_DidFail(
+ kDefaultThreadId, request_id, quota::kQuotaErrorNotSupported));
return;
}

Powered by Google App Engine
This is Rietveld 408576698