OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_MANAGER_H_ | 5 #ifndef WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_MANAGER_H_ |
6 #define WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_MANAGER_H_ | 6 #define WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_MANAGER_H_ |
7 | 7 |
8 #include <wtf/HashMap.h> | 8 #include <wtf/HashMap.h> |
| 9 #include <wtf/Noncopyable.h> |
9 | 10 |
10 #include "base/basictypes.h" | |
11 #include "base/logging.h" | |
12 #include "v8/include/v8-debug.h" | 11 #include "v8/include/v8-debug.h" |
13 #include "webkit/api/public/WebDevToolsAgent.h" | 12 #include "webkit/api/public/WebDevToolsAgent.h" |
14 | 13 |
15 namespace WebCore { | 14 namespace WebCore { |
16 class PageGroupLoadDeferrer; | 15 class PageGroupLoadDeferrer; |
17 } | 16 } |
18 | 17 |
19 class DebuggerAgentImpl; | 18 class DebuggerAgentImpl; |
20 class DictionaryValue; | 19 class DictionaryValue; |
21 class WebFrameImpl; | 20 class WebFrameImpl; |
22 class WebViewImpl; | 21 class WebViewImpl; |
23 | 22 |
24 // There is single v8 instance per render process. Also there may be several | 23 // There is single v8 instance per render process. Also there may be several |
25 // RenderViews and consequently devtools agents in the process that want to talk | 24 // RenderViews and consequently devtools agents in the process that want to talk |
26 // to the v8 debugger. This class coordinates communication between the debug | 25 // to the v8 debugger. This class coordinates communication between the debug |
27 // agents and v8 debugger. It will set debug output handler as long as at least | 26 // agents and v8 debugger. It will set debug output handler as long as at least |
28 // one debugger agent is attached and remove it when last debugger agent is | 27 // one debugger agent is attached and remove it when last debugger agent is |
29 // detached. When message is received from debugger it will route it to the | 28 // detached. When message is received from debugger it will route it to the |
30 // right debugger agent if there is one otherwise the message will be ignored. | 29 // right debugger agent if there is one otherwise the message will be ignored. |
31 // | 30 // |
32 // v8 may send a message(e.g. exception event) after which it | 31 // v8 may send a message(e.g. exception event) after which it |
33 // would expect some actions from the handler. If there is no appropriate | 32 // would expect some actions from the handler. If there is no appropriate |
34 // debugger agent to handle such messages the manager will perform the action | 33 // debugger agent to handle such messages the manager will perform the action |
35 // itself, otherwise v8 may hang waiting for the action. | 34 // itself, otherwise v8 may hang waiting for the action. |
36 class DebuggerAgentManager { | 35 class DebuggerAgentManager : public Noncopyable { |
37 public: | 36 public: |
38 static void DebugAttach(DebuggerAgentImpl* debugger_agent); | 37 static void DebugAttach(DebuggerAgentImpl* debugger_agent); |
39 static void DebugDetach(DebuggerAgentImpl* debugger_agent); | 38 static void DebugDetach(DebuggerAgentImpl* debugger_agent); |
40 static void DebugBreak(DebuggerAgentImpl* debugger_agent); | 39 static void DebugBreak(DebuggerAgentImpl* debugger_agent); |
41 static void DebugCommand(const WebCore::String& command); | 40 static void DebugCommand(const WebCore::String& command); |
42 | 41 |
43 static void ExecuteDebuggerCommand(const WebCore::String& command, | 42 static void ExecuteDebuggerCommand(const WebCore::String& command, |
44 int caller_id); | 43 int caller_id); |
45 static void SetMessageLoopDispatchHandler( | 44 static void SetMessageLoopDispatchHandler( |
46 WebKit::WebDevToolsAgent::MessageLoopDispatchHandler handler); | 45 WebKit::WebDevToolsAgent::MessageLoopDispatchHandler handler); |
47 | 46 |
48 // Sets |host_id| as the frame context data. This id is used to filter scripts | 47 // Sets |host_id| as the frame context data. This id is used to filter scripts |
49 // related to the inspected page. | 48 // related to the inspected page. |
50 static void SetHostId(WebFrameImpl* webframe, int host_id); | 49 static void SetHostId(WebFrameImpl* webframe, int host_id); |
51 | 50 |
52 static void OnWebViewClosed(WebViewImpl* webview); | 51 static void OnWebViewClosed(WebViewImpl* webview); |
53 | 52 |
54 static void OnNavigate(); | 53 static void OnNavigate(); |
55 | 54 |
56 class UtilityContextScope { | 55 class UtilityContextScope { |
57 public: | 56 public: |
58 UtilityContextScope() { | 57 UtilityContextScope() { |
59 DCHECK(!in_utility_context_); | 58 ASSERT(!in_utility_context_); |
60 in_utility_context_ = true; | 59 in_utility_context_ = true; |
61 } | 60 } |
62 ~UtilityContextScope() { | 61 ~UtilityContextScope() { |
63 if (debug_break_delayed_) { | 62 if (debug_break_delayed_) { |
64 v8::Debug::DebugBreak(); | 63 v8::Debug::DebugBreak(); |
65 debug_break_delayed_ = false; | 64 debug_break_delayed_ = false; |
66 } | 65 } |
67 in_utility_context_ = false; | 66 in_utility_context_ = false; |
68 } | 67 } |
69 private: | 68 private: |
(...skipping 18 matching lines...) Expand all Loading... |
88 | 87 |
89 static WebKit::WebDevToolsAgent::MessageLoopDispatchHandler | 88 static WebKit::WebDevToolsAgent::MessageLoopDispatchHandler |
90 message_loop_dispatch_handler_; | 89 message_loop_dispatch_handler_; |
91 static bool in_host_dispatch_handler_; | 90 static bool in_host_dispatch_handler_; |
92 typedef HashMap<WebViewImpl*, WebCore::PageGroupLoadDeferrer*> | 91 typedef HashMap<WebViewImpl*, WebCore::PageGroupLoadDeferrer*> |
93 DeferrersMap; | 92 DeferrersMap; |
94 static DeferrersMap page_deferrers_; | 93 static DeferrersMap page_deferrers_; |
95 | 94 |
96 static bool in_utility_context_; | 95 static bool in_utility_context_; |
97 static bool debug_break_delayed_; | 96 static bool debug_break_delayed_; |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(DebuggerAgentManager); | |
100 }; | 97 }; |
101 | 98 |
102 #endif // WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_MANAGER_H_ | 99 #endif // WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_MANAGER_H_ |
OLD | NEW |