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

Unified Diff: content/child/quota_dispatcher.h

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/child/quota_dispatcher.h
diff --git a/content/child/quota_dispatcher.h b/content/child/quota_dispatcher.h
index a2fbfcc380d0069e98a7aad3f6ff87a8567b1809..6a099f9e5d5ec97148cb812689a5a5522e7b849b 100644
--- a/content/child/quota_dispatcher.h
+++ b/content/child/quota_dispatcher.h
@@ -10,7 +10,8 @@
#include "base/basictypes.h"
#include "base/id_map.h"
-#include "ipc/ipc_listener.h"
+#include "base/memory/ref_counted.h"
+#include "webkit/child/worker_task_runner.h"
#include "webkit/common/quota/quota_types.h"
class GURL;
@@ -25,10 +26,13 @@ class WebStorageQuotaCallbacks;
namespace content {
+class ThreadSafeSender;
+
// Dispatches and sends quota related messages sent to/from a child
// process from/to the main browser process. There is one instance
-// per child process. Messages are dispatched on the main child thread.
-class QuotaDispatcher : public IPC::Listener {
+// per each thread. Thread-specific instance can be obtained by
+// ThreadSpecificInstance().
+class QuotaDispatcher : public webkit_glue::WorkerTaskRunner::Observer {
public:
class Callback {
public:
@@ -38,11 +42,17 @@ class QuotaDispatcher : public IPC::Listener {
virtual void DidFail(quota::QuotaStatusCode status) = 0;
};
- QuotaDispatcher();
+ explicit QuotaDispatcher(ThreadSafeSender* thread_safe_sender);
virtual ~QuotaDispatcher();
- // IPC::Listener implementation.
- virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
+ // |thread_safe_sender| is used if calling this leads to construction.
+ static QuotaDispatcher* ThreadSpecificInstance(
+ ThreadSafeSender* thread_safe_sender);
+
+ // webkit_glue::WorkerTaskRunner::Observer implementation.
+ virtual void OnWorkerRunLoopStopped() OVERRIDE;
+
+ void OnMessageReceived(const IPC::Message& msg);
void QueryStorageUsageAndQuota(const GURL& gurl,
quota::StorageType type,
@@ -59,15 +69,21 @@ class QuotaDispatcher : public IPC::Listener {
private:
// Message handlers.
- void DidQueryStorageUsageAndQuota(int request_id,
+ void DidQueryStorageUsageAndQuota(int ipc_thread_id,
+ int request_id,
int64 current_usage,
int64 current_quota);
- void DidGrantStorageQuota(int request_id,
+ void DidGrantStorageQuota(int ipc_thread_id,
+ int request_id,
int64 granted_quota);
- void DidFail(int request_id, quota::QuotaStatusCode error);
+ void DidFail(int ipc_thread_id,
+ int request_id,
+ quota::QuotaStatusCode error);
IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_;
+ scoped_refptr<ThreadSafeSender> thread_safe_sender_;
+
DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher);
};

Powered by Google App Engine
This is Rietveld 408576698