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

Unified Diff: Source/core/testing/Internals.cpp

Issue 1167343002: Add methods for creating V8 extras-based ReadableStreams from C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove C++ queuing strategies Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 6f84a6b09302e5d3bf85f6c02a28aae1307d399a..069b81257db6df3e52063db3a75c2337321c89da 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -117,6 +117,7 @@
#include "core/paint/DeprecatedPaintLayer.h"
#include "core/plugins/testing/DictionaryPluginPlaceholder.h"
#include "core/plugins/testing/DocumentFragmentPluginPlaceholder.h"
+#include "core/streams/ReadableStream2.h"
#include "core/testing/DictionaryTest.h"
#include "core/testing/GCObservation.h"
#include "core/testing/InternalRuntimeFlags.h"
@@ -192,9 +193,9 @@ static SpellCheckRequester* spellCheckRequester(Document* document)
const char* Internals::internalsId = "internals";
-Internals* Internals::create(Document* document)
+Internals* Internals::create(ScriptState* scriptState)
{
- return new Internals(document);
+ return new Internals(scriptState);
}
Internals::~Internals()
@@ -220,9 +221,26 @@ void Internals::resetToConsistentState(Page* page)
page->deprecatedLocalMainFrame()->view()->clear();
}
-Internals::Internals(Document* document)
- : ContextLifecycleObserver(document)
+namespace {
+
+class TestUnderlyingSource : public UnderlyingSourceBase {
+public:
+ ScriptPromise start(ScriptState* scriptState) override
+ {
+ controller().enqueue("a");
+ controller().enqueue("b");
+ controller().close();
+ return UnderlyingSourceBase::start(scriptState);
+ };
+};
+
+} // namespace
+
+Internals::Internals(ScriptState* scriptState)
+ : ContextLifecycleObserver(scriptState->executionContext())
, m_runtimeFlags(InternalRuntimeFlags::create())
+ , m_readableStream(new ReadableStream2(scriptState, new TestUnderlyingSource(),
+ ReadableStream2::createCountQueuingStrategy(scriptState, 1024.0)))
{
}
@@ -2370,4 +2388,9 @@ ClientRectList* Internals::focusRingRects(Element* element)
return ClientRectList::create(rects);
}
+ScriptValue Internals::readableStream()
+{
+ return m_readableStream->scriptValue();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698