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

Unified Diff: content/child/websocket_dispatcher.h

Issue 2225133002: Revert "Port WebSockets to Mojo IPC" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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_bridge.cc ('k') | content/child/websocket_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/websocket_dispatcher.h
diff --git a/content/child/websocket_dispatcher.h b/content/child/websocket_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..bd2fd50d6de22a6c894b34120fb5e0f6ed0e0144
--- /dev/null
+++ b/content/child/websocket_dispatcher.h
@@ -0,0 +1,56 @@
+// Copyright 2013 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_DISPATCHER_H_
+#define CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
+
+#include <stdint.h>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "ipc/ipc_listener.h"
+
+namespace content {
+
+class WebSocketBridge;
+
+// Dispatches WebSocket related messages sent to a child process from the
+// main browser process. There is one instance per child process. Messages
+// are dispatched on the main child thread. The ChildThread class
+// creates an instance of WebSocketDispatcher and delegates calls to it.
+class WebSocketDispatcher : public IPC::Listener {
+ public:
+ WebSocketDispatcher();
+ ~WebSocketDispatcher() override;
+
+ static bool CanHandleMessage(const IPC::Message& msg);
+
+ // Returns a unique channel id
+ int AddBridge(WebSocketBridge* bridge);
+ void RemoveBridge(int channel_id);
+
+ // IPC::Listener implementation.
+ bool OnMessageReceived(const IPC::Message& msg) override;
+
+ base::WeakPtr<WebSocketDispatcher> GetWeakPtr() {
+ return weak_ptr_factory_.GetWeakPtr();
+ }
+
+ private:
+ WebSocketBridge* GetBridge(int channel_id, uint32_t type);
+
+ std::map<int, WebSocketBridge*> bridges_;
+ int channel_id_max_;
+ base::WeakPtrFactory<WebSocketDispatcher> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebSocketDispatcher);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
« no previous file with comments | « content/child/websocket_bridge.cc ('k') | content/child/websocket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698