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

Side by Side Diff: content/child/websocket_dispatcher.h

Issue 2119973002: Port WebSockets to Mojo IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
6 #define CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
7
8 #include <stdint.h>
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/compiler_specific.h"
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "ipc/ipc_listener.h"
17
18 namespace content {
19
20 class WebSocketBridge;
21
22 // Dispatches WebSocket related messages sent to a child process from the
23 // main browser process. There is one instance per child process. Messages
24 // are dispatched on the main child thread. The ChildThread class
25 // creates an instance of WebSocketDispatcher and delegates calls to it.
26 class WebSocketDispatcher : public IPC::Listener {
27 public:
28 WebSocketDispatcher();
29 ~WebSocketDispatcher() override;
30
31 static bool CanHandleMessage(const IPC::Message& msg);
32
33 // Returns a unique channel id
34 int AddBridge(WebSocketBridge* bridge);
35 void RemoveBridge(int channel_id);
36
37 // IPC::Listener implementation.
38 bool OnMessageReceived(const IPC::Message& msg) override;
39
40 base::WeakPtr<WebSocketDispatcher> GetWeakPtr() {
41 return weak_ptr_factory_.GetWeakPtr();
42 }
43
44 private:
45 WebSocketBridge* GetBridge(int channel_id, uint32_t type);
46
47 std::map<int, WebSocketBridge*> bridges_;
48 int channel_id_max_;
49 base::WeakPtrFactory<WebSocketDispatcher> weak_ptr_factory_;
50
51 DISALLOW_COPY_AND_ASSIGN(WebSocketDispatcher);
52 };
53
54 } // namespace content
55
56 #endif // CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698