Overview.htm
changeset 137 142342673c3f
parent 136 351c58f63ce5
child 138 6cc871794be1
equal deleted inserted replaced
136:351c58f63ce5 137:142342673c3f
   385 		<p>
   385 		<p>
   386 			The WritableStream interface defines a protocol for APIs which consume a data stream.
   386 			The WritableStream interface defines a protocol for APIs which consume a data stream.
   387 			The protocol includes:
   387 			The protocol includes:
   388 			<ol>
   388 			<ol>
   389 				<li>How to receive data stream</li>
   389 				<li>How to receive data stream</li>
   390 				<li>How to notify the writer of completion of writing</li>
   390 				<li>How to notify the writer (data producing code) of completion of writing</li>
   391 				<li>How to notify the writer of how much data can be accepted currently</li>
   391 				<li>How to notify the writer of how much data can be accepted currently</li>
   392 			</ol>
   392 			</ol>
   393 
   393 
   394 			By returning a <a>Promise</a> and delaying fulfillment of it, the WritableStream realizes flow control.
   394 			By returning a <a>Promise</a> and delaying fulfillment of it, the WritableStream realizes flow control.
   395 		</p>
   395 		</p>
   494 					</p>
   494 					</p>
   495 
   495 
   496 					<p>
   496 					<p>
   497 						This method must run the steps below:
   497 						This method must run the steps below:
   498 						<ol>
   498 						<ol>
   499 							<li><a>Abort waiting</a></li>
   499 							<li><a>Abort awaitSpace</a></li>
   500 							<li>Set <a>awaitSpacePromise</a> to a newly-created <a>Promise</a></li>
   500 							<li>Set <a>awaitSpacePromise</a> to a newly-created <a>Promise</a></li>
   501 							<li>Return <a>awaitSpacePromise</a></li>
   501 							<li>Return <a>awaitSpacePromise</a></li>
   502 						</ol>
   502 						</ol>
   503 					</p>
   503 					</p>
   504 				</dd>
   504 				</dd>
   613 				A WritableStream has an associated <a>Promise</a> <dfn>awaitSpacePromise</dfn> which is used by the <code>awaitSpaceAvailable()</code> method.
   613 				A WritableStream has an associated <a>Promise</a> <dfn>awaitSpacePromise</dfn> which is used by the <code>awaitSpaceAvailable()</code> method.
   614 				This variable is initialized to <code>null</code> on construction.
   614 				This variable is initialized to <code>null</code> on construction.
   615 			</p>
   615 			</p>
   616 
   616 
   617 			<p>
   617 			<p>
   618 				To <dfn>abort waiting</dfn>, run the steps below:
   618 				To <dfn>abort awaitSpace</dfn>, run the steps below:
   619 				<ol>
   619 				<ol>
   620 					<li>If <a>awaitSpacePromise</a> is <code>null</code>, terminate these steps</li>
   620 					<li>If <a>awaitSpacePromise</a> is <code>null</code>, terminate these steps</li>
   621 					<li>Let <var>detachedWaitPromise</var> be <a>awaitSpacePromise</a></li>
   621 					<li>Let <var>detachedWaitPromise</var> be <a>awaitSpacePromise</a></li>
   622 					<li>Set <a>awaitSpacePromise</a> to <code>null</code></li>
   622 					<li>Set <a>awaitSpacePromise</a> to <code>null</code></li>
   623 					<li>Reject <var>detachedWaitPromise</var> with an "<code><a>AbortError</a></code>"</li>
   623 					<li>Reject <var>detachedWaitPromise</var> with an "<code><a>AbortError</a></code>"</li>
   725 		<h2>ReadableStream Interface</h2>
   725 		<h2>ReadableStream Interface</h2>
   726 		<p>
   726 		<p>
   727 			The ReadableStream interface defines a protocol for APIs which produce a data stream.
   727 			The ReadableStream interface defines a protocol for APIs which produce a data stream.
   728 			This protocol includes:
   728 			This protocol includes:
   729 			<ol>
   729 			<ol>
   730 				<li>How to receive a read request from the reader and pass output data to the reader</li>
   730 				<li>How to receive read requests from the reader (data consuming code) and pass output data to the reader</li>
   731 				<li>How to transfer data in bulk to another <a>WritableStream</a> (by using the <code>pipe()</code> method)</li>
   731 				<li>How to transfer data in bulk to another <a>WritableStream</a> (by using the <code>pipe()</code> method)</li>
   732 				<li>How to mirror data to multiple destinations (by using the <code>fork()</code>)</li>
   732 				<li>How to mirror data to multiple destinations (by using the <code>fork()</code>)</li>
   733 			</ol>
   733 			</ol>
   734 
   734 
   735 			By returning a <a>Promise</a> and delaying fulfillment of it, the ReadableStream realizes asynchronous data consumption.
   735 			By returning a <a>Promise</a> and delaying fulfillment of it, the ReadableStream realizes asynchronous data consumption.
   752 				<dt>attribute StreamReadType readBinaryAs</dt>
   752 				<dt>attribute StreamReadType readBinaryAs</dt>
   753 				<dd>
   753 				<dd>
   754 					<p>
   754 					<p>
   755 						Specifies what data type will be returned by a <code>read()</code> and <code>readUpTo()</code> method call.
   755 						Specifies what data type will be returned by a <code>read()</code> and <code>readUpTo()</code> method call.
   756 						This attribute can be set to any of the supported types in <a>StreamReadType</a>.
   756 						This attribute can be set to any of the supported types in <a>StreamReadType</a>.
   757 						The default value for this attribute is "<code>arraybuffer</code>".
   757 					<p>
   758 					</p>
   758 					</p>
   759 					<p>
   759 						The default value for this attribute is "<code>as-is</code>".
   760 						This attribute works only when the data to be read from the ReadableStream represents binary data.
   760 					</p>
       
   761 					<p>
       
   762 						Values other than "<code>as-is</code>" works only when the data to be read from the ReadableStream represents binary data.
   761 					</p>
   763 					</p>
   762 				</dd>
   764 				</dd>
   763 
   765 
   764 				<dt>attribute DOMString readEncoding</dt>
   766 				<dt>attribute DOMString readEncoding</dt>
   765 				<dd>
   767 				<dd>
   778 
   780 
   779 				<dt>attribute unsigned long long pullAmount</dt>
   781 				<dt>attribute unsigned long long pullAmount</dt>
   780 				<dd>
   782 				<dd>
   781 					<p>
   783 					<p>
   782 						This attribute provides the ReadableStream with a hint of how much data the reader can consume currently.
   784 						This attribute provides the ReadableStream with a hint of how much data the reader can consume currently.
       
   785 					</p>
       
   786 					<p>
   783 						Each implementation of the ReadableStream must initialize the value of pullAmount on construction.
   787 						Each implementation of the ReadableStream must initialize the value of pullAmount on construction.
   784 					</p>
   788 					</p>
   785 
   789 
   786 					<p>
   790 					<p>
   787 						When this attribute is set, <a>retrieve data</a>.
   791 						When this attribute is set, the user agent must <a>retrieve data</a>.
   788 					</p>
   792 					</p>
   789 
   793 
   790 					<section class="note">
   794 					<section class="note">
   791 						This flow control functionality is provided as a separated attribute rather than as an argument of the read() method based on the assumption that this value is not changed frequently.
   795 						This flow control functionality is provided as a separated attribute rather than as an argument of the read() method based on the assumption that this value is not changed frequently.
   792 					</section>
   796 					</section>
   909 
   913 
   910 						<ol>
   914 						<ol>
   911 							<li>If <a>readPending</a> is set, return a <a>Promise</a> rejected with an "<code><a>InvalidStateError</a></code>"</li>
   915 							<li>If <a>readPending</a> is set, return a <a>Promise</a> rejected with an "<code><a>InvalidStateError</a></code>"</li>
   912 							<li>Set <a>readPending</a></li>
   916 							<li>Set <a>readPending</a></li>
   913 
   917 
   914 							<li>Run <a>abort waiting</a> algorithm on <var>destination</var></a>
   918 							<li>Run <a>abort awaitSpace</a> algorithm on <var>destination</var></a>
   915 
   919 
   916 							<li>Set <a>amountBeingReturned</a> to 0</li>
   920 							<li>Set <a>amountBeingReturned</a> to 0</li>
   917 
   921 
   918 							<li><a>Retrieve data</a></li>
   922 							<li><a>Retrieve data</a></li>
   919 
   923 
   968 													Need to revisit. Finish when write to the destination completes?
   972 													Need to revisit. Finish when write to the destination completes?
   969 												</section>
   973 												</section>
   970 											</li>
   974 											</li>
   971 										</ol>
   975 										</ol>
   972 									</li>
   976 									</li>
       
   977 
   973 									<li>
   978 									<li>
   974 										Whenever <a>pendingWriteQueue</a> of <var>destination</var> is empty and <a>spaceAvailable</a> of <var>destination</var> is not 0,
   979 										Whenever <a>pendingWriteQueue</a> of <var>destination</var> is empty and <a>spaceAvailable</a> of <var>destination</var> is not 0,
   975 										<dl class="switch">
   980 										<dl class="switch">
   976 											<dt>If this happened in the event loop</dt>
   981 											<dt>If this happened in the event loop</dt>
   977 											<dd>Run the steps below</dd>
   982 											<dd>Run the steps below</dd>