| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "bindings/core/v8/ScriptStreamer.h" | 6 #include "bindings/core/v8/ScriptStreamer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
| 9 #include "bindings/core/v8/ScriptStreamerThread.h" | 9 #include "bindings/core/v8/ScriptStreamerThread.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class ScriptStreamingTest : public ::testing::Test { | 27 class ScriptStreamingTest : public ::testing::Test { |
| 28 public: | 28 public: |
| 29 ScriptStreamingTest() | 29 ScriptStreamingTest() |
| 30 : m_loadingTaskRunner(Platform::current()->currentThread()->scheduler()-
>loadingTaskRunner()) | 30 : m_loadingTaskRunner(Platform::current()->currentThread()->scheduler()-
>loadingTaskRunner()) |
| 31 , m_scope(v8::Isolate::GetCurrent()) | 31 , m_scope(v8::Isolate::GetCurrent()) |
| 32 , m_settings(Settings::create()) | 32 , m_settings(Settings::create()) |
| 33 , m_resourceRequest("http://www.streaming-test.com/") | 33 , m_resourceRequest("http://www.streaming-test.com/") |
| 34 , m_resource(ScriptResource::create(m_resourceRequest, "UTF-8")) | 34 , m_resource(ScriptResource::create(m_resourceRequest, "UTF-8")) |
| 35 , m_pendingScript(PendingScript::create(0, m_resource.get())) | 35 , m_pendingScript(PendingScript::create(0, m_resource.get())) |
| 36 { | 36 { |
| 37 m_resource->setLoading(true); | 37 m_resource->setStatus(Resource::Pending); |
| 38 m_pendingScript = PendingScript::create(0, m_resource.get()); | 38 m_pendingScript = PendingScript::create(0, m_resource.get()); |
| 39 ScriptStreamer::setSmallScriptThresholdForTesting(0); | 39 ScriptStreamer::setSmallScriptThresholdForTesting(0); |
| 40 } | 40 } |
| 41 | 41 |
| 42 ScriptState* getScriptState() const { return m_scope.getScriptState(); } | 42 ScriptState* getScriptState() const { return m_scope.getScriptState(); } |
| 43 v8::Isolate* isolate() const { return m_scope.isolate(); } | 43 v8::Isolate* isolate() const { return m_scope.isolate(); } |
| 44 | 44 |
| 45 PendingScript* getPendingScript() const { return m_pendingScript.get(); } | 45 PendingScript* getPendingScript() const { return m_pendingScript.get(); } |
| 46 | 46 |
| 47 protected: | 47 protected: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 61 for (int i = 0; i < 10; ++i) { | 61 for (int i = 0; i < 10; ++i) { |
| 62 appendData(" /* this is padding to make the script long enough, so " | 62 appendData(" /* this is padding to make the script long enough, so " |
| 63 "that V8's buffer gets filled and it starts processing " | 63 "that V8's buffer gets filled and it starts processing " |
| 64 "the data */ "); | 64 "the data */ "); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void finish() | 68 void finish() |
| 69 { | 69 { |
| 70 m_resource->finish(); | 70 m_resource->finish(); |
| 71 m_resource->setLoading(false); | 71 m_resource->setStatus(Resource::Cached); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void processTasksUntilStreamingComplete() | 74 void processTasksUntilStreamingComplete() |
| 75 { | 75 { |
| 76 while (ScriptStreamerThread::shared()->isRunningTask()) { | 76 while (ScriptStreamerThread::shared()->isRunningTask()) { |
| 77 testing::runPendingTasks(); | 77 testing::runPendingTasks(); |
| 78 } | 78 } |
| 79 // Once more, because the "streaming complete" notification might only | 79 // Once more, because the "streaming complete" notification might only |
| 80 // now be in the task queue. | 80 // now be in the task queue. |
| 81 testing::runPendingTasks(); | 81 testing::runPendingTasks(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 EXPECT_TRUE(sourceCode.streamer()); | 375 EXPECT_TRUE(sourceCode.streamer()); |
| 376 v8::TryCatch tryCatch(isolate()); | 376 v8::TryCatch tryCatch(isolate()); |
| 377 v8::Local<v8::Script> script; | 377 v8::Local<v8::Script> script; |
| 378 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc
ript)); | 378 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc
ript)); |
| 379 EXPECT_FALSE(tryCatch.HasCaught()); | 379 EXPECT_FALSE(tryCatch.HasCaught()); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace | 382 } // namespace |
| 383 | 383 |
| 384 } // namespace blink | 384 } // namespace blink |
| OLD | NEW |