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

Unified Diff: content/child/websocket_message_filter.cc

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_message_filter.h ('k') | content/content_child.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/websocket_message_filter.cc
diff --git a/content/child/websocket_message_filter.cc b/content/child/websocket_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b2e54c08f96b38eb027b9a7d8ea504fcdfdd5315
--- /dev/null
+++ b/content/child/websocket_message_filter.cc
@@ -0,0 +1,36 @@
+// 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.
+
+#include "content/child/websocket_message_filter.h"
+
+#include "base/bind.h"
+#include "base/single_thread_task_runner.h"
+#include "content/child/websocket_dispatcher.h"
+#include "ipc/ipc_message.h"
+
+namespace content {
+
+WebSocketMessageFilter::WebSocketMessageFilter(
+ WebSocketDispatcher* websocket_dispatcher)
+ : websocket_dispatcher_(websocket_dispatcher->GetWeakPtr()) {}
+
+WebSocketMessageFilter::~WebSocketMessageFilter() {}
+
+bool WebSocketMessageFilter::OnMessageReceived(const IPC::Message& message) {
+ if (!WebSocketDispatcher::CanHandleMessage(message))
+ return false;
+ loading_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &WebSocketMessageFilter::OnMessageReceivedOnMainThread,
+ this, message));
+ return true;
+}
+
+void WebSocketMessageFilter::OnMessageReceivedOnMainThread(
+ const IPC::Message& message) {
+ if (!websocket_dispatcher_.get())
+ return;
+ websocket_dispatcher_->OnMessageReceived(message);
+}
+
+} // namespace content
« no previous file with comments | « content/child/websocket_message_filter.h ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698