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

Side by Side Diff: Source/bindings/core/v8/ScriptController.cpp

Issue 1307363006: DevTools: move instrumentation of v8 calls into V8ScriptRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed comments Created 5 years, 3 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
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8ScriptRunner.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 4 * Copyright (C) 2014 Opera Software ASA. 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 are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 v8::MaybeLocal<v8::Value> ScriptController::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) 145 v8::MaybeLocal<v8::Value> ScriptController::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[])
146 { 146 {
147 // Keep LocalFrame (and therefore ScriptController) alive. 147 // Keep LocalFrame (and therefore ScriptController) alive.
148 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 148 RefPtrWillBeRawPtr<LocalFrame> protect(frame());
149 return ScriptController::callFunction(frame()->document(), function, receive r, argc, info, isolate()); 149 return ScriptController::callFunction(frame()->document(), function, receive r, argc, info, isolate());
150 } 150 }
151 151
152 v8::MaybeLocal<v8::Value> ScriptController::callFunction(ExecutionContext* conte xt, v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v 8::Local<v8::Value> info[], v8::Isolate* isolate) 152 v8::MaybeLocal<v8::Value> ScriptController::callFunction(ExecutionContext* conte xt, v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v 8::Local<v8::Value> info[], v8::Isolate* isolate)
153 { 153 {
154 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFu nction(context, DevToolsFunctionInfo(function));
155 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, co ntext, receiver, argc, info, isolate); 154 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, co ntext, receiver, argc, info, isolate);
156 InspectorInstrumentation::didCallFunction(cookie);
157 return result; 155 return result;
158 } 156 }
159 157
160 v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Local<v8: :Context> context, const ScriptSourceCode& source, AccessControlStatus accessCon trolStatus, double* compilationFinishTime) 158 v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Local<v8: :Context> context, const ScriptSourceCode& source, AccessControlStatus accessCon trolStatus, double* compilationFinishTime)
161 { 159 {
162 TRACE_EVENT1("devtools.timeline", "EvaluateScript", "data", InspectorEvaluat eScriptEvent::data(frame(), source.url().string(), source.startLine())); 160 TRACE_EVENT1("devtools.timeline", "EvaluateScript", "data", InspectorEvaluat eScriptEvent::data(frame(), source.url().string(), source.startLine()));
163 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvalua teScript(frame()); 161 InspectorInstrumentation::willEvaluateScript(frame()->document());
164 162
165 v8::Local<v8::Value> result; 163 v8::Local<v8::Value> result;
166 { 164 {
167 V8CacheOptions v8CacheOptions(V8CacheOptionsDefault); 165 V8CacheOptions v8CacheOptions(V8CacheOptionsDefault);
168 if (frame()->settings()) 166 if (frame()->settings())
169 v8CacheOptions = frame()->settings()->v8CacheOptions(); 167 v8CacheOptions = frame()->settings()->v8CacheOptions();
170 168
171 // Isolate exceptions that occur when compiling and executing 169 // Isolate exceptions that occur when compiling and executing
172 // the code. These exceptions should not interfere with 170 // the code. These exceptions should not interfere with
173 // javascript code we might evaluate from C++ when returning 171 // javascript code we might evaluate from C++ when returning
174 // from here. 172 // from here.
175 v8::TryCatch tryCatch; 173 v8::TryCatch tryCatch;
176 tryCatch.SetVerbose(true); 174 tryCatch.SetVerbose(true);
177 175
178 v8::Local<v8::Script> script; 176 v8::Local<v8::Script> script;
179 if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessContr olStatus, v8CacheOptions), script, tryCatch)) 177 if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessContr olStatus, v8CacheOptions), script, tryCatch))
180 return result; 178 return result;
181 179
182 if (compilationFinishTime) { 180 if (compilationFinishTime) {
183 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); 181 *compilationFinishTime = WTF::monotonicallyIncreasingTime();
184 } 182 }
185 // Keep LocalFrame (and therefore ScriptController) alive. 183 // Keep LocalFrame (and therefore ScriptController) alive.
186 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 184 RefPtrWillBeRawPtr<LocalFrame> protect(frame());
187 if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame() ->document()), result, tryCatch)) 185 if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame() ->document()), result, tryCatch))
188 return result; 186 return result;
189 } 187 }
190 188
191 InspectorInstrumentation::didEvaluateScript(cookie);
192 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 189 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
193 190
194 return result; 191 return result;
195 } 192 }
196 193
197 bool ScriptController::initializeMainWorld() 194 bool ScriptController::initializeMainWorld()
198 { 195 {
199 if (m_windowProxyManager->mainWorldProxy()->isContextInitialized()) 196 if (m_windowProxyManager->mainWorldProxy()->isContextInitialized())
200 return false; 197 return false;
201 return windowProxy(DOMWrapperWorld::mainWorld())->isContextInitialized(); 198 return windowProxy(DOMWrapperWorld::mainWorld())->isContextInitialized();
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 for (size_t i = 0; i < resultArray->Length(); ++i) { 588 for (size_t i = 0; i < resultArray->Length(); ++i) {
592 v8::Local<v8::Value> value; 589 v8::Local<v8::Value> value;
593 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) 590 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value))
594 return; 591 return;
595 results->append(value); 592 results->append(value);
596 } 593 }
597 } 594 }
598 } 595 }
599 596
600 } // namespace blink 597 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8ScriptRunner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698