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

Unified Diff: content/common/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: repurpose obsolete indexed-db switch to control idb on workers Created 9 years 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/common/indexed_db_message_filter.h
diff --git a/content/common/indexed_db_message_filter.h b/content/common/indexed_db_message_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..aea5c2d74a3b5656da5dc606082ef0c5a91f7380
--- /dev/null
+++ b/content/common/indexed_db_message_filter.h
@@ -0,0 +1,78 @@
+// 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_COMMON_INDEXED_DB_MESSAGE_FILTER_H_
+#define CONTENT_COMMON_INDEXED_DB_MESSAGE_FILTER_H_
+#pragma once
+
+#include <map>
+#include <set>
+
+#include "base/atomic_sequence_num.h"
+#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 GetUniqueCallbackIDWithThreadID();
+ void DidRemoveTransactionID(int32 id);
+ void DidAddTransactionID(int32 id);
+
+ private:
+ friend class MsgForwarderTask;
+ typedef std::map<int, int> CallbackIDToRunLoopMap;
+
+ void LookupAndForwardToThread(const IPC::Message& msg,
+ int32 id,
+ const CallbackIDToRunLoopMap& map);
+ void ForwardToThread(const IPC::Message& msg, int32 thread_id);
+ void ForwardToMainThread(const IPC::Message& msg);
+ void DispatchMessage(const IPC::Message& msg);
+
+ static int ExtractCallbackID(const IPC::Message& msg);
+ static int ExtractThreadID(int callback_id);
+ static int InjectThreadID(int callback_id, int thread_id);
+
+ scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
+ base::ThreadLocalPointer<IndexedDBDispatcher> idb_dispatcher_tls_;
+ base::AtomicSequenceNumber unique_id_;
+ CallbackIDToRunLoopMap transaction_id_to_run_loop_;
+ base::Lock map_lock_;
+
+ class MsgForwarderTask;
+ DISALLOW_COPY_AND_ASSIGN(IndexedDBMessageFilter);
+};
+
+#endif // CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698