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_ |