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

Side by Side Diff: chrome/renderer/debug_message_handler.cc

Issue 8735: Changed the call to attach the debugger to V8 to run in the renderer thread. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/renderer/debug_message_handler.h" 5 #include "chrome/renderer/debug_message_handler.h"
6 #include "chrome/renderer/render_view.h" 6 #include "chrome/renderer/render_view.h"
7 7
8 //////////////////////////////////////// 8 ////////////////////////////////////////
9 // methods called from the RenderThread 9 // methods called from the RenderThread
10 10
11 DebugMessageHandler::DebugMessageHandler(RenderView* view) : 11 DebugMessageHandler::DebugMessageHandler(RenderView* view) :
12 debugger_(NULL), view_(view), channel_(NULL) { 12 debugger_(NULL), view_(view), channel_(NULL) {
13 view_loop_ = MessageLoop::current(); 13 view_loop_ = MessageLoop::current();
14 view_routing_id_ = view_->routing_id(); 14 view_routing_id_ = view_->routing_id();
15 } 15 }
16 16
17 DebugMessageHandler::~DebugMessageHandler() { 17 DebugMessageHandler::~DebugMessageHandler() {
18 } 18 }
19 19
20 void DebugMessageHandler::EvaluateScriptUrl(const std::wstring& url) { 20 void DebugMessageHandler::EvaluateScriptUrl(const std::wstring& url) {
21 DCHECK(MessageLoop::current() == view_loop_); 21 DCHECK(MessageLoop::current() == view_loop_);
22 // It's possible that this will get cleared out from under us. 22 // It's possible that this will get cleared out from under us.
23 RenderView* view = view_; 23 RenderView* view = view_;
24 if (view) { 24 if (view) {
25 view->EvaluateScriptUrl(L"", url); 25 view->EvaluateScriptUrl(L"", url);
26 } 26 }
27 } 27 }
28 28
29 void DebugMessageHandler::Attach() {
30 DCHECK(MessageLoop::current() == view_loop_);
31 debugger_->Attach();
32 }
33
34
29 /////////////////////////////////////////////// 35 ///////////////////////////////////////////////
30 // all methods below called from the IO thread 36 // all methods below called from the IO thread
31 37
32 void DebugMessageHandler::DebuggerOutput(const std::wstring& out) { 38 void DebugMessageHandler::DebuggerOutput(const std::wstring& out) {
33 channel_->Send(new ViewHostMsg_DebuggerOutput(view_routing_id_, out)); 39 channel_->Send(new ViewHostMsg_DebuggerOutput(view_routing_id_, out));
34 } 40 }
35 41
36 void DebugMessageHandler::OnBreak(bool force) { 42 void DebugMessageHandler::OnBreak(bool force) {
43 // Set the debug break flag in the V8 enging.
Erik does not do reviews 2008/11/05 17:00:13 typo -> engine
37 debugger_->Break(force); 44 debugger_->Break(force);
45
46 // If a forced break has been requested make sure that it will occour by
Erik does not do reviews 2008/11/05 17:00:13 typo: "occur"
47 // running some JavaScript in the renderer.
38 if (force && view_loop_) { 48 if (force && view_loop_) {
39 view_loop_->PostTask(FROM_HERE, NewRunnableMethod( 49 view_loop_->PostTask(FROM_HERE, NewRunnableMethod(
40 this, &DebugMessageHandler::EvaluateScriptUrl, 50 this, &DebugMessageHandler::EvaluateScriptUrl,
41 std::wstring(L"javascript:void(0)"))); 51 std::wstring(L"javascript:void(0)")));
42 } 52 }
43 } 53 }
44 54
45 void DebugMessageHandler::OnAttach() { 55 void DebugMessageHandler::OnAttach() {
46 if (!debugger_) { 56 if (!debugger_) {
47 debugger_ = new Debugger(this); 57 debugger_ = new Debugger(this);
48 } 58 }
49 debugger_->Attach(); 59
60 // Run the actual debugger attach in the renderer as it uses V8 methods which
61 // most run in the V8 thread.
Erik does not do reviews 2008/11/05 17:00:13 most -> must
62 if (view_loop_) {
63 view_loop_->PostTask(FROM_HERE, NewRunnableMethod(
64 this, &DebugMessageHandler::Attach));
65 }
50 } 66 }
51 67
52 void DebugMessageHandler::OnCommand(const std::wstring& cmd) { 68 void DebugMessageHandler::OnCommand(const std::wstring& cmd) {
53 if (!debugger_) { 69 if (!debugger_) {
54 NOTREACHED(); 70 NOTREACHED();
55 std::wstring msg = 71 std::wstring msg =
56 StringPrintf(L"before attach, ignored command (%S)", cmd.c_str()); 72 StringPrintf(L"before attach, ignored command (%S)", cmd.c_str());
57 DebuggerOutput(msg); 73 DebuggerOutput(msg);
58 } else { 74 } else {
59 debugger_->Command(cmd); 75 debugger_->Command(cmd);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // hang forever and never exit. To avoid this, we look for close messages 121 // hang forever and never exit. To avoid this, we look for close messages
106 // and tell the debugger to shutdown. 122 // and tell the debugger to shutdown.
107 IPC_MESSAGE_HANDLER_GENERIC(ViewMsg_Close, 123 IPC_MESSAGE_HANDLER_GENERIC(ViewMsg_Close,
108 if (debugger_) OnDetach(); 124 if (debugger_) OnDetach();
109 handled = false;) 125 handled = false;)
110 IPC_MESSAGE_UNHANDLED(handled = false); 126 IPC_MESSAGE_UNHANDLED(handled = false);
111 IPC_END_MESSAGE_MAP() 127 IPC_END_MESSAGE_MAP()
112 return handled; 128 return handled;
113 } 129 }
114 130
OLDNEW
« chrome/renderer/debug_message_handler.h ('K') | « chrome/renderer/debug_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698