ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / renderer / devtools / devtools_agent.h
blob8e0502fd96e90acf3f9d79df6319b274d992158a
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_DEVTOOLS_AGENT_H_
6 #define CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_
8 #include <string>
10 #include "base/atomicops.h"
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "content/public/common/console_message_level.h"
14 #include "content/public/renderer/render_frame_observer.h"
15 #include "third_party/WebKit/public/web/WebDevToolsAgentClient.h"
17 namespace blink {
18 class WebDevToolsAgent;
21 namespace content {
23 class RenderViewImpl;
25 // DevToolsAgent belongs to the inspectable RenderView and provides Glue's
26 // agents with the communication capabilities. All messages from/to Glue's
27 // agents infrastructure are flowing through this communication agent.
28 // There is a corresponding DevToolsClient object on the client side.
29 class DevToolsAgent : public RenderFrameObserver,
30 public blink::WebDevToolsAgentClient {
31 public:
32 explicit DevToolsAgent(RenderFrame* main_render_frame);
33 ~DevToolsAgent() override;
35 // Returns agent instance for its routing id.
36 static DevToolsAgent* FromRoutingId(int routing_id);
38 static void SendChunkedProtocolMessage(
39 IPC::Sender* sender,
40 int routing_id,
41 int call_id,
42 const std::string& message,
43 const std::string& post_state);
45 blink::WebDevToolsAgent* GetWebAgent();
47 bool IsAttached();
49 private:
50 // RenderView::Observer implementation.
51 bool OnMessageReceived(const IPC::Message& message) override;
53 // WebDevToolsAgentClient implementation
54 void sendProtocolMessage(int call_id,
55 const blink::WebString& response,
56 const blink::WebString& state) override;
57 long processId() override;
58 int debuggerId() override;
59 blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
60 createClientMessageLoop() override;
61 void willEnterDebugLoop() override;
62 void didExitDebugLoop() override;
64 typedef void (*TraceEventCallback)(
65 char phase, const unsigned char*, const char* name, unsigned long long id,
66 int numArgs, const char* const* argNames, const unsigned char* argTypes,
67 const unsigned long long* argValues,
68 unsigned char flags, double timestamp);
69 void resetTraceEventCallback() override;
70 void setTraceEventCallback(const blink::WebString& category_filter,
71 TraceEventCallback cb) override;
72 void enableTracing(const blink::WebString& category_filter) override;
73 void disableTracing() override;
75 void enableDeviceEmulation(
76 const blink::WebDeviceEmulationParams& params) override;
77 void disableDeviceEmulation() override;
79 void OnAttach(const std::string& host_id);
80 void OnReattach(const std::string& host_id,
81 const std::string& agent_state);
82 void OnDetach();
83 void OnDispatchOnInspectorBackend(const std::string& message);
84 void OnInspectElement(const std::string& host_id, int x, int y);
85 void OnAddMessageToConsole(ConsoleMessageLevel level,
86 const std::string& message);
87 void ContinueProgram();
88 void OnSetupDevToolsClient();
90 RenderViewImpl* GetRenderViewImpl();
92 static void TraceEventCallbackWrapper(
93 base::TimeTicks timestamp,
94 char phase,
95 const unsigned char* category_group_enabled,
96 const char* name,
97 unsigned long long id,
98 int num_args,
99 const char* const arg_names[],
100 const unsigned char arg_types[],
101 const unsigned long long arg_values[],
102 unsigned char flags);
104 bool is_attached_;
105 bool is_devtools_client_;
106 bool paused_in_mouse_move_;
107 RenderFrame* main_render_frame_;
109 static base::subtle::AtomicWord /* TraceEventCallback */ event_callback_;
111 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent);
114 } // namespace content
116 #endif // CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_