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