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

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

Issue 1826623002: [DevTools] Move wrapCallFrames from InjectedScriptSource.js to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-no-scopes
Patch Set: Created 4 years, 9 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/v8_inspector/V8JavaScriptCallFrame.h"
6
7 #include "platform/v8_inspector/InspectorWrapper.h"
8 #include "platform/v8_inspector/JavaScriptCallFrame.h"
9 #include "platform/v8_inspector/V8StringUtil.h"
10 #include "wtf/PassOwnPtr.h"
11 #include <algorithm>
12
13 namespace blink {
14
15 namespace {
16
17 void callerAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallba ckInfo<v8::Value>& info)
18 {
19 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
20 OwnPtr<JavaScriptCallFrame> caller = impl->caller();
21 if (!caller)
22 return;
23 v8::Isolate* isolate = info.GetIsolate();
24 v8::Local<v8::FunctionTemplate> wrapperTemplate = impl->wrapperTemplate(isol ate);
25 if (wrapperTemplate.IsEmpty())
26 return;
27 info.GetReturnValue().Set(V8JavaScriptCallFrame::wrap(wrapperTemplate, isola te->GetCurrentContext(), caller.release()));
28 }
29
30 void sourceIDAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCall backInfo<v8::Value>& info)
31 {
32 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
33 info.GetReturnValue().Set(impl->sourceID());
34 }
35
36 void lineAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallback Info<v8::Value>& info)
37 {
38 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
39 info.GetReturnValue().Set(impl->line());
40 }
41
42 void columnAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallba ckInfo<v8::Value>& info)
43 {
44 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
45 info.GetReturnValue().Set(impl->column());
46 }
47
48 void scopeChainAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCa llbackInfo<v8::Value>& info)
49 {
50 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
51 info.GetReturnValue().Set(impl->scopeChain());
52 }
53
54 void thisObjectAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCa llbackInfo<v8::Value>& info)
55 {
56 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
57 info.GetReturnValue().Set(impl->thisObject());
58 }
59
60 void stepInPositionsAttributeGetterCallback(v8::Local<v8::Name>, const v8::Prope rtyCallbackInfo<v8::Value>& info)
61 {
62 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
63 info.GetReturnValue().Set(toV8String(info.GetIsolate(), impl->stepInPosition s()));
64 }
65
66 void functionNameAttributeGetterCallback(v8::Local<v8::Name>, const v8::Property CallbackInfo<v8::Value>& info)
67 {
68 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
69 info.GetReturnValue().Set(toV8String(info.GetIsolate(), impl->functionName() ));
70 }
71
72 void functionLineAttributeGetterCallback(v8::Local<v8::Name>, const v8::Property CallbackInfo<v8::Value>& info)
73 {
74 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
75 info.GetReturnValue().Set(impl->functionLine());
76 }
77
78 void functionColumnAttributeGetterCallback(v8::Local<v8::Name>, const v8::Proper tyCallbackInfo<v8::Value>& info)
79 {
80 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
81 info.GetReturnValue().Set(impl->functionColumn());
82 }
83
84 void isAtReturnAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCa llbackInfo<v8::Value>& info)
85 {
86 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
87 info.GetReturnValue().Set(impl->isAtReturn());
88 }
89
90 void returnValueAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyC allbackInfo<v8::Value>& info)
91 {
92 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
93 info.GetReturnValue().Set(impl->returnValue());
94 }
95
96 void scopeTypeMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
97 {
98 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
99 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
100 if (maybeScopeIndex.IsNothing())
101 return;
102 int scopeIndex = maybeScopeIndex.FromJust();
103 info.GetReturnValue().Set(impl->scopeType(scopeIndex));
104 }
105
106 void scopeNameMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
107 {
108 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
109 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
110 if (maybeScopeIndex.IsNothing())
111 return;
112 int scopeIndex = maybeScopeIndex.FromJust();
113 info.GetReturnValue().Set(impl->scopeName(scopeIndex));
114 }
115
116 void scopeStartLocationMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
117 {
118 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
119 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
120 if (maybeScopeIndex.IsNothing())
121 return;
122 int scopeIndex = maybeScopeIndex.FromJust();
123 info.GetReturnValue().Set(impl->scopeStartLocation(scopeIndex));
124 }
125
126 void scopeEndLocationMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
127 {
128 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
129 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
130 if (maybeScopeIndex.IsNothing())
131 return;
132 int scopeIndex = maybeScopeIndex.FromJust();
133 info.GetReturnValue().Set(impl->scopeEndLocation(scopeIndex));
134 }
135
136 char hiddenPropertyName[] = "v8inspector::JavaScriptCallFrame";
137 char className[] = "V8JavaScriptCallFrame";
138 using JavaScriptCallFrameWrapper = InspectorWrapper<JavaScriptCallFrame, hiddenP ropertyName, className>;
139
140 const JavaScriptCallFrameWrapper::V8AttributeConfiguration V8JavaScriptCallFrame Attributes[] = {
141 {"scopeChain", scopeChainAttributeGetterCallback},
142 {"thisObject", thisObjectAttributeGetterCallback},
143 {"returnValue", returnValueAttributeGetterCallback},
144
145 {"caller", callerAttributeGetterCallback},
146 {"sourceID", sourceIDAttributeGetterCallback},
147 {"line", lineAttributeGetterCallback},
148 {"column", columnAttributeGetterCallback},
149 {"stepInPositions", stepInPositionsAttributeGetterCallback},
150 {"functionName", functionNameAttributeGetterCallback},
151 {"functionLine", functionLineAttributeGetterCallback},
152 {"functionColumn", functionColumnAttributeGetterCallback},
153 {"isAtReturn", isAtReturnAttributeGetterCallback},
154 };
155
156 const JavaScriptCallFrameWrapper::V8MethodConfiguration V8JavaScriptCallFrameMet hods[] = {
157 {"scopeType", scopeTypeMethodCallback},
158 {"scopeName", scopeNameMethodCallback},
159 {"scopeStartLocation", scopeStartLocationMethodCallback},
160 {"scopeEndLocation", scopeEndLocationMethodCallback},
161 };
162
163 } // namespace
164
165 v8::Local<v8::FunctionTemplate> V8JavaScriptCallFrame::createWrapperTemplate(v8: :Isolate* isolate)
166 {
167 protocol::Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_AR RAY_LENGTH(V8JavaScriptCallFrameMethods));
168 std::copy(V8JavaScriptCallFrameMethods, V8JavaScriptCallFrameMethods + WTF_A RRAY_LENGTH(V8JavaScriptCallFrameMethods), methods.begin());
169 protocol::Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes( WTF_ARRAY_LENGTH(V8JavaScriptCallFrameAttributes));
170 std::copy(V8JavaScriptCallFrameAttributes, V8JavaScriptCallFrameAttributes + WTF_ARRAY_LENGTH(V8JavaScriptCallFrameAttributes), attributes.begin());
171 return JavaScriptCallFrameWrapper::createWrapperTemplate(isolate, methods, a ttributes);
172 }
173
174 v8::Local<v8::Object> V8JavaScriptCallFrame::wrap(v8::Local<v8::FunctionTemplate > constructorTemplate, v8::Local<v8::Context> context, PassOwnPtr<JavaScriptCall Frame> frame)
175 {
176 // Store template for .caller callback
177 frame->setWrapperTemplate(constructorTemplate, context->GetIsolate());
178 return JavaScriptCallFrameWrapper::wrap(constructorTemplate, context, frame) ;
179 }
180
181 JavaScriptCallFrame* V8JavaScriptCallFrame::unwrap(v8::Local<v8::Context> contex t, v8::Local<v8::Object> object)
182 {
183 return JavaScriptCallFrameWrapper::unwrap(context, object);
184 }
185
186 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698