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

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

Issue 847803002: Make ScriptStreamer and dependents Oilpan friendly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nullptr tidying Created 5 years, 11 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 | Annotate | Revision Log
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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 if (context.IsEmpty()) 564 if (context.IsEmpty())
565 return v8::Local<v8::Value>(); 565 return v8::Local<v8::Value>();
566 566
567 ScriptState* scriptState = ScriptState::from(context); 567 ScriptState* scriptState = ScriptState::from(context);
568 ScriptState::Scope scope(scriptState); 568 ScriptState::Scope scope(scriptState);
569 569
570 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 570 RefPtrWillBeRawPtr<LocalFrame> protect(frame());
571 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()) 571 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument())
572 frame()->loader().didAccessInitialDocument(); 572 frame()->loader().didAccessInitialDocument();
573 573
574 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio n::preprocess(frame(), sourceCode); 574 Nullable<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentati on::preprocess(frame(), sourceCode);
575 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma ybeProcessedSourceCode : sourceCode; 575 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode.isNul l() ? sourceCode : maybeProcessedSourceCode.get();
576 576
577 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); 577 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCodeToCompile, corsStatus, compilationFinishTime);
578 m_sourceURL = savedSourceURL; 578 m_sourceURL = savedSourceURL;
579 579
580 if (object.IsEmpty()) 580 if (object.IsEmpty())
581 return v8::Local<v8::Value>(); 581 return v8::Local<v8::Value>();
582 582
583 return handleScope.Escape(object); 583 return handleScope.Escape(object);
584 } 584 }
585 585
586 void ScriptController::executeScriptInIsolatedWorld(int worldID, const Vector<Sc riptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Value> >* res ults) 586 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val ue> >* results)
587 { 587 {
588 ASSERT(worldID > 0); 588 ASSERT(worldID > 0);
589 589
590 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate (), worldID, extensionGroup); 590 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate (), worldID, extensionGroup);
591 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); 591 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world);
592 if (!isolatedWorldWindowProxy->isContextInitialized()) 592 if (!isolatedWorldWindowProxy->isContextInitialized())
593 return; 593 return;
594 594
595 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); 595 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState();
596 v8::Context::Scope scope(scriptState->context()); 596 v8::Context::Scope scope(scriptState->context());
597 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()) ; 597 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()) ;
598 598
599 for (size_t i = 0; i < sources.size(); ++i) { 599 for (size_t i = 0; i < sources.size(); ++i) {
600 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri ptState->context(), sources[i]); 600 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri ptState->context(), sources[i]);
601 if (evaluationResult.IsEmpty()) 601 if (evaluationResult.IsEmpty())
602 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine d(isolate())); 602 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine d(isolate()));
603 resultArray->Set(i, evaluationResult); 603 resultArray->Set(i, evaluationResult);
604 } 604 }
605 605
606 if (results) { 606 if (results) {
607 for (size_t i = 0; i < resultArray->Length(); ++i) 607 for (size_t i = 0; i < resultArray->Length(); ++i)
608 results->append(resultArray->Get(i)); 608 results->append(resultArray->Get(i));
609 } 609 }
610 } 610 }
611 611
612 } // namespace blink 612 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698