OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_RENDERER_DEVTOOLS_AGENT_FILTER_H_ | 5 #ifndef CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_ |
6 #define CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_ | 6 #define CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ipc/ipc_channel_proxy.h" | 10 #include "ipc/ipc_channel_proxy.h" |
11 | 11 |
12 class MessageLoop; | 12 class MessageLoop; |
13 struct DevToolsMessageData; | 13 struct DevToolsMessageData; |
14 | 14 |
| 15 namespace content { |
| 16 |
15 // DevToolsAgentFilter is registered as an IPC filter in order to be able to | 17 // DevToolsAgentFilter is registered as an IPC filter in order to be able to |
16 // dispatch messages while on the IO thread. The reason for that is that while | 18 // dispatch messages while on the IO thread. The reason for that is that while |
17 // debugging, Render thread is being held by the v8 and hence no messages | 19 // debugging, Render thread is being held by the v8 and hence no messages |
18 // are being dispatched there. While holding the thread in a tight loop, | 20 // are being dispatched there. While holding the thread in a tight loop, |
19 // v8 provides thread-safe Api for controlling debugger. In our case v8's Api | 21 // v8 provides thread-safe Api for controlling debugger. In our case v8's Api |
20 // is being used from this communication agent on the IO thread. | 22 // is being used from this communication agent on the IO thread. |
21 class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter { | 23 class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter { |
22 public: | 24 public: |
23 // There is a single instance of this class instantiated by the RenderThread. | 25 // There is a single instance of this class instantiated by the RenderThread. |
24 DevToolsAgentFilter(); | 26 DevToolsAgentFilter(); |
25 | 27 |
26 static void SendRpcMessage(const DevToolsMessageData& data); | 28 static void SendRpcMessage(const DevToolsMessageData& data); |
27 | 29 |
28 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. | 30 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. |
29 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
30 | 32 |
31 protected: | 33 protected: |
32 virtual ~DevToolsAgentFilter(); | 34 virtual ~DevToolsAgentFilter(); |
33 | 35 |
34 private: | 36 private: |
35 void OnDispatchOnInspectorBackend(const std::string& message); | 37 void OnDispatchOnInspectorBackend(const std::string& message); |
36 | 38 |
37 bool message_handled_; | 39 bool message_handled_; |
38 MessageLoop* render_thread_loop_; | 40 MessageLoop* render_thread_loop_; |
39 int current_routing_id_; | 41 int current_routing_id_; |
40 | 42 |
41 DISALLOW_COPY_AND_ASSIGN(DevToolsAgentFilter); | 43 DISALLOW_COPY_AND_ASSIGN(DevToolsAgentFilter); |
42 }; | 44 }; |
43 | 45 |
| 46 } // namespace content |
| 47 |
44 #endif // CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_ | 48 #endif // CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_ |
OLD | NEW |