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 "v8_proxy.h" | 8 #include "v8_proxy.h" |
9 #include <wtf/HashSet.h> | 9 #include <wtf/HashSet.h> |
10 #undef LOG | 10 #undef LOG |
11 | 11 |
12 #include "base/json_reader.h" | 12 #include "base/json_reader.h" |
13 #include "base/json_writer.h" | 13 #include "base/json_writer.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "webkit/glue/devtools/debugger_agent_impl.h" | 16 #include "webkit/glue/devtools/debugger_agent_impl.h" |
17 #include "webkit/glue/devtools/debugger_agent_manager.h" | 17 #include "webkit/glue/devtools/debugger_agent_manager.h" |
18 #include "webkit/glue/webdevtoolsagent_impl.h" | 18 #include "webkit/glue/webdevtoolsagent_impl.h" |
19 | 19 |
20 #if USE(V8) | 20 #if USE(V8) |
21 #include "v8/include/v8-debug.h" | 21 #include "v8/include/v8-debug.h" |
22 #endif | 22 #endif |
23 | 23 |
24 WebDevToolsAgent::MessageLoopDispatchHandler | 24 WebDevToolsAgent::MessageLoopDispatchHandler |
25 DebuggerAgentManager::message_loop_dispatch_handler_ = NULL; | 25 DebuggerAgentManager::message_loop_dispatch_handler_ = NULL; |
26 | 26 |
| 27 // static |
| 28 bool DebuggerAgentManager::in_host_dispatch_handler_ = false; |
| 29 |
27 namespace { | 30 namespace { |
28 | 31 |
29 class CallerIdWrapper : public v8::Debug::ClientData { | 32 class CallerIdWrapper : public v8::Debug::ClientData { |
30 public: | 33 public: |
31 CallerIdWrapper() : caller_is_mananager_(true), caller_id_(0) {} | 34 CallerIdWrapper() : caller_is_mananager_(true), caller_id_(0) {} |
32 explicit CallerIdWrapper(int caller_id) | 35 explicit CallerIdWrapper(int caller_id) |
33 : caller_is_mananager_(false), | 36 : caller_is_mananager_(false), |
34 caller_id_(caller_id) {} | 37 caller_id_(caller_id) {} |
35 ~CallerIdWrapper() {} | 38 ~CallerIdWrapper() {} |
36 bool caller_is_mananager() const { return caller_is_mananager_; } | 39 bool caller_is_mananager() const { return caller_is_mananager_; } |
(...skipping 12 matching lines...) Expand all Loading... |
49 int length, | 52 int length, |
50 v8::Debug::ClientData* data) { | 53 v8::Debug::ClientData* data) { |
51 #if USE(V8) | 54 #if USE(V8) |
52 std::wstring out(reinterpret_cast<const wchar_t*>(message), length); | 55 std::wstring out(reinterpret_cast<const wchar_t*>(message), length); |
53 std::string out_utf8 = WideToUTF8(out); | 56 std::string out_utf8 = WideToUTF8(out); |
54 DebuggerAgentManager::DebuggerOutput(out_utf8, data); | 57 DebuggerAgentManager::DebuggerOutput(out_utf8, data); |
55 #endif | 58 #endif |
56 } | 59 } |
57 | 60 |
58 void DebuggerAgentManager::V8DebugHostDispatchHandler() { | 61 void DebuggerAgentManager::V8DebugHostDispatchHandler() { |
| 62 if (in_host_dispatch_handler_) { |
| 63 return; |
| 64 } |
| 65 in_host_dispatch_handler_ = true; |
59 if (DebuggerAgentManager::message_loop_dispatch_handler_ | 66 if (DebuggerAgentManager::message_loop_dispatch_handler_ |
60 && attached_agents_) { | 67 && attached_agents_) { |
61 DebuggerAgentImpl::RunWithDeferredMessages( | 68 DebuggerAgentImpl::RunWithDeferredMessages( |
62 *attached_agents_, | 69 *attached_agents_, |
63 message_loop_dispatch_handler_); | 70 message_loop_dispatch_handler_); |
64 } | 71 } |
| 72 in_host_dispatch_handler_ = false; |
65 } | 73 } |
66 | 74 |
67 // static | 75 // static |
68 DebuggerAgentManager::AttachedAgentsSet* | 76 DebuggerAgentManager::AttachedAgentsSet* |
69 DebuggerAgentManager::attached_agents_ = NULL; | 77 DebuggerAgentManager::attached_agents_ = NULL; |
70 | 78 |
71 // static | 79 // static |
72 void DebuggerAgentManager::DebugAttach(DebuggerAgentImpl* debugger_agent) { | 80 void DebuggerAgentManager::DebugAttach(DebuggerAgentImpl* debugger_agent) { |
73 #if USE(V8) | 81 #if USE(V8) |
74 if (!attached_agents_) { | 82 if (!attached_agents_) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 DebuggerAgentImpl* DebuggerAgentManager::FindDebuggerAgentForToolsAgent( | 196 DebuggerAgentImpl* DebuggerAgentManager::FindDebuggerAgentForToolsAgent( |
189 int caller_id) { | 197 int caller_id) { |
190 for (AttachedAgentsSet::iterator it = attached_agents_->begin(); | 198 for (AttachedAgentsSet::iterator it = attached_agents_->begin(); |
191 it != attached_agents_->end(); ++it) { | 199 it != attached_agents_->end(); ++it) { |
192 if ((*it)->webdevtools_agent()->host_id() == caller_id) { | 200 if ((*it)->webdevtools_agent()->host_id() == caller_id) { |
193 return *it; | 201 return *it; |
194 } | 202 } |
195 } | 203 } |
196 return NULL; | 204 return NULL; |
197 } | 205 } |
OLD | NEW |