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

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 649183010: Added SuspendableScriptExecutor::createAndRun to replace ctor+run (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@a
Patch Set: Created 6 years, 2 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 ASSERT(frame()); 782 ASSERT(frame());
783 783
784 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first()); 784 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first());
785 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource Code(source.code, source.url, position)); 785 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource Code(source.code, source.url, position));
786 } 786 }
787 787
788 void WebLocalFrameImpl::requestExecuteScriptAndReturnValue(const WebScriptSource & source, bool userGesture, WebScriptExecutionCallback* callback) 788 void WebLocalFrameImpl::requestExecuteScriptAndReturnValue(const WebScriptSource & source, bool userGesture, WebScriptExecutionCallback* callback)
789 { 789 {
790 ASSERT(frame()); 790 ASSERT(frame());
791 791
792 Vector<ScriptSourceCode> sources = createSourcesVector(&source, 1); 792 SuspendableScriptExecutor::createAndRun(frame(), 0, createSourcesVector(&sou rce, 1), 0, userGesture, callback);
793 SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame(), 0, sources, 0, userGesture, callback);
794 executor->run();
795 } 793 }
796 794
797 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local <v8::Value> >* results) 795 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local <v8::Value> >* results)
798 { 796 {
799 ASSERT(frame()); 797 ASSERT(frame());
800 RELEASE_ASSERT(worldID > 0); 798 RELEASE_ASSERT(worldID > 0);
801 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); 799 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
802 800
803 Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources ); 801 Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources );
804 802
805 if (results) { 803 if (results) {
806 Vector<v8::Local<v8::Value> > scriptResults; 804 Vector<v8::Local<v8::Value> > scriptResults;
807 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, &scriptResults); 805 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, &scriptResults);
808 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); 806 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size());
809 for (unsigned i = 0; i < scriptResults.size(); i++) 807 for (unsigned i = 0; i < scriptResults.size(); i++)
810 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR esults[i]); 808 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR esults[i]);
811 results->swap(v8Results); 809 results->swap(v8Results);
812 } else { 810 } else {
813 v8::HandleScope handleScope(toIsolate(frame())); 811 v8::HandleScope handleScope(toIsolate(frame()));
814 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, 0); 812 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, 0);
815 } 813 }
816 } 814 }
817 815
818 void WebLocalFrameImpl::requestExecuteScriptInIsolatedWorld(int worldID, const W ebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, bool userGes ture, WebScriptExecutionCallback* callback) 816 void WebLocalFrameImpl::requestExecuteScriptInIsolatedWorld(int worldID, const W ebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, bool userGes ture, WebScriptExecutionCallback* callback)
819 { 817 {
820 ASSERT(frame()); 818 ASSERT(frame());
821 RELEASE_ASSERT(worldID > 0); 819 RELEASE_ASSERT(worldID > 0);
822 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); 820 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
823 821
824 Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources ); 822 SuspendableScriptExecutor::createAndRun(frame(), worldID, createSourcesVecto r(sourcesIn, numSources), extensionGroup, userGesture, callback);
825 SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame(), worldID, sources, extensionGroup, userGesture, callback);
826 executor->run();
827 } 823 }
828 824
829 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl e<v8::Value> argv[]) 825 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl e<v8::Value> argv[])
830 { 826 {
831 ASSERT(frame()); 827 ASSERT(frame());
832 return frame()->script().callFunction(function, receiver, argc, argv); 828 return frame()->script().callFunction(function, receiver, argc, argv);
833 } 829 }
834 830
835 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const 831 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const
836 { 832 {
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 1958
1963 void WebLocalFrameImpl::invalidateAll() const 1959 void WebLocalFrameImpl::invalidateAll() const
1964 { 1960 {
1965 ASSERT(frame() && frame()->view()); 1961 ASSERT(frame() && frame()->view());
1966 FrameView* view = frame()->view(); 1962 FrameView* view = frame()->view();
1967 view->invalidateRect(view->frameRect()); 1963 view->invalidateRect(view->frameRect());
1968 invalidateScrollbar(); 1964 invalidateScrollbar();
1969 } 1965 }
1970 1966
1971 } // namespace blink 1967 } // namespace blink
OLDNEW
« Source/web/SuspendableScriptExecutor.h ('K') | « Source/web/SuspendableScriptExecutor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698