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

Unified Diff: content/child/websocket_message_filter.h

Issue 2000113002: Delegate WebSocket message handlers to the loading task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment Created 4 years, 7 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
« no previous file with comments | « content/child/websocket_dispatcher.cc ('k') | content/child/websocket_message_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..00efbb213aca2c8a8581254d249d1b2d22c5cb20
--- /dev/null
+++ b/content/child/websocket_message_filter.h
@@ -0,0 +1,50 @@
+// 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 "base/memory/weak_ptr.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.
+class WebSocketMessageFilter : public IPC::MessageFilter {
+ public:
+ explicit WebSocketMessageFilter(WebSocketDispatcher* websocket_dispatcher);
+
+ // 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;
+ void OnMessageReceivedOnMainThread(const IPC::Message& message);
+
+ scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_;
+
+ // This actual object is owned by a ChildThreadImpl and is derefed only on the
+ // main thread.
+ base::WeakPtr<WebSocketDispatcher> websocket_dispatcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebSocketMessageFilter);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_
« no previous file with comments | « content/child/websocket_dispatcher.cc ('k') | content/child/websocket_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698