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

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 comments 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
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..9f2b52ab9c058559081f4ad29d0d8db449431dd5
--- /dev/null
+++ b/content/child/websocket_message_filter.cc
@@ -0,0 +1,30 @@
+// 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) {}
+
+WebSocketMessageFilter::~WebSocketMessageFilter() {}
+
+bool WebSocketMessageFilter::OnMessageReceived(const IPC::Message& message) {
yhirano 2016/05/25 10:39:52 Does this function run on the IO thread? If so, ca
yhirano 2016/05/25 11:34:52 Hmm, it seems there is no easy way to check that.
+ if (!websocket_dispatcher_->CanHandleMessage(message))
+ return false;
+ loading_task_runner_->PostTask(FROM_HERE, base::Bind(
+ base::IgnoreResult(&WebSocketDispatcher::OnMessageReceived),
+ base::Unretained(websocket_dispatcher_),
kinuko 2016/05/25 09:30:53 It's not obvious who guarantees websocket_dispatch
hajimehoshi 2016/05/25 12:05:02 IIUC websocket_dispatcher_ is owned by a RenderThr
+ message));
+ return true;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698