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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ScriptStreamer.h" | 6 #include "bindings/core/v8/ScriptStreamer.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptStreamerThread.h" | 8 #include "bindings/core/v8/ScriptStreamerThread.h" |
9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 SourceStream(ScriptStreamer* streamer) | 90 SourceStream(ScriptStreamer* streamer) |
91 : v8::ScriptCompiler::ExternalSourceStream() | 91 : v8::ScriptCompiler::ExternalSourceStream() |
92 , m_streamer(streamer) | 92 , m_streamer(streamer) |
93 , m_cancelled(false) | 93 , m_cancelled(false) |
94 , m_dataPosition(0) { } | 94 , m_dataPosition(0) { } |
95 | 95 |
96 virtual ~SourceStream() { } | 96 virtual ~SourceStream() { } |
97 | 97 |
98 // Called by V8 on a background thread. Should block until we can return | 98 // Called by V8 on a background thread. Should block until we can return |
99 // some data. | 99 // some data. |
100 virtual size_t GetMoreData(const uint8_t** src) OVERRIDE | 100 virtual size_t GetMoreData(const uint8_t** src) override |
101 { | 101 { |
102 ASSERT(!isMainThread()); | 102 ASSERT(!isMainThread()); |
103 { | 103 { |
104 MutexLocker locker(m_mutex); | 104 MutexLocker locker(m_mutex); |
105 if (m_cancelled) | 105 if (m_cancelled) |
106 return 0; | 106 return 0; |
107 } | 107 } |
108 size_t length = 0; | 108 size_t length = 0; |
109 // This will wait until there is data. | 109 // This will wait until there is data. |
110 m_dataQueue.consume(src, &length); | 110 m_dataQueue.consume(src, &length); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if (scriptStreamingTask) { | 427 if (scriptStreamingTask) { |
428 streamer->m_task = adoptPtr(scriptStreamingTask); | 428 streamer->m_task = adoptPtr(scriptStreamingTask); |
429 script.setStreamer(streamer.release()); | 429 script.setStreamer(streamer.release()); |
430 return true; | 430 return true; |
431 } | 431 } |
432 // Otherwise, V8 cannot stream the script. | 432 // Otherwise, V8 cannot stream the script. |
433 return false; | 433 return false; |
434 } | 434 } |
435 | 435 |
436 } // namespace blink | 436 } // namespace blink |
OLD | NEW |