Changeset 186044 in webkit
- Timestamp:
- Jun 28, 2015 5:39:48 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r186040 r186044 1 2015-06-28 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Streams API] Add support for chunks with customized sizes 4 https://bugs.webkit.org/show_bug.cgi?id=146312 5 6 Reviewed by Darin Adler. 7 8 * streams/reference-implementation/bad-strategies-expected.txt: 9 1 10 2015-06-27 David Kilzer <ddkilzer@apple.com> 2 11 -
trunk/LayoutTests/streams/reference-implementation/bad-strategies-expected.txt
r185953 r186044 1 1 2 2 PASS Readable stream: throwing strategy.size getter 3 FAIL Readable stream: throwing strategy.size method assert_throws: enqueue should throw the error function "function () { c.enqueue('a'); }" did not throw 3 PASS Readable stream: throwing strategy.size method 4 4 PASS Readable stream: throwing strategy.highWaterMark getter 5 5 PASS Readable stream: invalid strategy.highWaterMark 6 6 PASS Readable stream: negative strategy.highWaterMark 7 FAIL Readable stream: strategy.size returning NaN assert_equals: enqueue should throw a RangeError expected function "function RangeError() { 8 [native code] 9 }" but got function "function AssertionError(message) 10 { 11 this.messa..." 12 FAIL Readable stream: strategy.size returning -Infinity assert_equals: enqueue should throw a RangeError expected function "function RangeError() { 13 [native code] 14 }" but got function "function AssertionError(message) 15 { 16 this.messa..." 17 FAIL Readable stream: strategy.size returning +Infinity assert_equals: enqueue should throw a RangeError expected function "function RangeError() { 18 [native code] 19 }" but got function "function AssertionError(message) 20 { 21 this.messa..." 7 PASS Readable stream: strategy.size returning NaN 8 PASS Readable stream: strategy.size returning -Infinity 9 PASS Readable stream: strategy.size returning +Infinity 22 10 -
trunk/Source/WebCore/ChangeLog
r186043 r186044 1 2015-06-28 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Streams API] Add support for chunks with customized sizes 4 https://bugs.webkit.org/show_bug.cgi?id=146312 5 6 Reviewed by Darin Adler. 7 8 Covered by rebased tests. 9 10 * bindings/js/ReadableJSStream.cpp: 11 (WebCore::ReadableJSStream::read): Decrement totalQueueSize with the chunk specific size. 12 (WebCore::ReadableJSStream::enqueue): Calls retrieveSize, enqueue chunk with its size and increment totalQueueSize. 13 (WebCore::ReadableJSStream::retrieveChunkSize): Calls size JS callback and convert it to double. 14 * bindings/js/ReadableJSStream.h: 15 1 16 2015-06-28 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 17 -
trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp
r186043 r186044 324 324 ASSERT(hasValue()); 325 325 326 return m_chunkQueue.takeFirst().get(); 327 } 328 329 void ReadableJSStream::enqueue(ExecState& exec) 326 Chunk chunk = m_chunkQueue.takeFirst(); 327 m_totalQueueSize -= chunk.size; 328 329 return chunk.value.get(); 330 } 331 332 void ReadableJSStream::enqueue(ExecState& state) 330 333 { 331 334 ASSERT(!isCloseRequested()); … … 334 337 return; 335 338 336 JSValue chunk = exec.argumentCount() ? exec.argument(0) : jsUndefined();339 JSValue chunk = state.argument(0); 337 340 if (resolveReadCallback(chunk)) { 338 341 pull(); … … 340 343 } 341 344 342 m_chunkQueue.append(JSC::Strong<JSC::Unknown>(exec.vm(), chunk)); 343 // FIXME: Compute chunk size. 345 double size = retrieveChunkSize(state, chunk); 346 if (state.hadException()) { 347 storeError(state, state.exception()->value()); 348 return; 349 } 350 351 m_chunkQueue.append({ JSC::Strong<JSC::Unknown>(state.vm(), chunk), size }); 352 m_totalQueueSize += size; 353 344 354 pull(); 345 355 } 346 356 357 double ReadableJSStream::retrieveChunkSize(ExecState& state, JSValue chunk) 358 { 359 if (!m_sizeFunction) 360 return 1; 361 362 MarkedArgumentBuffer arguments; 363 arguments.append(chunk); 364 365 JSValue sizeValue = callFunction(state, m_sizeFunction.get(), jsUndefined(), arguments); 366 if (state.hadException()) 367 return 0; 368 369 double size = sizeValue.toNumber(&state); 370 if (state.hadException()) 371 return 0; 372 373 if (!std::isfinite(size)) { 374 throwVMError(&state, createRangeError(&state, ASCIILiteral("Incorrect double value"))); 375 return 0; 376 } 377 378 return size; 379 } 380 347 381 } // namespace WebCore 348 382 -
trunk/Source/WebCore/bindings/js/ReadableJSStream.h
r186043 r186044 65 65 void enqueue(JSC::ExecState&); 66 66 67 double desiredSize() const { return m_highWaterMark - m_ chunkQueue.size(); }67 double desiredSize() const { return m_highWaterMark - m_totalQueueSize; } 68 68 69 69 private: … … 83 83 JSDOMGlobalObject* globalObject(); 84 84 85 double retrieveChunkSize(JSC::ExecState&, JSC::JSValue); 86 85 87 std::unique_ptr<ReadableStreamController> m_controller; 86 88 // FIXME: we should consider not using JSC::Strong, see https://bugs.webkit.org/show_bug.cgi?id=146278 … … 88 90 JSC::Strong<JSC::JSFunction> m_errorFunction; 89 91 JSC::Strong<JSC::JSObject> m_source; 90 Deque<JSC::Strong<JSC::Unknown>> m_chunkQueue; 92 93 struct Chunk { 94 JSC::Strong<JSC::Unknown> value; 95 double size; 96 }; 97 Deque<Chunk> m_chunkQueue; 98 99 double m_totalQueueSize { 0 }; 91 100 double m_highWaterMark; 92 101 JSC::Strong<JSC::JSFunction> m_sizeFunction;
Note: See TracChangeset
for help on using the changeset viewer.