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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.cpp

Issue 1866213002: [DevTools] Move inspect from Inspector to Runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inspector-connection
Patch Set: inspectRequested Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/v8_inspector/InjectedScriptHost.h" 31 #include "platform/v8_inspector/InjectedScriptHost.h"
32 32
33 #include "platform/inspector_protocol/String16.h" 33 #include "platform/inspector_protocol/String16.h"
34 #include "platform/inspector_protocol/Values.h" 34 #include "platform/inspector_protocol/Values.h"
35 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 35 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
36 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 36 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
37 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
37 #include "platform/v8_inspector/public/V8Debugger.h" 38 #include "platform/v8_inspector/public/V8Debugger.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 PassOwnPtr<InjectedScriptHost> InjectedScriptHost::create(V8DebuggerImpl* debugg er, V8InspectorSessionImpl* session) 42 PassOwnPtr<InjectedScriptHost> InjectedScriptHost::create(V8DebuggerImpl* debugg er, V8InspectorSessionImpl* session)
42 { 43 {
43 return adoptPtr(new InjectedScriptHost(debugger, session)); 44 return adoptPtr(new InjectedScriptHost(debugger, session));
44 } 45 }
45 46
46 InjectedScriptHost::InjectedScriptHost(V8DebuggerImpl* debugger, V8InspectorSess ionImpl* session) 47 InjectedScriptHost::InjectedScriptHost(V8DebuggerImpl* debugger, V8InspectorSess ionImpl* session)
47 : m_debugger(debugger) 48 : m_debugger(debugger)
48 , m_session(session) 49 , m_session(session)
49 { 50 {
50 } 51 }
51 52
52 InjectedScriptHost::~InjectedScriptHost() 53 InjectedScriptHost::~InjectedScriptHost()
53 { 54 {
54 } 55 }
55 56
56 void InjectedScriptHost::disconnect()
57 {
58 m_debugger = nullptr;
59 m_session = nullptr;
60 m_inspectedObjects.clear();
61 }
62
63 void InjectedScriptHost::inspectImpl(PassOwnPtr<protocol::Value> object, PassOwn Ptr<protocol::Value> hints) 57 void InjectedScriptHost::inspectImpl(PassOwnPtr<protocol::Value> object, PassOwn Ptr<protocol::Value> hints)
64 { 58 {
65 if (m_session && m_session->inspectCallback()) { 59 protocol::ErrorSupport errors;
66 protocol::ErrorSupport errors; 60 OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::Re moteObject::parse(object.get(), &errors);
67 OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime ::RemoteObject::parse(object.get(), &errors); 61 m_session->runtimeAgentImpl()->inspect(remoteObject.release(), protocol::Dic tionaryValue::cast(hints));
68 (*m_session->inspectCallback())(remoteObject.release(), protocol::Dictio naryValue::cast(hints));
69 }
70 } 62 }
71 63
72 void InjectedScriptHost::clearConsoleMessages() 64 void InjectedScriptHost::clearConsoleMessages()
73 { 65 {
74 if (m_session && m_session->clearConsoleCallback()) 66 if (m_session->clearConsoleCallback())
75 (*m_session->clearConsoleCallback())(); 67 (*m_session->clearConsoleCallback())();
76 } 68 }
77 69
78 void InjectedScriptHost::addInspectedObject(PassOwnPtr<V8RuntimeAgent::Inspectab le> object) 70 void InjectedScriptHost::addInspectedObject(PassOwnPtr<V8RuntimeAgent::Inspectab le> object)
79 { 71 {
80 m_inspectedObjects.prepend(object); 72 m_inspectedObjects.prepend(object);
81 while (m_inspectedObjects.size() > 5) 73 while (m_inspectedObjects.size() > 5)
82 m_inspectedObjects.removeLast(); 74 m_inspectedObjects.removeLast();
83 } 75 }
84 76
85 void InjectedScriptHost::clearInspectedObjects() 77 void InjectedScriptHost::clearInspectedObjects()
86 { 78 {
87 m_inspectedObjects.clear(); 79 m_inspectedObjects.clear();
88 } 80 }
89 81
90 V8RuntimeAgent::Inspectable* InjectedScriptHost::inspectedObject(unsigned num) 82 V8RuntimeAgent::Inspectable* InjectedScriptHost::inspectedObject(unsigned num)
91 { 83 {
92 if (num >= m_inspectedObjects.size()) 84 if (num >= m_inspectedObjects.size())
93 return nullptr; 85 return nullptr;
94 return m_inspectedObjects[num].get(); 86 return m_inspectedObjects[num].get();
95 } 87 }
96 88
97 void InjectedScriptHost::debugFunction(const String16& scriptId, int lineNumber, int columnNumber) 89 void InjectedScriptHost::debugFunction(const String16& scriptId, int lineNumber, int columnNumber)
98 { 90 {
99 if (m_session) 91 m_session->debuggerAgentImpl()->setBreakpointAt(scriptId, lineNumber, column Number, V8DebuggerAgentImpl::DebugCommandBreakpointSource);
100 m_session->debuggerAgentImpl()->setBreakpointAt(scriptId, lineNumber, co lumnNumber, V8DebuggerAgentImpl::DebugCommandBreakpointSource);
101 } 92 }
102 93
103 void InjectedScriptHost::undebugFunction(const String16& scriptId, int lineNumbe r, int columnNumber) 94 void InjectedScriptHost::undebugFunction(const String16& scriptId, int lineNumbe r, int columnNumber)
104 { 95 {
105 if (m_session) 96 m_session->debuggerAgentImpl()->removeBreakpointAt(scriptId, lineNumber, col umnNumber, V8DebuggerAgentImpl::DebugCommandBreakpointSource);
106 m_session->debuggerAgentImpl()->removeBreakpointAt(scriptId, lineNumber, columnNumber, V8DebuggerAgentImpl::DebugCommandBreakpointSource);
107 } 97 }
108 98
109 void InjectedScriptHost::monitorFunction(const String16& scriptId, int lineNumbe r, int columnNumber, const String16& functionName) 99 void InjectedScriptHost::monitorFunction(const String16& scriptId, int lineNumbe r, int columnNumber, const String16& functionName)
110 { 100 {
111 String16Builder builder; 101 String16Builder builder;
112 builder.append("console.log(\"function "); 102 builder.append("console.log(\"function ");
113 if (functionName.isEmpty()) 103 if (functionName.isEmpty())
114 builder.append("(anonymous function)"); 104 builder.append("(anonymous function)");
115 else 105 else
116 builder.append(functionName); 106 builder.append(functionName);
117 builder.append(" called\" + (arguments.length > 0 ? \" with arguments: \" + Array.prototype.join.call(arguments, \", \") : \"\")) && false"); 107 builder.append(" called\" + (arguments.length > 0 ? \" with arguments: \" + Array.prototype.join.call(arguments, \", \") : \"\")) && false");
118 if (m_session) 108 m_session->debuggerAgentImpl()->setBreakpointAt(scriptId, lineNumber, column Number, V8DebuggerAgentImpl::MonitorCommandBreakpointSource, builder.toString()) ;
119 m_session->debuggerAgentImpl()->setBreakpointAt(scriptId, lineNumber, co lumnNumber, V8DebuggerAgentImpl::MonitorCommandBreakpointSource, builder.toStrin g());
120 } 109 }
121 110
122 void InjectedScriptHost::unmonitorFunction(const String16& scriptId, int lineNum ber, int columnNumber) 111 void InjectedScriptHost::unmonitorFunction(const String16& scriptId, int lineNum ber, int columnNumber)
123 { 112 {
124 if (m_session) 113 m_session->debuggerAgentImpl()->removeBreakpointAt(scriptId, lineNumber, col umnNumber, V8DebuggerAgentImpl::MonitorCommandBreakpointSource);
125 m_session->debuggerAgentImpl()->removeBreakpointAt(scriptId, lineNumber, columnNumber, V8DebuggerAgentImpl::MonitorCommandBreakpointSource);
126 } 114 }
127 115
128 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698