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

Side by Side Diff: src/inspector/v8-runtime-agent-impl.cc

Issue 2499273003: [inspector] introduced Script::TYPE_INSPECTOR (Closed)
Patch Set: rebased Created 4 years, 1 month 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 | « src/inspector/v8-inspector-impl.cc ('k') | src/objects.h » ('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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 if (silent.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole(); 286 if (silent.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole();
287 if (userGesture.fromMaybe(false)) scope.pretendUserGesture(); 287 if (userGesture.fromMaybe(false)) scope.pretendUserGesture();
288 288
289 if (includeCommandLineAPI.fromMaybe(false)) scope.installCommandLineAPI(); 289 if (includeCommandLineAPI.fromMaybe(false)) scope.installCommandLineAPI();
290 290
291 bool evalIsDisabled = !scope.context()->IsCodeGenerationFromStringsAllowed(); 291 bool evalIsDisabled = !scope.context()->IsCodeGenerationFromStringsAllowed();
292 // Temporarily enable allow evals for inspector. 292 // Temporarily enable allow evals for inspector.
293 if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(true); 293 if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(true);
294 294
295 v8::MaybeLocal<v8::Value> maybeResultValue; 295 v8::MaybeLocal<v8::Value> maybeResultValue;
296 v8::Local<v8::Script> script = m_inspector->compileScript( 296 v8::Local<v8::Script> script;
297 scope.context(), toV8String(m_inspector->isolate(), expression), 297 if (m_inspector->compileScript(scope.context(), expression, String16())
298 String16(), false); 298 .ToLocal(&script)) {
299 if (!script.IsEmpty())
300 maybeResultValue = m_inspector->runCompiledScript(scope.context(), script); 299 maybeResultValue = m_inspector->runCompiledScript(scope.context(), script);
300 }
301 301
302 if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(false); 302 if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(false);
303 303
304 // Re-initialize after running client's code, as it could have destroyed 304 // Re-initialize after running client's code, as it could have destroyed
305 // context or session. 305 // context or session.
306 response = scope.initialize(); 306 response = scope.initialize();
307 if (!response.isSuccess()) { 307 if (!response.isSuccess()) {
308 callback->sendFailure(response); 308 callback->sendFailure(response);
309 return; 309 return;
310 } 310 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 callback->sendFailure(response); 372 callback->sendFailure(response);
373 return; 373 return;
374 } 374 }
375 argv[i] = argumentValue; 375 argv[i] = argumentValue;
376 } 376 }
377 } 377 }
378 378
379 if (silent.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole(); 379 if (silent.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole();
380 if (userGesture.fromMaybe(false)) scope.pretendUserGesture(); 380 if (userGesture.fromMaybe(false)) scope.pretendUserGesture();
381 381
382 v8::MaybeLocal<v8::Value> maybeFunctionValue = 382 v8::MaybeLocal<v8::Value> maybeFunctionValue;
383 m_inspector->compileAndRunInternalScript( 383 v8::Local<v8::Script> functionScript;
384 scope.context(), 384 if (m_inspector
385 toV8String(m_inspector->isolate(), "(" + expression + ")")); 385 ->compileScript(scope.context(), "(" + expression + ")", String16())
386 .ToLocal(&functionScript)) {
387 maybeFunctionValue =
388 m_inspector->runCompiledScript(scope.context(), functionScript);
389 }
386 // Re-initialize after running client's code, as it could have destroyed 390 // Re-initialize after running client's code, as it could have destroyed
387 // context or session. 391 // context or session.
388 response = scope.initialize(); 392 response = scope.initialize();
389 if (!response.isSuccess()) { 393 if (!response.isSuccess()) {
390 callback->sendFailure(response); 394 callback->sendFailure(response);
391 return; 395 return;
392 } 396 }
393 397
394 if (scope.tryCatch().HasCaught()) { 398 if (scope.tryCatch().HasCaught()) {
395 wrapEvaluateResultAsync(scope.injectedScript(), maybeFunctionValue, 399 wrapEvaluateResultAsync(scope.injectedScript(), maybeFunctionValue,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 int contextId = 0; 540 int contextId = 0;
537 Response response = ensureContext(m_inspector, m_session->contextGroupId(), 541 Response response = ensureContext(m_inspector, m_session->contextGroupId(),
538 std::move(executionContextId), &contextId); 542 std::move(executionContextId), &contextId);
539 if (!response.isSuccess()) return response; 543 if (!response.isSuccess()) return response;
540 InjectedScript::ContextScope scope(m_inspector, m_session->contextGroupId(), 544 InjectedScript::ContextScope scope(m_inspector, m_session->contextGroupId(),
541 contextId); 545 contextId);
542 response = scope.initialize(); 546 response = scope.initialize();
543 if (!response.isSuccess()) return response; 547 if (!response.isSuccess()) return response;
544 548
545 if (!persistScript) m_inspector->debugger()->muteScriptParsedEvents(); 549 if (!persistScript) m_inspector->debugger()->muteScriptParsedEvents();
546 v8::Local<v8::Script> script = m_inspector->compileScript( 550 v8::Local<v8::Script> script;
547 scope.context(), toV8String(m_inspector->isolate(), expression), 551 bool isOk = m_inspector->compileScript(scope.context(), expression, sourceURL)
548 sourceURL, false); 552 .ToLocal(&script);
549 if (!persistScript) m_inspector->debugger()->unmuteScriptParsedEvents(); 553 if (!persistScript) m_inspector->debugger()->unmuteScriptParsedEvents();
550 if (script.IsEmpty()) { 554 if (!isOk) {
551 if (scope.tryCatch().HasCaught()) { 555 if (scope.tryCatch().HasCaught()) {
552 response = scope.injectedScript()->createExceptionDetails( 556 response = scope.injectedScript()->createExceptionDetails(
553 scope.tryCatch(), String16(), false, exceptionDetails); 557 scope.tryCatch(), String16(), false, exceptionDetails);
554 if (!response.isSuccess()) return response; 558 if (!response.isSuccess()) return response;
555 return Response::OK(); 559 return Response::OK();
556 } else { 560 } else {
557 return Response::Error("Script compilation failed"); 561 return Response::Error("Script compilation failed");
558 } 562 }
559 } 563 }
560 564
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 730 }
727 731
728 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, 732 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message,
729 bool generatePreview) { 733 bool generatePreview) {
730 message->reportToFrontend(&m_frontend, m_session, generatePreview); 734 message->reportToFrontend(&m_frontend, m_session, generatePreview);
731 m_frontend.flush(); 735 m_frontend.flush();
732 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()); 736 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId());
733 } 737 }
734 738
735 } // namespace v8_inspector 739 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-inspector-impl.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698