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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "Frame.h" | 7 #include "Frame.h" |
8 #include "PageGroupLoadDeferrer.h" | 8 #include "PageGroupLoadDeferrer.h" |
9 #include "V8Proxy.h" | 9 #include "V8Proxy.h" |
10 #include <wtf/HashSet.h> | 10 #include <wtf/HashSet.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 WebDevToolsAgent::MessageLoopDispatchHandler | 23 WebDevToolsAgent::MessageLoopDispatchHandler |
24 DebuggerAgentManager::message_loop_dispatch_handler_ = NULL; | 24 DebuggerAgentManager::message_loop_dispatch_handler_ = NULL; |
25 | 25 |
26 // static | 26 // static |
27 bool DebuggerAgentManager::in_host_dispatch_handler_ = false; | 27 bool DebuggerAgentManager::in_host_dispatch_handler_ = false; |
28 | 28 |
29 // static | 29 // static |
30 DebuggerAgentManager::DeferrersMap DebuggerAgentManager::page_deferrers_; | 30 DebuggerAgentManager::DeferrersMap DebuggerAgentManager::page_deferrers_; |
31 | 31 |
| 32 // static |
| 33 bool DebuggerAgentManager::in_utility_context_ = false; |
| 34 |
| 35 // static |
| 36 bool DebuggerAgentManager::debug_break_delayed_ = false; |
| 37 |
32 namespace { | 38 namespace { |
33 | 39 |
34 class CallerIdWrapper : public v8::Debug::ClientData { | 40 class CallerIdWrapper : public v8::Debug::ClientData { |
35 public: | 41 public: |
36 CallerIdWrapper() : caller_is_mananager_(true), caller_id_(0) {} | 42 CallerIdWrapper() : caller_is_mananager_(true), caller_id_(0) {} |
37 explicit CallerIdWrapper(int caller_id) | 43 explicit CallerIdWrapper(int caller_id) |
38 : caller_is_mananager_(false), | 44 : caller_is_mananager_(false), |
39 caller_id_(caller_id) {} | 45 caller_id_(caller_id) {} |
40 ~CallerIdWrapper() {} | 46 ~CallerIdWrapper() {} |
41 bool caller_is_mananager() const { return caller_is_mananager_; } | 47 bool caller_is_mananager() const { return caller_is_mananager_; } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 SendContinueCommandToV8(); | 156 SendContinueCommandToV8(); |
151 } | 157 } |
152 } | 158 } |
153 } | 159 } |
154 | 160 |
155 // static | 161 // static |
156 void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) { | 162 void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) { |
157 #if USE(V8) | 163 #if USE(V8) |
158 DCHECK(DebuggerAgentForHostId(debugger_agent->webdevtools_agent()->host_id()) | 164 DCHECK(DebuggerAgentForHostId(debugger_agent->webdevtools_agent()->host_id()) |
159 == debugger_agent); | 165 == debugger_agent); |
160 v8::Debug::DebugBreak(); | 166 if (in_utility_context_) { |
| 167 debug_break_delayed_ = true; |
| 168 } else { |
| 169 v8::Debug::DebugBreak(); |
| 170 } |
161 #endif | 171 #endif |
162 } | 172 } |
163 | 173 |
164 // static | 174 // static |
165 void DebuggerAgentManager::OnV8DebugMessage(const v8::Debug::Message& message) { | 175 void DebuggerAgentManager::OnV8DebugMessage(const v8::Debug::Message& message) { |
166 v8::HandleScope scope; | 176 v8::HandleScope scope; |
167 v8::String::Utf8Value value(message.GetJSON()); | 177 v8::String::Utf8Value value(message.GetJSON()); |
168 std::string out(*value, value.length()); | 178 std::string out(*value, value.length()); |
169 | 179 |
170 // If caller_data is not NULL the message is a response to a debugger command. | 180 // If caller_data is not NULL the message is a response to a debugger command. |
(...skipping 23 matching lines...) Expand all Loading... |
194 } | 204 } |
195 | 205 |
196 v8::Handle<v8::Context> context = message.GetEventContext(); | 206 v8::Handle<v8::Context> context = message.GetEventContext(); |
197 // If the context is from one of the inpected tabs it should have its context | 207 // If the context is from one of the inpected tabs it should have its context |
198 // data. | 208 // data. |
199 if (context.IsEmpty()) { | 209 if (context.IsEmpty()) { |
200 // Unknown context, skip the event. | 210 // Unknown context, skip the event. |
201 return; | 211 return; |
202 } | 212 } |
203 | 213 |
204 // If the context is from one of the inpected tabs or injected extension | 214 if (in_utility_context_) { |
205 // scripts it must have host_id in the data field. | 215 if (message.GetEvent() == v8::Break) { |
206 int host_id = WebCore::V8Proxy::contextDebugId(context); | 216 // This may happen when two tabs are being debugged in the same process. |
207 if (host_id != -1) { | 217 // Suppose that first debugger is pauesed on an exception. It will run |
208 DebuggerAgentImpl* agent = DebuggerAgentForHostId(host_id); | 218 // nested MessageLoop which may process Break request from the second |
209 if (agent) { | 219 // debugger. |
210 agent->DebuggerOutput(out); | 220 debug_break_delayed_ = true; |
211 return; | 221 } |
| 222 } else { |
| 223 // If the context is from one of the inpected tabs or injected extension |
| 224 // scripts it must have host_id in the data field. |
| 225 int host_id = WebCore::V8Proxy::contextDebugId(context); |
| 226 if (host_id != -1) { |
| 227 DebuggerAgentImpl* agent = DebuggerAgentForHostId(host_id); |
| 228 if (agent) { |
| 229 agent->DebuggerOutput(out); |
| 230 return; |
| 231 } |
212 } | 232 } |
213 } | 233 } |
214 | 234 |
215 if (!message.WillStartRunning()) { | 235 if (!message.WillStartRunning()) { |
216 // Autocontinue execution on break and exception events if there is no | 236 // Autocontinue execution on break and exception events if there is no |
217 // handler. | 237 // handler. |
218 SendContinueCommandToV8(); | 238 SendContinueCommandToV8(); |
219 } | 239 } |
220 } | 240 } |
221 | 241 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 return NULL; | 313 return NULL; |
294 } | 314 } |
295 | 315 |
296 // static | 316 // static |
297 DebuggerAgentImpl* DebuggerAgentManager::DebuggerAgentForHostId(int host_id) { | 317 DebuggerAgentImpl* DebuggerAgentManager::DebuggerAgentForHostId(int host_id) { |
298 if (!attached_agents_map_) { | 318 if (!attached_agents_map_) { |
299 return NULL; | 319 return NULL; |
300 } | 320 } |
301 return attached_agents_map_->get(host_id); | 321 return attached_agents_map_->get(host_id); |
302 } | 322 } |
OLD | NEW |