Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: webkit/glue/devtools/debugger_agent_manager.cc

Issue 264077: Convert devtools interfaces over to using WebString.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/devtools/debugger_agent_manager.h ('k') | webkit/glue/devtools/devtools_rpc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // Note that we do not empty handlers while in dispatch - we schedule 135 // Note that we do not empty handlers while in dispatch - we schedule
136 // continue and do removal once we are out of the dispatch. Also there is 136 // continue and do removal once we are out of the dispatch. Also there is
137 // no need to send continue command in this case since removing message 137 // no need to send continue command in this case since removing message
138 // handler will cause debugger unload and all breakpoints will be cleared. 138 // handler will cause debugger unload and all breakpoints will be cleared.
139 if (!in_host_dispatch_handler_) { 139 if (!in_host_dispatch_handler_) {
140 v8::Debug::SetMessageHandler2(NULL); 140 v8::Debug::SetMessageHandler2(NULL);
141 v8::Debug::SetHostDispatchHandler(NULL); 141 v8::Debug::SetHostDispatchHandler(NULL);
142 } 142 }
143 } else { 143 } else {
144 // Remove all breakpoints set by the agent. 144 // Remove all breakpoints set by the agent.
145 std::wstring clear_breakpoint_group_cmd(StringPrintf( 145 String clear_breakpoint_group_cmd = String::format(
146 L"{\"seq\":1,\"type\":\"request\",\"command\":\"clearbreakpointgroup\"," 146 "{\"seq\":1,\"type\":\"request\",\"command\":\"clearbreakpointgroup\","
147 L"\"arguments\":{\"groupId\":%d}}", 147 "\"arguments\":{\"groupId\":%d}}",
148 host_id)); 148 host_id);
149 SendCommandToV8(WideToUTF16(clear_breakpoint_group_cmd), 149 SendCommandToV8(clear_breakpoint_group_cmd, new CallerIdWrapper());
150 new CallerIdWrapper());
151 150
152 if (is_on_breakpoint) { 151 if (is_on_breakpoint) {
153 // Force continue if detach happened in nessted message loop while 152 // Force continue if detach happened in nessted message loop while
154 // debugger was paused on a breakpoint(as long as there are other 153 // debugger was paused on a breakpoint(as long as there are other
155 // attached agents v8 will wait for explicit'continue' message). 154 // attached agents v8 will wait for explicit'continue' message).
156 SendContinueCommandToV8(); 155 SendContinueCommandToV8();
157 } 156 }
158 } 157 }
159 } 158 }
160 159
161 // static 160 // static
162 void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) { 161 void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) {
163 #if USE(V8) 162 #if USE(V8)
164 DCHECK(DebuggerAgentForHostId(debugger_agent->webdevtools_agent()->host_id()) 163 DCHECK(DebuggerAgentForHostId(debugger_agent->webdevtools_agent()->host_id())
165 == debugger_agent); 164 == debugger_agent);
166 if (in_utility_context_) { 165 if (in_utility_context_) {
167 debug_break_delayed_ = true; 166 debug_break_delayed_ = true;
168 } else { 167 } else {
169 v8::Debug::DebugBreak(); 168 v8::Debug::DebugBreak();
170 } 169 }
171 #endif 170 #endif
172 } 171 }
173 172
174 // static 173 // static
175 void DebuggerAgentManager::OnV8DebugMessage(const v8::Debug::Message& message) { 174 void DebuggerAgentManager::OnV8DebugMessage(const v8::Debug::Message& message) {
176 v8::HandleScope scope; 175 v8::HandleScope scope;
177 v8::String::Utf8Value value(message.GetJSON()); 176 v8::String::Value value(message.GetJSON());
178 std::string out(*value, value.length()); 177 String out(reinterpret_cast<const UChar*>(*value), value.length());
179 178
180 // If caller_data is not NULL the message is a response to a debugger command. 179 // If caller_data is not NULL the message is a response to a debugger command.
181 if (v8::Debug::ClientData* caller_data = message.GetClientData()) { 180 if (v8::Debug::ClientData* caller_data = message.GetClientData()) {
182 CallerIdWrapper* wrapper = static_cast<CallerIdWrapper*>(caller_data); 181 CallerIdWrapper* wrapper = static_cast<CallerIdWrapper*>(caller_data);
183 if (wrapper->caller_is_mananager()) { 182 if (wrapper->caller_is_mananager()) {
184 // Just ignore messages sent by this manager. 183 // Just ignore messages sent by this manager.
185 return; 184 return;
186 } 185 }
187 DebuggerAgentImpl* debugger_agent = 186 DebuggerAgentImpl* debugger_agent =
188 DebuggerAgentForHostId(wrapper->caller_id()); 187 DebuggerAgentForHostId(wrapper->caller_id());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 231
233 if (!message.WillStartRunning()) { 232 if (!message.WillStartRunning()) {
234 // Autocontinue execution on break and exception events if there is no 233 // Autocontinue execution on break and exception events if there is no
235 // handler. 234 // handler.
236 SendContinueCommandToV8(); 235 SendContinueCommandToV8();
237 } 236 }
238 } 237 }
239 238
240 // static 239 // static
241 void DebuggerAgentManager::ExecuteDebuggerCommand( 240 void DebuggerAgentManager::ExecuteDebuggerCommand(
242 const std::string& command, 241 const String& command,
243 int caller_id) { 242 int caller_id) {
244 SendCommandToV8(UTF8ToUTF16(command), new CallerIdWrapper(caller_id)); 243 SendCommandToV8(command, new CallerIdWrapper(caller_id));
245 } 244 }
246 245
247 // static 246 // static
248 void DebuggerAgentManager::SetMessageLoopDispatchHandler( 247 void DebuggerAgentManager::SetMessageLoopDispatchHandler(
249 WebDevToolsAgent::MessageLoopDispatchHandler handler) { 248 WebDevToolsAgent::MessageLoopDispatchHandler handler) {
250 message_loop_dispatch_handler_ = handler; 249 message_loop_dispatch_handler_ = handler;
251 } 250 }
252 251
253 // static 252 // static
254 void DebuggerAgentManager::SetHostId(WebFrameImpl* webframe, int host_id) { 253 void DebuggerAgentManager::SetHostId(WebFrameImpl* webframe, int host_id) {
(...skipping 13 matching lines...) Expand all
268 } 267 }
269 268
270 // static 269 // static
271 void DebuggerAgentManager::OnNavigate() { 270 void DebuggerAgentManager::OnNavigate() {
272 if (in_host_dispatch_handler_) { 271 if (in_host_dispatch_handler_) {
273 DebuggerAgentManager::SendContinueCommandToV8(); 272 DebuggerAgentManager::SendContinueCommandToV8();
274 } 273 }
275 } 274 }
276 275
277 // static 276 // static
278 void DebuggerAgentManager::SendCommandToV8(const string16& cmd, 277 void DebuggerAgentManager::SendCommandToV8(const String& cmd,
279 v8::Debug::ClientData* data) { 278 v8::Debug::ClientData* data) {
280 #if USE(V8) 279 #if USE(V8)
281 v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.data()), 280 v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.characters()),
282 cmd.length(), 281 cmd.length(),
283 data); 282 data);
284 #endif 283 #endif
285 } 284 }
286 285
287 void DebuggerAgentManager::SendContinueCommandToV8() { 286 void DebuggerAgentManager::SendContinueCommandToV8() {
288 std::wstring continue_cmd( 287 String continue_cmd(
289 L"{\"seq\":1,\"type\":\"request\",\"command\":\"continue\"}"); 288 "{\"seq\":1,\"type\":\"request\",\"command\":\"continue\"}");
290 SendCommandToV8(WideToUTF16(continue_cmd), new CallerIdWrapper()); 289 SendCommandToV8(continue_cmd, new CallerIdWrapper());
291 } 290 }
292 291
293 // static 292 // static
294 DebuggerAgentImpl* DebuggerAgentManager::FindAgentForCurrentV8Context() { 293 DebuggerAgentImpl* DebuggerAgentManager::FindAgentForCurrentV8Context() {
295 if (!attached_agents_map_) { 294 if (!attached_agents_map_) {
296 return NULL; 295 return NULL;
297 } 296 }
298 DCHECK(!attached_agents_map_->isEmpty()); 297 DCHECK(!attached_agents_map_->isEmpty());
299 298
300 WebCore::Frame* frame = WebCore::V8Proxy::retrieveFrameForEnteredContext(); 299 WebCore::Frame* frame = WebCore::V8Proxy::retrieveFrameForEnteredContext();
(...skipping 10 matching lines...) Expand all
311 return NULL; 310 return NULL;
312 } 311 }
313 312
314 // static 313 // static
315 DebuggerAgentImpl* DebuggerAgentManager::DebuggerAgentForHostId(int host_id) { 314 DebuggerAgentImpl* DebuggerAgentManager::DebuggerAgentForHostId(int host_id) {
316 if (!attached_agents_map_) { 315 if (!attached_agents_map_) {
317 return NULL; 316 return NULL;
318 } 317 }
319 return attached_agents_map_->get(host_id); 318 return attached_agents_map_->get(host_id);
320 } 319 }
OLDNEW
« no previous file with comments | « webkit/glue/devtools/debugger_agent_manager.h ('k') | webkit/glue/devtools/devtools_rpc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698