OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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_MESSAGE_FILTER_H_ | |
6 #define CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "ipc/message_filter.h" | |
11 | |
12 namespace base { | |
13 class SingleThreadTaskRunner; | |
14 } | |
15 | |
16 namespace content { | |
17 | |
18 class WebSocketDispatcher; | |
19 | |
20 // Delegates IPC messages to a WebSocketDispatcher on the loading task queue | |
21 // instead of the default task queue. | |
22 // | |
23 // Background: When we want to suspend V8 execution, we need to suspend task | |
24 // queues. However, the default task queue can't be suspended because it'd be | |
yhirano
2016/05/25 10:39:52
Is this comment needed?
hajimehoshi
2016/05/25 12:05:02
As we discussed offline, this explanation is in th
| |
25 // dangarous. As WebSocket IPC message dispatching might call V8 functions, we | |
26 // need to delegate this dispatch to another task queue like the loading task | |
27 // queue. | |
28 class WebSocketMessageFilter : public IPC::MessageFilter { | |
29 public: | |
30 WebSocketMessageFilter(WebSocketDispatcher* websocket_dispatcher); | |
kinuko
2016/05/25 09:30:53
nit: explicit
hajimehoshi
2016/05/25 12:05:02
Done.
| |
31 | |
32 // IPC::MessageFilter implementation. | |
33 bool OnMessageReceived(const IPC::Message& message) override; | |
34 | |
35 void SetLoadingTaskRunner( | |
36 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) { | |
37 loading_task_runner_ = loading_task_runner; | |
38 } | |
39 | |
40 private: | |
41 ~WebSocketMessageFilter() override; | |
42 | |
43 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; | |
44 WebSocketDispatcher* websocket_dispatcher_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(WebSocketMessageFilter); | |
47 }; | |
48 | |
49 } // namespace content | |
50 | |
51 #endif // CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ | |
OLD | NEW |