OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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/Values.h" | 34 #include "platform/inspector_protocol/Values.h" |
34 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 35 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
35 #include "platform/v8_inspector/public/V8Debugger.h" | 36 #include "platform/v8_inspector/public/V8Debugger.h" |
36 | 37 |
37 #include "wtf/text/StringBuilder.h" | |
38 | |
39 namespace blink { | 38 namespace blink { |
40 | 39 |
41 PassOwnPtr<InjectedScriptHost> InjectedScriptHost::create(V8DebuggerImpl* debugg
er) | 40 PassOwnPtr<InjectedScriptHost> InjectedScriptHost::create(V8DebuggerImpl* debugg
er) |
42 { | 41 { |
43 return adoptPtr(new InjectedScriptHost(debugger)); | 42 return adoptPtr(new InjectedScriptHost(debugger)); |
44 } | 43 } |
45 | 44 |
46 InjectedScriptHost::InjectedScriptHost(V8DebuggerImpl* debugger) | 45 InjectedScriptHost::InjectedScriptHost(V8DebuggerImpl* debugger) |
47 : m_debugger(debugger) | 46 : m_debugger(debugger) |
48 , m_debuggerAgent(nullptr) | 47 , m_debuggerAgent(nullptr) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 m_inspectedObjects.clear(); | 100 m_inspectedObjects.clear(); |
102 } | 101 } |
103 | 102 |
104 V8RuntimeAgent::Inspectable* InjectedScriptHost::inspectedObject(unsigned num) | 103 V8RuntimeAgent::Inspectable* InjectedScriptHost::inspectedObject(unsigned num) |
105 { | 104 { |
106 if (num >= m_inspectedObjects.size()) | 105 if (num >= m_inspectedObjects.size()) |
107 return nullptr; | 106 return nullptr; |
108 return m_inspectedObjects[num].get(); | 107 return m_inspectedObjects[num].get(); |
109 } | 108 } |
110 | 109 |
111 void InjectedScriptHost::debugFunction(const String& scriptId, int lineNumber, i
nt columnNumber) | 110 void InjectedScriptHost::debugFunction(const String16& scriptId, int lineNumber,
int columnNumber) |
112 { | 111 { |
113 if (m_debuggerAgent) | 112 if (m_debuggerAgent) |
114 m_debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, V8D
ebuggerAgentImpl::DebugCommandBreakpointSource); | 113 m_debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, V8D
ebuggerAgentImpl::DebugCommandBreakpointSource); |
115 } | 114 } |
116 | 115 |
117 void InjectedScriptHost::undebugFunction(const String& scriptId, int lineNumber,
int columnNumber) | 116 void InjectedScriptHost::undebugFunction(const String16& scriptId, int lineNumbe
r, int columnNumber) |
118 { | 117 { |
119 if (m_debuggerAgent) | 118 if (m_debuggerAgent) |
120 m_debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber,
V8DebuggerAgentImpl::DebugCommandBreakpointSource); | 119 m_debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber,
V8DebuggerAgentImpl::DebugCommandBreakpointSource); |
121 } | 120 } |
122 | 121 |
123 void InjectedScriptHost::monitorFunction(const String& scriptId, int lineNumber,
int columnNumber, const String& functionName) | 122 void InjectedScriptHost::monitorFunction(const String16& scriptId, int lineNumbe
r, int columnNumber, const String16& functionName) |
124 { | 123 { |
125 StringBuilder builder; | 124 String16Builder builder; |
126 builder.appendLiteral("console.log(\"function "); | 125 builder.append("console.log(\"function "); |
127 if (functionName.isEmpty()) | 126 if (functionName.isEmpty()) |
128 builder.appendLiteral("(anonymous function)"); | 127 builder.append("(anonymous function)"); |
129 else | 128 else |
130 builder.append(functionName); | 129 builder.append(functionName); |
131 builder.appendLiteral(" called\" + (arguments.length > 0 ? \" with arguments
: \" + Array.prototype.join.call(arguments, \", \") : \"\")) && false"); | 130 builder.append(" called\" + (arguments.length > 0 ? \" with arguments: \" +
Array.prototype.join.call(arguments, \", \") : \"\")) && false"); |
132 if (m_debuggerAgent) | 131 if (m_debuggerAgent) |
133 m_debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, V8D
ebuggerAgentImpl::MonitorCommandBreakpointSource, builder.toString()); | 132 m_debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, V8D
ebuggerAgentImpl::MonitorCommandBreakpointSource, builder.toString()); |
134 } | 133 } |
135 | 134 |
136 void InjectedScriptHost::unmonitorFunction(const String& scriptId, int lineNumbe
r, int columnNumber) | 135 void InjectedScriptHost::unmonitorFunction(const String16& scriptId, int lineNum
ber, int columnNumber) |
137 { | 136 { |
138 if (m_debuggerAgent) | 137 if (m_debuggerAgent) |
139 m_debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber,
V8DebuggerAgentImpl::MonitorCommandBreakpointSource); | 138 m_debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber,
V8DebuggerAgentImpl::MonitorCommandBreakpointSource); |
140 } | 139 } |
141 | 140 |
142 } // namespace blink | 141 } // namespace blink |
OLD | NEW |