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

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: 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.h ('k') | content/child/websocket_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/websocket_dispatcher.cc
diff --git a/content/child/websocket_dispatcher.cc b/content/child/websocket_dispatcher.cc
index 9fc3370bb65d8bcc1b380761dba11efcf43103f9..13535eb51afe8602772eae28c6e901608980210d 100644
--- a/content/child/websocket_dispatcher.cc
+++ b/content/child/websocket_dispatcher.cc
@@ -15,10 +15,28 @@
namespace content {
-WebSocketDispatcher::WebSocketDispatcher() : channel_id_max_(0) {}
+WebSocketDispatcher::WebSocketDispatcher()
+ : channel_id_max_(0),
+ weak_ptr_factory_(this) {}
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 +53,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;
« no previous file with comments | « content/child/websocket_dispatcher.h ('k') | content/child/websocket_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698