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 <memory> | 7 #include <memory> |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 | 134 |
135 void Consume(const uint8_t** data, size_t* length) { | 135 void Consume(const uint8_t** data, size_t* length) { |
136 MutexLocker locker(mutex_); | 136 MutexLocker locker(mutex_); |
137 while (!TryGetData(data, length)) | 137 while (!TryGetData(data, length)) |
138 have_data_.Wait(mutex_); | 138 have_data_.Wait(mutex_); |
139 } | 139 } |
140 | 140 |
141 private: | 141 private: |
142 bool TryGetData(const uint8_t** data, size_t* length) { | 142 bool TryGetData(const uint8_t** data, size_t* length) { |
143 ASSERT(mutex_.Locked()); | 143 DCHECK(mutex_.Locked()); |
144 if (!data_.IsEmpty()) { | 144 if (!data_.IsEmpty()) { |
145 std::pair<const uint8_t*, size_t> next_data = data_.TakeFirst(); | 145 std::pair<const uint8_t*, size_t> next_data = data_.TakeFirst(); |
146 *data = next_data.first; | 146 *data = next_data.first; |
147 *length = next_data.second; | 147 *length = next_data.second; |
148 return true; | 148 return true; |
149 } | 149 } |
150 if (finished_) { | 150 if (finished_) { |
151 *length = 0; | 151 *length = 0; |
152 return true; | 152 return true; |
153 } | 153 } |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 // needed. This makes PendingScript notify the ScriptStreamer when it is | 617 // needed. This makes PendingScript notify the ScriptStreamer when it is |
618 // destroyed. | 618 // destroyed. |
619 script->SetStreamer(ScriptStreamer::Create(script, script_type, script_state, | 619 script->SetStreamer(ScriptStreamer::Create(script, script_type, script_state, |
620 compile_option, | 620 compile_option, |
621 std::move(loading_task_runner))); | 621 std::move(loading_task_runner))); |
622 | 622 |
623 return true; | 623 return true; |
624 } | 624 } |
625 | 625 |
626 } // namespace blink | 626 } // namespace blink |
OLD | NEW |