[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / renderer / devtools_agent_filter.h
blob627f7494f0f6125e3ab9a76e578553e023c8c74f
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_
6 #define CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_
8 #include <string>
10 #include "ipc/ipc_channel_proxy.h"
12 class MessageLoop;
13 struct DevToolsMessageData;
15 namespace content {
17 // DevToolsAgentFilter is registered as an IPC filter in order to be able to
18 // dispatch messages while on the IO thread. The reason for that is that while
19 // debugging, Render thread is being held by the v8 and hence no messages
20 // are being dispatched there. While holding the thread in a tight loop,
21 // v8 provides thread-safe Api for controlling debugger. In our case v8's Api
22 // is being used from this communication agent on the IO thread.
23 class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter {
24 public:
25 // There is a single instance of this class instantiated by the RenderThread.
26 DevToolsAgentFilter();
28 static void SendRpcMessage(const DevToolsMessageData& data);
30 // IPC::ChannelProxy::MessageFilter override. Called on IO thread.
31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 protected:
34 virtual ~DevToolsAgentFilter();
36 private:
37 void OnDispatchOnInspectorBackend(const std::string& message);
39 bool message_handled_;
40 MessageLoop* render_thread_loop_;
41 int current_routing_id_;
43 DISALLOW_COPY_AND_ASSIGN(DevToolsAgentFilter);
46 } // namespace content
48 #endif // CONTENT_RENDERER_DEVTOOLS_AGENT_FILTER_H_