Index: content/child/websocket_message_filter.h |
diff --git a/content/child/websocket_message_filter.h b/content/child/websocket_message_filter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..701fb838e7cca8d7ad0c2b66188ab058de22176c |
--- /dev/null |
+++ b/content/child/websocket_message_filter.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 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_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ |
+#define CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ |
+ |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "ipc/message_filter.h" |
+ |
+namespace base { |
+class SingleThreadTaskRunner; |
+} |
+ |
+namespace content { |
+ |
+class WebSocketDispatcher; |
+ |
+// Delegates IPC messages to a WebSocketDispatcher on the loading task queue |
+// instead of the default task queue. |
+// |
+// Background: When we want to suspend V8 execution, we need to suspend task |
+// queues. However, the default task queue can't be suspended because it'd be |
yhirano
2016/05/25 10:39:52
Is this comment needed?
hajimehoshi
2016/05/25 12:05:02
As we discussed offline, this explanation is in th
|
+// dangarous. As WebSocket IPC message dispatching might call V8 functions, we |
+// need to delegate this dispatch to another task queue like the loading task |
+// queue. |
+class WebSocketMessageFilter : public IPC::MessageFilter { |
+ public: |
+ WebSocketMessageFilter(WebSocketDispatcher* websocket_dispatcher); |
kinuko
2016/05/25 09:30:53
nit: explicit
hajimehoshi
2016/05/25 12:05:02
Done.
|
+ |
+ // IPC::MessageFilter implementation. |
+ bool OnMessageReceived(const IPC::Message& message) override; |
+ |
+ void SetLoadingTaskRunner( |
+ scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) { |
+ loading_task_runner_ = loading_task_runner; |
+ } |
+ |
+ private: |
+ ~WebSocketMessageFilter() override; |
+ |
+ scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; |
+ WebSocketDispatcher* websocket_dispatcher_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebSocketMessageFilter); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ |