| 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 #include "bindings/core/v8/ScriptStreamer.h" | 5 #include "bindings/core/v8/ScriptStreamer.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
| 8 #include "bindings/core/v8/ScriptStreamerThread.h" | 8 #include "bindings/core/v8/ScriptStreamerThread.h" |
| 9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 public: | 28 public: |
| 29 ScriptStreamingTest() | 29 ScriptStreamingTest() |
| 30 : m_loadingTaskRunner(Platform::current() | 30 : m_loadingTaskRunner(Platform::current() |
| 31 ->currentThread() | 31 ->currentThread() |
| 32 ->scheduler() | 32 ->scheduler() |
| 33 ->loadingTaskRunner()), | 33 ->loadingTaskRunner()), |
| 34 m_settings(Settings::create()), | 34 m_settings(Settings::create()), |
| 35 m_resourceRequest("http://www.streaming-test.com/"), | 35 m_resourceRequest("http://www.streaming-test.com/"), |
| 36 m_resource(ScriptResource::create(m_resourceRequest, "UTF-8")), | 36 m_resource(ScriptResource::create(m_resourceRequest, "UTF-8")), |
| 37 m_pendingScript(PendingScript::create(0, m_resource.get())) { | 37 m_pendingScript(PendingScript::create(0, m_resource.get())) { |
| 38 m_resource->setStatus(Resource::Pending); | 38 m_resource->setStatus(ResourceStatus::Pending); |
| 39 m_pendingScript = PendingScript::create(0, m_resource.get()); | 39 m_pendingScript = PendingScript::create(0, m_resource.get()); |
| 40 ScriptStreamer::setSmallScriptThresholdForTesting(0); | 40 ScriptStreamer::setSmallScriptThresholdForTesting(0); |
| 41 } | 41 } |
| 42 | 42 |
| 43 ~ScriptStreamingTest() { | 43 ~ScriptStreamingTest() { |
| 44 if (m_pendingScript) | 44 if (m_pendingScript) |
| 45 m_pendingScript->dispose(); | 45 m_pendingScript->dispose(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 PendingScript* getPendingScript() const { return m_pendingScript.get(); } | 48 PendingScript* getPendingScript() const { return m_pendingScript.get(); } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 for (int i = 0; i < 10; ++i) { | 62 for (int i = 0; i < 10; ++i) { |
| 63 appendData( | 63 appendData( |
| 64 " /* this is padding to make the script long enough, so " | 64 " /* this is padding to make the script long enough, so " |
| 65 "that V8's buffer gets filled and it starts processing " | 65 "that V8's buffer gets filled and it starts processing " |
| 66 "the data */ "); | 66 "the data */ "); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 void finish() { | 70 void finish() { |
| 71 m_resource->finish(); | 71 m_resource->finish(); |
| 72 m_resource->setStatus(Resource::Cached); | 72 m_resource->setStatus(ResourceStatus::Cached); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void processTasksUntilStreamingComplete() { | 75 void processTasksUntilStreamingComplete() { |
| 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(); |
| 82 } | 82 } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 v8::TryCatch tryCatch(scope.isolate()); | 385 v8::TryCatch tryCatch(scope.isolate()); |
| 386 v8::Local<v8::Script> script; | 386 v8::Local<v8::Script> script; |
| 387 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, scope.isolate()) | 387 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, scope.isolate()) |
| 388 .ToLocal(&script)); | 388 .ToLocal(&script)); |
| 389 EXPECT_FALSE(tryCatch.HasCaught()); | 389 EXPECT_FALSE(tryCatch.HasCaught()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace | 392 } // namespace |
| 393 | 393 |
| 394 } // namespace blink | 394 } // namespace blink |
| OLD | NEW |