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

Unified Diff: content/renderer/indexed_db_message_filter.h

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: inject thread ids into ipcs Created 9 years, 1 month 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/renderer/indexed_db_message_filter.h
diff --git a/content/renderer/indexed_db_message_filter.h b/content/renderer/indexed_db_message_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f68f053f0b4dd35af0ad6f2612c86d70dd1e360
--- /dev/null
+++ b/content/renderer/indexed_db_message_filter.h
@@ -0,0 +1,84 @@
+// 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.
+
+#ifndef CONTENT_RENDERER_INDEXED_DB_MESSAGE_FILTER_H_
+#define CONTENT_RENDERER_INDEXED_DB_MESSAGE_FILTER_H_
+#pragma once
+
+#include <map>
+#include <set>
+
+#include "base/nullable_string16.h"
+#include "base/threading/thread_local.h"
+#include "content/common/worker_task_runner.h"
+#include "ipc/ipc_channel_proxy.h"
+
+class IndexedDBDispatcher;
+class IndexedDBKey;
+
+namespace content {
+class SerializedScriptValue;
+}
+
+namespace WebKit {
+class WebIDBCallbacks;
+class WebIDBDatabaseCallbacks;
+class WebIDBTransactionCallbacks;
+class WebWorkerRunLoop;
+}
+
+class IndexedDBMessageFilter : public IPC::ChannelProxy::MessageFilter,
+ public WorkerTaskRunner::Observer {
+ public:
+ IndexedDBMessageFilter();
+ virtual ~IndexedDBMessageFilter();
+
+ // IPC::Channel::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
+
+ // This returns the dispatcher associated with the current WebWorkerRunLoop,
+ // if being run from a worker.
+ IndexedDBDispatcher* thread_specific_idb_dispatcher();
+
+ // WorkerTaskRunner::Observer implementation.
+ virtual void onLoopRegistered() OVERRIDE;
+ virtual void onLoopUnregistered() OVERRIDE;
+
+ int GetUniqueID();
+ void RemoveForType(int32 id, WebKit::WebIDBCallbacks* callbacks);
+ void RemoveForType(int32 id, WebKit::WebIDBTransactionCallbacks* callbacks);
+ void RemoveForType(int32 id, WebKit::WebIDBDatabaseCallbacks* callbacks);
+ void NotifyAddWithIDForType(int32 id,
+ WebKit::WebIDBTransactionCallbacks* callbacks);
+ void NotifyAddWithIDForType(int32 id,
+ WebKit::WebIDBDatabaseCallbacks* callbacks);
+
+ private:
+
+ int InjectThreadID(int);
+ void DispatchMessage(const IPC::Message& msg);
+ int current_worker_id();
+ int current();
+ void ForwardToMainThread(const IPC::Message& msg);
+ scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
+
+ base::ThreadLocalPointer<IndexedDBDispatcher> idb_dispatcher_tls_;
+
+ int unique_id_ = 0;
+ base::Lock id_lock_;
+
+ typedef std::map<int, int> IDToRunLoopMap;
+ IDToRunLoopMap database_id_to_run_loop_;
+ IDToRunLoopMap transaction_id_to_run_loop_;
+ void RemoveFromMap(int32 id, IDToRunLoopMap*);
+ base::Lock map_lock_;
+
+ void ForwardToThread(const IPC::Message& msg, int32 id,
+ const IDToRunLoopMap& map);
+ void ForwardToThread(const IPC::Message& msg, int32 thread_id);
+
+ DISALLOW_COPY_AND_ASSIGN(IndexedDBMessageFilter);
+};
+
+#endif // CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698