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

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

Issue 1917733002: [DevTools] Move part of CommandLineAPI to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 14 matching lines...) Expand all
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/String16.h"
34 #include "platform/inspector_protocol/Values.h" 34 #include "platform/inspector_protocol/Values.h"
35 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
36 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 35 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
37 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 36 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
38 #include "platform/v8_inspector/public/V8Debugger.h"
39 37
40 namespace blink { 38 namespace blink {
41 39
42 PassOwnPtr<InjectedScriptHost> InjectedScriptHost::create(V8DebuggerImpl* debugg er, V8InspectorSessionImpl* session) 40 PassOwnPtr<InjectedScriptHost> InjectedScriptHost::create(V8DebuggerImpl* debugg er, V8InspectorSessionImpl* session)
43 { 41 {
44 return adoptPtr(new InjectedScriptHost(debugger, session)); 42 return adoptPtr(new InjectedScriptHost(debugger, session));
45 } 43 }
46 44
47 InjectedScriptHost::InjectedScriptHost(V8DebuggerImpl* debugger, V8InspectorSess ionImpl* session) 45 InjectedScriptHost::InjectedScriptHost(V8DebuggerImpl* debugger, V8InspectorSess ionImpl* session)
48 : m_debugger(debugger) 46 : m_debugger(debugger)
49 , m_session(session) 47 , m_session(session)
50 { 48 {
51 } 49 }
52 50
53 InjectedScriptHost::~InjectedScriptHost() 51 InjectedScriptHost::~InjectedScriptHost()
54 { 52 {
55 } 53 }
56 54
57 void InjectedScriptHost::inspectImpl(PassOwnPtr<protocol::Value> object, PassOwn Ptr<protocol::Value> hints) 55 void InjectedScriptHost::inspectImpl(PassOwnPtr<protocol::Value> object, PassOwn Ptr<protocol::Value> hints)
58 { 56 {
59 protocol::ErrorSupport errors; 57 protocol::ErrorSupport errors;
60 OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::Re moteObject::parse(object.get(), &errors); 58 OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::Re moteObject::parse(object.get(), &errors);
61 m_session->runtimeAgentImpl()->inspect(remoteObject.release(), protocol::Dic tionaryValue::cast(hints)); 59 m_session->runtimeAgentImpl()->inspect(remoteObject.release(), protocol::Dic tionaryValue::cast(hints));
62 } 60 }
63 61
64 void InjectedScriptHost::clearConsoleMessages()
65 {
66 if (m_session->clearConsoleCallback())
67 (*m_session->clearConsoleCallback())();
68 }
69
70 void InjectedScriptHost::addInspectedObject(PassOwnPtr<V8RuntimeAgent::Inspectab le> object) 62 void InjectedScriptHost::addInspectedObject(PassOwnPtr<V8RuntimeAgent::Inspectab le> object)
71 { 63 {
72 m_inspectedObjects.prepend(object); 64 m_inspectedObjects.prepend(object);
73 while (m_inspectedObjects.size() > 5) 65 while (m_inspectedObjects.size() > 5)
74 m_inspectedObjects.removeLast(); 66 m_inspectedObjects.removeLast();
75 } 67 }
76 68
77 void InjectedScriptHost::clearInspectedObjects() 69 void InjectedScriptHost::clearInspectedObjects()
78 { 70 {
79 m_inspectedObjects.clear(); 71 m_inspectedObjects.clear();
80 } 72 }
81 73
82 V8RuntimeAgent::Inspectable* InjectedScriptHost::inspectedObject(unsigned num) 74 V8RuntimeAgent::Inspectable* InjectedScriptHost::inspectedObject(unsigned num)
83 { 75 {
84 if (num >= m_inspectedObjects.size()) 76 if (num >= m_inspectedObjects.size())
85 return nullptr; 77 return nullptr;
86 return m_inspectedObjects[num].get(); 78 return m_inspectedObjects[num].get();
87 } 79 }
88 80
89 void InjectedScriptHost::debugFunction(const String16& scriptId, int lineNumber, int columnNumber)
90 {
91 m_session->debuggerAgentImpl()->setBreakpointAt(scriptId, lineNumber, column Number, V8DebuggerAgentImpl::DebugCommandBreakpointSource);
92 }
93
94 void InjectedScriptHost::undebugFunction(const String16& scriptId, int lineNumbe r, int columnNumber)
95 {
96 m_session->debuggerAgentImpl()->removeBreakpointAt(scriptId, lineNumber, col umnNumber, V8DebuggerAgentImpl::DebugCommandBreakpointSource);
97 }
98
99 void InjectedScriptHost::monitorFunction(const String16& scriptId, int lineNumbe r, int columnNumber, const String16& functionName)
100 {
101 String16Builder builder;
102 builder.append("console.log(\"function ");
103 if (functionName.isEmpty())
104 builder.append("(anonymous function)");
105 else
106 builder.append(functionName);
107 builder.append(" called\" + (arguments.length > 0 ? \" with arguments: \" + Array.prototype.join.call(arguments, \", \") : \"\")) && false");
108 m_session->debuggerAgentImpl()->setBreakpointAt(scriptId, lineNumber, column Number, V8DebuggerAgentImpl::MonitorCommandBreakpointSource, builder.toString()) ;
109 }
110
111 void InjectedScriptHost::unmonitorFunction(const String16& scriptId, int lineNum ber, int columnNumber)
112 {
113 m_session->debuggerAgentImpl()->removeBreakpointAt(scriptId, lineNumber, col umnNumber, V8DebuggerAgentImpl::MonitorCommandBreakpointSource);
114 }
115
116 } // namespace blink 81 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698