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

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

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

Powered by Google App Engine
This is Rietveld 408576698