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

Unified Diff: content/child/websocket_dispatcher.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: Address on yhirano's review 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_dispatcher.cc
diff --git a/content/child/websocket_dispatcher.cc b/content/child/websocket_dispatcher.cc
index 9fc3370bb65d8bcc1b380761dba11efcf43103f9..9a1243b807fd716033e1ee2336bb20ad7c12e16d 100644
--- a/content/child/websocket_dispatcher.cc
+++ b/content/child/websocket_dispatcher.cc
@@ -19,6 +19,22 @@ WebSocketDispatcher::WebSocketDispatcher() : channel_id_max_(0) {}
WebSocketDispatcher::~WebSocketDispatcher() {}
+bool WebSocketDispatcher::CanHandleMessage(const IPC::Message& msg) {
+ switch (msg.type()) {
+ case WebSocketMsg_AddChannelResponse::ID:
+ case WebSocketMsg_NotifyStartOpeningHandshake::ID:
+ case WebSocketMsg_NotifyFinishOpeningHandshake::ID:
+ case WebSocketMsg_NotifyFailure::ID:
+ case WebSocketMsg_SendFrame::ID:
+ case WebSocketMsg_FlowControl::ID:
+ case WebSocketMsg_DropChannel::ID:
+ case WebSocketMsg_NotifyClosing::ID:
+ return true;
+ default:
+ return false;
+ }
+}
+
int WebSocketDispatcher::AddBridge(WebSocketBridge* bridge) {
++channel_id_max_;
bridges_.insert(std::make_pair(channel_id_max_, bridge));
@@ -35,20 +51,8 @@ void WebSocketDispatcher::RemoveBridge(int channel_id) {
}
bool WebSocketDispatcher::OnMessageReceived(const IPC::Message& msg) {
- switch (msg.type()) {
- case WebSocketMsg_AddChannelResponse::ID:
- case WebSocketMsg_NotifyStartOpeningHandshake::ID:
- case WebSocketMsg_NotifyFinishOpeningHandshake::ID:
- case WebSocketMsg_NotifyFailure::ID:
- case WebSocketMsg_SendFrame::ID:
- case WebSocketMsg_FlowControl::ID:
- case WebSocketMsg_DropChannel::ID:
- case WebSocketMsg_NotifyClosing::ID:
- break;
- default:
- return false;
- }
-
+ if (!CanHandleMessage(msg))
+ return false;
WebSocketBridge* bridge = GetBridge(msg.routing_id(), msg.type());
if (!bridge)
return true;

Powered by Google App Engine
This is Rietveld 408576698