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 RenderView and provides Glue's |
Charlie Reis
2015/03/24 17:25:13
Let's update this comment.
dgozman
2015/03/25 16:25:50
Done.
| |
26 // agents with the communication capabilities. All messages from/to Glue's | 23 // agents with the communication capabilities. All messages from/to Glue's |
27 // agents infrastructure are flowing through this communication agent. | 24 // agents infrastructure are flowing through this communication agent. |
28 // There is a corresponding DevToolsClient object on the client side. | 25 // There is a corresponding DevToolsClient object on the client side. |
29 class DevToolsAgent : public RenderFrameObserver, | 26 class DevToolsAgent : public RenderFrameObserver, |
30 public blink::WebDevToolsAgentClient { | 27 public blink::WebDevToolsAgentClient { |
31 public: | 28 public: |
32 explicit DevToolsAgent(RenderFrame* main_render_frame); | 29 explicit DevToolsAgent(RenderFrameImpl* frame); |
33 ~DevToolsAgent() override; | 30 ~DevToolsAgent() override; |
34 | 31 |
35 // Returns agent instance for its routing id. | 32 // Returns agent instance for its routing id. |
36 static DevToolsAgent* FromRoutingId(int routing_id); | 33 static DevToolsAgent* FromRoutingId(int routing_id); |
37 | 34 |
38 static void SendChunkedProtocolMessage( | 35 static void SendChunkedProtocolMessage( |
39 IPC::Sender* sender, | 36 IPC::Sender* sender, |
40 int routing_id, | 37 int routing_id, |
41 int call_id, | 38 int call_id, |
42 const std::string& message, | 39 const std::string& message, |
43 const std::string& post_state); | 40 const std::string& post_state); |
44 | 41 |
45 blink::WebDevToolsAgent* GetWebAgent(); | 42 blink::WebDevToolsAgent* GetWebAgent(); |
46 | 43 |
47 bool IsAttached(); | 44 bool IsAttached(); |
48 | 45 |
49 private: | 46 private: |
50 // RenderView::Observer implementation. | 47 // RenderView::Observer implementation. |
Charlie Reis
2015/03/24 17:25:13
nit: Update comment.
dgozman
2015/03/25 16:25:50
Done.
| |
51 bool OnMessageReceived(const IPC::Message& message) override; | 48 bool OnMessageReceived(const IPC::Message& message) override; |
52 | 49 |
53 // WebDevToolsAgentClient implementation | 50 // WebDevToolsAgentClient implementation |
54 void sendProtocolMessage(int call_id, | 51 void sendProtocolMessage(int call_id, |
55 const blink::WebString& response, | 52 const blink::WebString& response, |
56 const blink::WebString& state) override; | 53 const blink::WebString& state) override; |
57 long processId() override; | |
58 int debuggerId() override; | |
59 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* | 54 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* |
60 createClientMessageLoop() override; | 55 createClientMessageLoop() override; |
61 void willEnterDebugLoop() override; | 56 void willEnterDebugLoop() override; |
62 void didExitDebugLoop() override; | 57 void didExitDebugLoop() override; |
63 | 58 |
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; | 59 void enableTracing(const blink::WebString& category_filter) override; |
73 void disableTracing() override; | 60 void disableTracing() override; |
74 | 61 |
75 void OnAttach(const std::string& host_id); | 62 void OnAttach(const std::string& host_id); |
76 void OnReattach(const std::string& host_id, | 63 void OnReattach(const std::string& host_id, |
77 const std::string& agent_state); | 64 const std::string& agent_state); |
78 void OnDetach(); | 65 void OnDetach(); |
79 void OnDispatchOnInspectorBackend(const std::string& message); | 66 void OnDispatchOnInspectorBackend(const std::string& message); |
80 void OnInspectElement(const std::string& host_id, int x, int y); | 67 void OnInspectElement(const std::string& host_id, int x, int y); |
81 void OnAddMessageToConsole(ConsoleMessageLevel level, | 68 void OnAddMessageToConsole(ConsoleMessageLevel level, |
82 const std::string& message); | 69 const std::string& message); |
83 void ContinueProgram(); | 70 void ContinueProgram(); |
84 void OnSetupDevToolsClient(); | 71 void OnSetupDevToolsClient(); |
85 | 72 |
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_; | 73 bool is_attached_; |
101 bool is_devtools_client_; | 74 bool is_devtools_client_; |
102 bool paused_in_mouse_move_; | 75 bool paused_in_mouse_move_; |
103 RenderFrame* main_render_frame_; | 76 RenderFrameImpl* frame_; |
104 | |
105 static base::subtle::AtomicWord /* TraceEventCallback */ event_callback_; | |
106 | 77 |
107 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); | 78 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); |
108 }; | 79 }; |
109 | 80 |
110 } // namespace content | 81 } // namespace content |
111 | 82 |
112 #endif // CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ | 83 #endif // CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ |
OLD | NEW |