Overview.htm
author Takeshi Yoshino <tyoshino@google.com>
Fri, 10 Jan 2014 23:04:10 +0900
changeset 127 bf65397910b7
parent 126 be34c357de7f
child 128 56491a744f4d
permissions -rw-r--r--
More rewriting
38
3cdd8b2d21d9 Merging changes made for preparing WD
Takeshi Yoshino <tyoshino@google.com>
parents: 37
diff changeset
     1
<!DOCTYPE html>
8
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
     2
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
     3
<html>
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
     4
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
     5
<head>
83
afed6501a898 moved images, fixed typos, fixed header
fmoussa <feras.moussa@hotmail.com>
parents: 81
diff changeset
     6
	<title>Streams API</title>
11
f99aafc91a32 First complete update to prep for FPWD
fmoussa <feras.moussa@hotmail.com>
parents: 10
diff changeset
     7
	<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
     8
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
     9
	<!-- <script class=remove src="http://dev.w3.org/2009/dap/ReSpec.js/js/respec.js"></script> -->
10
bbfec9730bc4 Resolving respec js file path
fmoussa <feras.moussa@hotmail.com>
parents: 8
diff changeset
    10
	<script class="remove" src="https://www.w3.org/Tools/respec/respec-w3c-common"></script>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    11
	<!-- <script class="remove" src="respec-w3c-common.js"></script> -->
8
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
    12
10
bbfec9730bc4 Resolving respec js file path
fmoussa <feras.moussa@hotmail.com>
parents: 8
diff changeset
    13
	<script class="remove">
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    14
var respecConfig = {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    15
	// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    16
	specStatus:           "ED",
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
    17
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    18
	// the specification's short name, as in http://www.w3.org/TR/short-name/
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    19
	shortName:            "streams-api",
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
    20
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    21
	// if your specification has a subtitle that goes below the main
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    22
	// formal title, define it here
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    23
	// subtitle   :  "an excellent document",
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
    24
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    25
	// if you wish the publication date to be other than today, set this
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    26
	// publishDate:  "yyyy-mm-dd",
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
    27
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    28
	// if the specification's copyright date is a range of years, specify
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    29
	// the start date here:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    30
	// copyrightStart: "2005"
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    31
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    32
	// if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    33
	// and its maturity status
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    34
	// previousPublishDate:  "yyyy-mm-dd",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    35
	// previousMaturity:  "WD",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    36
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    37
	// if there a publicly available Editor's Draft, this is the link
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    38
	edDraftURI:           "http://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    39
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    40
	// if this is a LCWD, uncomment and set the end of its review period
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    41
	// lcEnd: "2009-08-05",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    42
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    43
	// if you want to have extra CSS, append them to this list
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    44
	// it is recommended that the respec.css stylesheet be kept
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    45
	//extraCSS:             ["http://dev.w3.org/2009/dap/ReSpec.js/css/respec.css",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    46
	//	"http://www.w3.org/StyleSheets/TR/W3C-ED.css",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    47
	//	],
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    48
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    49
	// editors, add as many as you like
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    50
	// only "name" is required
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    51
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    52
	localBiblio: {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    53
		"EncodingDetermination": {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    54
			title: "Encoding",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    55
			href: "http://encoding.spec.whatwg.org/",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    56
			authors: ["Anne van Kesteren", "Joshua Bell"],
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    57
			publisher: "WHATWG"
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    58
		}
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    59
	},
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    60
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    61
	editors:  [
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    62
		{ name: "Feras Moussa", url: "mailto:feras.moussa@hotmail.com",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    63
			company: "Invited Expert",  },
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    64
		{ name: "Takeshi Yoshino", url: "mailto:tyoshino@google.com",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    65
			company: "Google, Inc.",  },
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    66
	],
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    67
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    68
	// authors, add as many as you like.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    69
	// This is optional, uncomment if you have authors as well as editors.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    70
	// only "name" is required. Same format as editors.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    71
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    72
	//authors:  [
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    73
	//    { name: "Your Name", url: "http://example.org/",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    74
	//      company: "Your Company", companyURL: "http://example.com/" },
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    75
	//],
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    77
	// name of the WG
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    78
	wg:           "W3C Web Applications (WebApps)",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    79
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    80
	// URI of the public WG page
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    81
	wgURI:        "http://www.w3.org/2008/webapps/",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    82
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    83
	// name (with the @w3c.org) of the public mailing to which comments are due
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    84
	wgPublicList: "public-webapps",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    85
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    86
	// URI of the patent status for this WG, for Rec-track documents
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    87
	// !!!! IMPORTANT !!!!
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    88
	// This is important for Rec-track documents, do not copy a patent URI from a random
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    89
	// document unless you know what you're doing. If in doubt ask your friendly neighbourhood
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    90
	// Team Contact.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    91
	wgPatentURI:  "",
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    92
};
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    93
</script>
8
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
    94
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
    95
	<!-- Styles to mimic File API spec -->
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    96
	<!-- <style type="text/css"> -->
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    97
	<!-- 	table.error { border-collapse:collapse; border-style:hidden hidden none hidden } -->
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    98
	<!-- 	table.error thead { border-bottom:solid } -->
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
    99
	<!-- 	table.error tbody th:first-child { border-left:solid } -->
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   100
	<!-- 	table.error td, table th { border-left:solid; border-right:solid; border-bottom:solid thin; vertical-align:top; padding:0.2em } -->
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   101
	<!-- </style> -->
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   102
7
4a496b9c9944 fixed issue with resolving css file
fmoussa <feras.moussa@hotmail.com>
parents: 6
diff changeset
   103
</head>
8
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
   104
<body>
35
1e0b2c48a167 Added sotd
fmoussa <feras.moussa@hotmail.com>
parents: 27
diff changeset
   105
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   106
	<section id="sotd">
46
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   107
		<p>
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   108
			This document is not complete.
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   109
			It is subject to major changes and, while early experimentations are encouraged, it is therefore not intended for implementation.
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   110
		</p>
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   111
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   112
		<p>
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   113
			To check recent changes and rationale for them, please visit <a href="https://dvcs.w3.org/hg/streams-api/">Mercurial history</a>.
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   114
			Check open bugs at Bugzilla using <a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=Streams%20API">this link</a>.
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   115
			If you wish to submit a bug, please use <a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WebAppsWG&component=Streams%20API">this link</a>.
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   116
			All comments and bug reports are welcome.
d9d23bed8517 Add links to Bugzilla listing and entering UI.
Takeshi Yoshino <tyoshino@google.com>
parents: 45
diff changeset
   117
		</p>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   118
	</section>
35
1e0b2c48a167 Added sotd
fmoussa <feras.moussa@hotmail.com>
parents: 27
diff changeset
   119
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   120
	<section id="abstract">
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   121
		<p>
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   122
			This specification provides an API for representing a stream of data in web applications, as well as programmatically reading and writing it.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   123
			This includes:
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   124
		</p>
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   125
		<ul>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   126
			<li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   127
				An interface named <a>WritableStream</a> which defines a general protocol for data consuming APIs (<a href="#consumers">consumers</a>) to communicate with data producing code (<a href="#producers">producers</a>).
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   128
			</li>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   129
			<li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   130
				An interface named <a>ReadableStream</a> which defines a general protocol for data producing APIs to communicate with data consuming code.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   131
			</li>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   132
			<li>
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   133
				An interface named <a>ByteStream</a> which inherits both WritableStream and ReadableStream and represents a sequence of data.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   134
			</li>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   135
			<li>
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   136
				A struct type named <a>StreamReadResult</a> which represents the result of consuming operations such as <code>read()</code> and <code>pipe()</code>.
125
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   137
				It holds:
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   138
				<ul>
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   139
					<li>Chunk of content read from a <a>ReadableStream</a></li>
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   140
					<li>The total cost of the chunk</li>
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   141
					<li>EOF signal</li>
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   142
					<li>Error info</li>
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   143
				</ul>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   144
			</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   145
			<li>
125
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   146
				An enum <a>StreamReadType</a> which represents data types as which data can be read from a <a>ReadableStream</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   147
			</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   148
			<li>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   149
				A list of notable data <a href="#producers">producers</a> and <a href="#consumers">consumers</a> for which we can apply either or both of <a>ReadableStream</a> and <a>WritableStream</a> model.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   150
			</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   151
			<li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   152
				Extensions to <a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-xmlhttprequest-interface">XMLHttpRequest</a> [[!XMLHTTPREQUEST2]] to add support for uploading data via <a>WritableStream</a> and downloading a response as a <a>ReadableStream</a>.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   153
			</li>
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   154
			<li>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   155
				Extensions to <a href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-createObjectURL">URL.createObjectURL</a> and <a href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-revokeObjectURL">URL.revokeObjectURL</a> to add support for <a>ReadableStream</a>.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   156
			</li>
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   157
		</ul>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   158
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   159
		<p>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   160
			This API is designed to be used in conjunction with other APIs and elements on the web platform, notably:
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   161
			<ul>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   162
				<li><a href="http://dev.w3.org/2006/webapi/FileAPI">FileAPI</a> [[!FILE-API]]</li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   163
				<li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   164
					<a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2">XMLHttpRequest</a>.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   165
					E.g. with an overloaded <a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-send-method"><code>send()</code></a> method and <a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-responsetype-attribute"><code>response</code></a> object for <a>ReadableStream</a> objects) [[!XMLHTTPREQUEST2]].
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   166
				</li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   167
				<li><a href="http://dev.w3.org/html5/postmsg/#dom-window-postmessage"><code>postMessage</code></a></li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   168
				<li>Web Workers [[!WEBWORKERS]]</li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   169
			</ul>
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   170
		</p>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   171
	</section>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   172
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   173
	<section id="introduction" class="section informative">
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   174
		<h2>Introduction</h2>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   175
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   176
		<p>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   177
			Web applications should have the ability to acquire, manipulate, and pass data in a wide variety of forms, including as a sequence of data made available over time.
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   178
			This specification defines the basic representation for streams of data, and programmatic ways to read and write streams of data and errors raised on those operations.
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   179
		</p>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   180
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   181
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   182
			The <a>WritableStream</a> interface defines a general protocol for <a href="#consumers">data consuming APIs</a> to communicate with data producing code.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   183
			In these cases, the data consuming API, such as a decoder, provides a <a>WritableStream</a> for other applications to write to, enabling the decoder to begin decoding data as it becomes available.
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   184
			The data is written to the internal data sink inside the data consuming API using:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   185
			<ul>
87
dcf26e7c77fe Break at the end of each sentence.
Takeshi Yoshino <tyoshino@google.com>
parents: 86
diff changeset
   186
				<li>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   187
					The <code>write()</code> method which writes the given data to the data sink
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   188
				</li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   189
				<li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   190
					The <code>awaitSpaceAvailable()</code> method which allows a data producing code to write data to the data consuming API only when its data sink is available to consume more data.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   191
					This is useful for cases where an app may want to avoid filling the internal buffer.
87
dcf26e7c77fe Break at the end of each sentence.
Takeshi Yoshino <tyoshino@google.com>
parents: 86
diff changeset
   192
				</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   193
			</ul>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   194
			Actual transfer of data to the data sink may happen either synchronously or asynchronously.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   195
			<a>WritableStream</a> hides the details of actual communication with the data sink while allowing for an efficient transfer of data.
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   196
		</p>
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   197
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   198
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   199
			The <a>ReadableStream</a> interface defines a general protocol for <a href="#producers">data producing APIs</a> to communicate with data consuming code.
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   200
			This interface represents the potential for an infinite amount of data which are obtained over time and read once.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   201
			Data consuming code reads data from the internal data source inside the data producing API using:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   202
			<ul>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   203
				<li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   204
					The <code>read()</code> and <code>readUpTo()</code> methods which reads data from the data source
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   205
				</li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   206
				<li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   207
					The <code>pullAmount</code> attribute which paces data retrieval from the data source
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   208
				</li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   209
				<li>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   210
					The <code>pipe()</code> method which transfers data in bulk from the data source into the data sink of another API which implements <a>WritableStream</a>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   211
				</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   212
			</ul>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   213
			Actual transfer of data from the data source may happen either synchronously or asynchronously.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   214
			The <a>ReadableStream</a> hides the details of actual communication with the data source while allowing for an efficient transfer of data.
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   215
		</p>
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   216
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   217
		<p>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   218
			With the combination of the following features, this interface suite responds to various simple and complex needs of data stream handling.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   219
			<ul>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   220
				<li>Delayed notification of completion by using <a>Promise</a>s. See below for more details.</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   221
				<li>Explicit back pressure management by propagating room for consumption back to producers</li>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   222
				<li><a>WritableStream</a> always accepts incoming data synchronously to bridge with legacy APIs that don't understand backpressure</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   223
			</ul>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   224
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   225
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   226
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   227
			The <a>ByteStream</a> is a simple implementation of both the <a>WritableStream</a> and <a>ReadableStream</a> interface.
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   228
			A ByteStream has a single queue of bytes which works as a data sink for the WritableStream interface and as a data source for the ReadableStream interface.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   229
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   230
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   231
		<p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   232
			Read and write operations on these interfaces are implemented using <a>Promise</a>.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   233
			When an operation completes, the Promise returned by a method will be fulfilled, and then the fulfill callback set to the Promise will handle the result.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   234
			Error conditions that may arise during an operation will be handled by the reject callback set to the Promise.
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   235
		</p>
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   236
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   237
		<p>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   238
			Examples below will be illustrative.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   239
		</p>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   240
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   241
		<p>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   242
			The example below demonstrates how to read a chunk of data from a <a>ReadableStream</a> using <code>read()</code>.
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   243
			The <a>ReadableStream</a> may of come from a <a href="#producers">producer</a> such as <code>XMLHttpRequest</code>.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   244
		</p>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   245
77
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   246
		<pre class="example">
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   247
// Tell stream that we're ready to consume 1024 bytes.
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   248
stream.pullAmount = 1024;
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   249
stream.readEncoding = "UTF-8";
121
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   250
stream.readBinaryAs = "arraybuffer";
77
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   251
stream.read().then(
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   252
  function (result) {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   253
    // Process data
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   254
  },
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   255
  function (error) {
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   256
    // Handle error
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   257
  });</pre>
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   258
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   259
		<p>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   260
			The example below demonstrates how to read bytes from a <a>ReadableStream</a> until an EOF is encountered.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   261
		</p>
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   262
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   263
		<pre class="example">// Read data from the ReadableStream repeatedly
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   264
function readUntilEof() {
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   265
  stream.read().then(
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   266
    function (result) {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   267
      processData(result.data);
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   268
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   269
      if (!result.eof) {
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   270
        readUntilEof();
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   271
      }
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   272
    },
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   273
    function (error) {
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   274
      // Handle error
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   275
    });
8
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
   276
}
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   277
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   278
readUntilEof();</pre>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   279
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   280
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   281
			The example below demonstrates how to obtain a <a>ReadableStream</a> from <a>XMLHttpRequest</a> to begin playing a large video in <code>readystate</code> LOADING.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   282
			The example takes the <a>ReadableStream</a> from a <a href="#producers">producer</a>, <a>XMLHttpRequest</a>, and gives it to a <a href="#consumers">consumer</a>, the video tag.
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   283
			If the consumer implements the <a>WritableStream</a> interface, we could use <code>pipe()</code> to transfer data to it instead of URL.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   284
		</p>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   285
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   286
		<pre class="example">function handler() {
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   287
  if(this.readyState == this.LOADING) {
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   288
    var theStream = this.response;
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   289
    var streamURL = URL.createObjectURL(theStream);
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   290
    document.getElementById("myVideoTag").src = streamURL;
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   291
  }
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   292
}
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   293
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   294
var client = new XMLHttpRequest();
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   295
client.onreadystatechange = handler;
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   296
client.setRequestHeader('customHeader', 'value');
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   297
client.setRequestHeader('customHeader2', 'value2');
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   298
client.open("GET", "myvideo.h264");
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   299
client.responseType = "stream";
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   300
client.send();</pre>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   301
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   302
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   303
			The example below demonstrates how to use <code>write()</code> to load a <a>ReadableStream</a> into the audio tag, whose data could be processed and built dynamically at read time.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   304
			ByteStream in the example is a class which implements both <a>WritableStream</a> and <a>ReadableStream</a>.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   305
			It accepts bytes generated by the code via <a>WritableStream</a> methods, and the written data will be consumed by the audio element via the object URL which is a part of <a>ReadableStream</a>'s functionality.
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   306
		</p>
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   307
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   308
		<pre class="example">var stream = new ByteStream("audio/mp3");
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   309
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   310
function writeData() {
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   311
  // Do work to create more data to place into the stream
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   312
  var data = generateMusic();
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   313
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   314
  // If we have no more data to process and place in the stream, we close
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   315
  if (moreData == null){
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   316
    stream.writeClose();
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   317
  } else{
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   318
    // Wait until write() completes.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   319
    stream.write(data).then(
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   320
      function () {
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   321
        writeData();
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   322
      },
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   323
      function (error) {
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   324
        // Handle error
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   325
      }
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   326
    );
0
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   327
  }
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   328
}
af7713ef49dc Adding Editors Draft
eliotgra@ELIOTGRA-X220.redmond.corp.microsoft.com
parents:
diff changeset
   329
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   330
var streamURL = URL.createObjectURL(stream);
8
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
   331
document.getElementById('audioTag').src = streamURL;
cb4e62ad9587 Switching to respec version
fmoussa <feras.moussa@hotmail.com>
parents: 7
diff changeset
   332
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   333
writeData();</pre>
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   334
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   335
		<p>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   336
			A producer can also do work only when pulled by using <code>awaitSpaceAvailable()</code>.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   337
			This method informs the data producing code of that the data consuming API is ready to consume data.
87
dcf26e7c77fe Break at the end of each sentence.
Takeshi Yoshino <tyoshino@google.com>
parents: 86
diff changeset
   338
			This is useful when high-performance is necessary.
24
01eb488cd8c4 Complete update of streams spec to support promises and further refinements
fmoussa <feras.moussa@hotmail.com>
parents: 23
diff changeset
   339
		</p>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   340
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   341
		<pre class="example">function poll() {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   342
  stream.awaitSpaceAvailable().then(
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   343
    function (pulledAmount) {
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   344
      stream.write(generateRandomBytes(pulledAmount));
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   345
      poll();
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   346
    }
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   347
  );
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   348
}
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   349
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   350
poll();</pre>
113
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   351
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   352
		<p>
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   353
			The example below demonstrates how the timing to pull new data is determined.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   354
			When data of cost X is loaded and passed to the Promise, the <a>ReadableStream</a> marks X bytes of pullAmount as used.
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   355
			The next <code>read()</code> call automatically clears the mask to request the data source to produce X more data.
113
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   356
			If precise flow control is needed, you update pullAmount before the next <code>read()</code>.
126
be34c357de7f Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 125
diff changeset
   357
			In the example, the producer API is requested to produce 16 bytes, and then in the fulfill callback, pullAmount is set to the remaining number of bytes not to let the API produce more data.
113
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   358
		</p>
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   359
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   360
		<pre class="example">stream.pullAmount = 16;
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   361
function read() {
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   362
  stream.read().then(
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   363
    function (result) {
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   364
      process(result);
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   365
      stream.pullAmount -= result.size;
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   366
      if (stream.pullAmount == 0) {
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   367
        // Done
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   368
      } else if (stream.eof) {
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   369
        // Done
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   370
      } else {
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   371
        read();
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   372
      }
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   373
    }
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   374
  );
b6a7ebb05e6b Add pullAmount precise flow control example
Takeshi Yoshino <tyoshino@google.com>
parents: 112
diff changeset
   375
}</pre>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   376
	</section>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   377
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   378
	<section class="section" id="writableByteStream">
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   379
		<h2>WritableStream Interface</h2>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   380
		<p>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   381
			The WritableStream interface defines a protocol for APIs which consume data stream.
87
dcf26e7c77fe Break at the end of each sentence.
Takeshi Yoshino <tyoshino@google.com>
parents: 86
diff changeset
   382
			The protocol includes:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   383
			<ol>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   384
				<li>How to receive data stream</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   385
				<li>How to notify the writer of completion of writing</li>
77
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   386
				<li>How to notify the writer of how much data can be accepted currently</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   387
			</ol>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   388
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   389
			By returning a <a>Promise</a> and delaying fulfillment of it, the WritableStream realizes flow control.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   390
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   391
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   392
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   393
			The actual data consumer behind the WritableStream is called a data sink and is identified by <dfn>dataSink</dfn>.
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   394
			A data sink consumes stream of data and notifies the WritableStream of the cost of data the data sink can newly accept.
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   395
			For each data sink, it must be defined how to calculate <a>cost</a> of each object which the data sink can consume.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   396
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   397
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   398
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   399
			A WritableStream has a one-to-one mapping with the associated data sink, and has defined semantics for <a href='#interactingWithDataSink'>interacting with the data sink internally</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   400
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   401
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   402
		<section class="section">
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   403
			<h3>WritableStream interface</h3>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   404
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   405
			<dl class="idl" title="interface WritableStream">
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   406
				<dt>attribute DOMString writeEncoding</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   407
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   408
					<p>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   409
						A <a>DOMString</a> that represents the label of an encoding [[!EncodingDetermination]] to be passed to <a>dataSink</a> together with data passed to <code>write()</code> method.
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   410
						It will be used by <a>dataSink</a> for encoding determination.
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   411
						This attribute returns the label last set, or the empty DOMString if never set.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   412
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   413
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   414
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   415
						This parameter is not designed to be specified as an argument of write() since it's not likely to be changed frequently.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   416
					</section>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   417
				</dd>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   418
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   419
				<dt>Promise&amp;lt;unsigned long long&gt; write()</dt>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   420
				<dd>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   421
					<p>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   422
						This method writes the specified <var>data</var> to <a>dataSink</a>.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   423
					</p>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   424
85
885937bdcc17 Fix bug24021. Typo in process pendingWriteQueue
Takeshi Yoshino <tyoshino@google.com>
parents: 84
diff changeset
   425
					<section class="note">
885937bdcc17 Fix bug24021. Typo in process pendingWriteQueue
Takeshi Yoshino <tyoshino@google.com>
parents: 84
diff changeset
   426
						<p>
885937bdcc17 Fix bug24021. Typo in process pendingWriteQueue
Takeshi Yoshino <tyoshino@google.com>
parents: 84
diff changeset
   427
							write() returns a Promise to make it easy for byte stream producing code to react to backpressure.
885937bdcc17 Fix bug24021. Typo in process pendingWriteQueue
Takeshi Yoshino <tyoshino@google.com>
parents: 84
diff changeset
   428
						</p>
885937bdcc17 Fix bug24021. Typo in process pendingWriteQueue
Takeshi Yoshino <tyoshino@google.com>
parents: 84
diff changeset
   429
					</section>
885937bdcc17 Fix bug24021. Typo in process pendingWriteQueue
Takeshi Yoshino <tyoshino@google.com>
parents: 84
diff changeset
   430
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   431
					<p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   432
						This method must run the steps below:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   433
						<ol>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   434
							<li>Let <var>latchedEncoding</var> be the current value of <a href="#widl-WritableStream-writeEncoding">writeEncoding</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   435
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   436
							<li><a>Abort wait</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   437
115
14b1075d41d8 Define cost
Takeshi Yoshino <tyoshino@google.com>
parents: 111
diff changeset
   438
							<li>If <var>cost</var> argument is specified, let <var>amountToWrite</var> be <var>cost</var> argument. Otherwise, let <var>amountToWrite</var> be the <a>cost</a> of <var>data</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   439
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   440
							<li>Let <var>writePromise</var> be a new <a>Promise</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   441
98
3b89f8cea0fd More tuple -> pendingWrite renaming
Takeshi Yoshino <tyoshino@google.com>
parents: 97
diff changeset
   442
							<li>Let <var>pendingWrite</var> be a new <a>PendingWriteDescriptor</a></li>
3b89f8cea0fd More tuple -> pendingWrite renaming
Takeshi Yoshino <tyoshino@google.com>
parents: 97
diff changeset
   443
							<li>Set <var>pendingWrite.promise</var> to <var>writePromise</var></li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   444
							<li>Set <var>pendingWrite.amount</var> to <var>amountToWrite</var></li>
98
3b89f8cea0fd More tuple -> pendingWrite renaming
Takeshi Yoshino <tyoshino@google.com>
parents: 97
diff changeset
   445
							<li>Push <var>pendingWrite</var> to <a>pendingWriteQueue</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   446
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   447
							<li><a>Process pendingWriteQueue</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   448
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   449
							<li>Return <var>writePromise</var>, and then continue to process the steps in this algorithm</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   450
109
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   451
							<li>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   452
								<dl class="switch">
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   453
									<dt>If <var>data</var> is a <a>DOMString</a></dt>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   454
									<dd>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   455
										Write <var>data</var> to <a>dataSink</a> together with <var>latchedEncoding</var> as <var>encoding</var> parameter.
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   456
										Interpretation of <var>latchedEncoding</var> is up to <a>dataSink</a>.
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   457
									</dd>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   458
									<dt>Otherwise</dt>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   459
									<dd>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   460
										Write <var>data</var> to <a>dataSink</a>.
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   461
									</dd>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   462
								</dl>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   463
							</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   464
						</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   465
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   466
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   467
					<p>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   468
						WritableStream interface doesn't guarantee that <var>data</var> argument is cloned.
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   469
						Modifications made on <var>data</var> argument after <code>write()</code> method call may affect the data written to <a>dataSink</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   470
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   471
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   472
					<dl class="parameters">
111
f3c425cc88db write accepts any data
Takeshi Yoshino <tyoshino@google.com>
parents: 110
diff changeset
   473
						<dt>any data</dt>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   474
						<dd>Data to write.</dd>
115
14b1075d41d8 Define cost
Takeshi Yoshino <tyoshino@google.com>
parents: 111
diff changeset
   475
						<dt>optional [Clamp] unsigned long long cost</dt>
14b1075d41d8 Define cost
Takeshi Yoshino <tyoshino@google.com>
parents: 111
diff changeset
   476
						<dd>Overrides <a>cost</a> of data.</dd>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   477
					</dl>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   478
				</dd>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   479
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   480
				<dt>Promise&amp;lt;unsigned long long&gt; awaitSpaceAvailable()</dt>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   481
				<dd>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   482
					<p>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   483
						This method returns a <a>Promise</a>.
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   484
						The returned Promise will be fulfilled with the data <a>cost</a> which <a>dataSink</a> can accept when <a>dataSink</a> becomes able to accept data with any non-zero amount of cost.
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   485
					</p>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   486
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   487
					<p>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   488
						This method must run the steps below:
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   489
						<ol>
110
6a7a40bde1e5 Abort wait -> abort waiting
Takeshi Yoshino <tyoshino@google.com>
parents: 109
diff changeset
   490
							<li><a>Abort waiting</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   491
							<li>Set <a>waitPromise</a> to a new <a>Promise</a></li>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   492
							<li>Return <a>waitPromise</a></li>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   493
						</ol>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   494
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   495
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   496
103
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   497
				<dt>Promise&amp;lt;undefined&gt; writeClose()</dt>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   498
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   499
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   500
						This method tells the WritableStream that no more data will be written to it.
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   501
					</p>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   502
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   503
						Once writeClose() has been called on a WritableStream, no further method calls can be made on the WritableStream.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   504
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   505
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   506
					<p>
103
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   507
						This method must run the steps below:
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   508
						<ol>
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   509
							<li>Let <var>closePromise</var> be a new <a>Promise</a></li>
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   510
							<li>Return <var>closePromise</var>, and then continue the process the steps in this algorithm</li>
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   511
							<li>Write the EOF to <a>dataSink</a></li>
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   512
							<li>Wait until <a>dataSink</a> acknowledges the EOF</li>
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   513
							<li>Fulfill <var>closePromise</var> with <code>undefined</code></li>
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   514
						</ol>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   515
					</p>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   516
				</dd>
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   517
118
360cd31579a7 Make reason optional
Takeshi Yoshino <tyoshino@google.com>
parents: 117
diff changeset
   518
				<dt>Promise&amp;lt;undefined&gt; writeAbort(optional any reason)</dt>
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   519
				<dd>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   520
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   521
						This method tells the WritableStream that no more data will be written to it with indication of error.
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   522
						The details of the error will be given by <var>reason</var> argument.
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   523
						The interpretation of <var>reason</var> is up to <a>dataSink</a>.
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   524
					</p>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   525
					<p>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   526
						Once this method has been called on a WritableStream, no further method calls can be made on the WritableStream.
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   527
					</p>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   528
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   529
					<p>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   530
						This method must run the steps below:
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   531
						<ol>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   532
							<li>Let <var>abortPromise</var> be a new <a>Promise</a></li>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   533
							<li>Return <var>abortPromise</var>, and then continue the process the steps in this algorithm</li>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   534
							<li><a>Write-abort</a> <a>dataSink</a> with <var>reason</var></li>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   535
							<li>Wait until <a>dataSink</a> acknowledges the <a>write-abort</a></li>
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   536
							<li>Fulfill <var>abortPromise</var> with <code>undefined</code></li>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   537
						</ol>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   538
					</p>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   539
				</dd>
37
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   540
			</dl>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   541
		</section>
0de575d7b79a - Unify indentation to tabs.
Takeshi Yoshino <tyoshino@google.com>
parents: 35
diff changeset
   542
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   543
		<section class="section">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   544
			<h2>Data sink model</h2>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   545
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   546
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   547
				The data sink is the underlying mechanism which a <a>WritableStream</a> interacts with and stores its data in.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   548
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   549
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   550
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   551
				A data sink to which the <a>WritableStream</a> interface writes bytes can be anything which:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   552
				<ol>
109
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   553
					<li>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   554
						Accepts data possibly together with a <a>DOMString</a> parameter named <var>encoding</var> indicating in what encoding the data must be interpreted.
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   555
					</li>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   556
					<li>
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   557
						Accepts the EOF signal
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   558
					</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   559
					<li>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   560
						Accepts the <dfn>write-abort</dfn> signal with an object parameter named reason.
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   561
					</li>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   562
					<li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   563
						Notifies <a>WritableStream</a> of how much data the data sink can newly accept.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   564
						When and how to generate such notifications is up to data sinks.
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   565
						Data sinks must be able to accept data more than it notified <a>WritableStream</a> of.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   566
					</li>
103
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   567
					<li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   568
						Notifies <a>WritableStream</a> of that the data sink is gone.
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   569
						This signal may mean an error.
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   570
						If it means an error, an object indicating the details of the error is attached.
116
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   571
					</li>
d59e463a9181 Add writeAbort
Takeshi Yoshino <tyoshino@google.com>
parents: 115
diff changeset
   572
					<li>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   573
						Notifies <a>WritableStream</a> of acknowledgement of the EOF signal.
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   574
					</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   575
					<li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   576
						Notifies <a>WritableStream</a> of acknowledgement of the write-abort signal with error detail object.
103
56c80502bb30 Change writeClose() return type to Promise
Takeshi Yoshino <tyoshino@google.com>
parents: 102
diff changeset
   577
					</li>
109
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   578
					<li>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   579
						It's defined how to calculate an integer value <dfn>cost</dfn> of each object which the data sink can consume.
109
44cada6acb2f Make write() agnostic to data type
Takeshi Yoshino <tyoshino@google.com>
parents: 108
diff changeset
   580
					</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   581
				</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   582
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   583
		</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   584
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   585
		<section class="section" id='interactingWithDataSink'>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   586
			<h2>Interacting with the data sink</h2>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   587
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   588
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   589
				This section defines the internal mechanisms for how the WritableStream interacts with <a>dataSink</a>.
93
33fa9ecdbe74 A bit tweak on data sink definition
Takeshi Yoshino <tyoshino@google.com>
parents: 92
diff changeset
   590
				This section specifies both the internal properties as well as the algorithms.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   591
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   592
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   593
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   594
				A WritableStream has an associated integer variable <dfn>spaceAvailable</dfn> which holds the number of bytes that <a>dataSink</a> requested but not yet written to it.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   595
				This variable is initialized to 0 on construction.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   596
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   597
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   598
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   599
				A WritableStream has an associated <a>Promise</a> <dfn>waitPromise</dfn> which is used by the <code>awaitSpaceAvailable()</code> method.
93
33fa9ecdbe74 A bit tweak on data sink definition
Takeshi Yoshino <tyoshino@google.com>
parents: 92
diff changeset
   600
				This variable is initialized to <code>null</code> on construction.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   601
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   602
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   603
			<p>
110
6a7a40bde1e5 Abort wait -> abort waiting
Takeshi Yoshino <tyoshino@google.com>
parents: 109
diff changeset
   604
				To <dfn>abort waiting</dfn>, run the steps below:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   605
				<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   606
					<li>If <a>waitPromise</a> is <code>null</code>, terminate these steps</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   607
					<li>Let <var>detachedWaitPromise</var> be <a>waitPromise</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   608
					<li>Set <a>waitPromise</a> to <code>null</code></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   609
					<li>Reject <var>detachedWaitPromise</var> with an "<code><a>AbortError</a></code>"</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   610
				</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   611
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   612
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   613
			<p>
94
e06bf08768db Formatting data sink definition
Takeshi Yoshino <tyoshino@google.com>
parents: 93
diff changeset
   614
				A struct type <dfn>PendingWriteDescriptor</dfn> has the following members:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   615
				<ul>
91
3ed9f08a1f23 Renames for readability
Takeshi Yoshino <tyoshino@google.com>
parents: 90
diff changeset
   616
					<li>A <a>Promise</a> <var>promise</var></li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   617
					<li>An integer <var>amount</var></li>
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   618
					<li>An integer <var>ackedAmount</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   619
				</ul>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   620
			</p>
94
e06bf08768db Formatting data sink definition
Takeshi Yoshino <tyoshino@google.com>
parents: 93
diff changeset
   621
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   622
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   623
				A WritableStream has an associated queue <dfn>pendingWriteQueue</dfn> which holds <a>PendingWriteDescriptor</a>s.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   624
				This queue is initialized to an empty queue on construction.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   625
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   626
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   627
			<p>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   628
				To <dfn>process pendingWriteQueue</dfn>, run the steps below:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   629
				<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   630
					<li>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   631
						While <a>pendingWriteQueue</a> is not empty, repeat the steps below:
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   632
						<ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   633
							<li>Let <var>pendingWrite</var> be the head element of <a>pendingWriteQueue</a></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   634
							<li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   635
								<dl class="switch">
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   636
									<dt>If <a>sinkGone</a> is set</dt>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   637
									<dd>
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   638
										<ol>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   639
											<li>Pop <var>pendingWrite</var> from <a>pendingWriteQueue</a>, and then</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   640
											<li>If <var>pendingWrite.promise</var> is not <code>null</code>, reject it with <a>sinkErrorDetail</a></li>
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   641
										</ol>
127
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   642
									</dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   643
									<dt>Otherwise</dt>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   644
									<dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   645
										<ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   646
											<li>Let <var>amountToAcknowledge</var> be min(<var>pendingWrite.amount</var> - <var>pendingWrite.ackedAmount</var>, <a>spaceAvailable</a>)</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   647
											<li>Set <a>spaceAvailable</a> to <a>spaceAvailable</a> - <var>amountToAcknowledge</var></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   648
											<li>Set <var>pendingWrite.ackedAmount</var> to <var>pendingWrite.ackedAmount</var> + <var>amountToAcknowledge</var></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   649
											<li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   650
												<dl class="switch">
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   651
													<dt>If <var>pendingWrite.ackedAmount</var> equals to <var>pendingWrite.amount</var></dt>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   652
													<dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   653
														<ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   654
															<li>Pop <var>pendingWrite</var> from <a>pendingWriteQueue</a></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   655
															<li>If <var>pendingWrite.promise</var> is not <code>null</code>, fulfill it with <var>pendingWrite.amount</var></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   656
														</ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   657
													</dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   658
													<dt>Otherwise</dt>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   659
													<dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   660
														Exit from this loop
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   661
													</dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   662
												</dl>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   663
											</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   664
										</ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   665
									</dd>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   666
								</dl>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   667
							</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   668
						</ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   669
					</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   670
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   671
					<li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   672
						If <a>pendingWriteQueue</a> is empty and <a>spaceAvailable</a> is not 0, run the steps below:
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   673
						<ol>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   674
							<li>If <a>waitPromise</a> is <code>null</code>, terminate these steps</li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   675
							<li>Let <var>detachedWaitPromise</var> be <a>waitPromise</a></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   676
							<li>Set <a>waitPromise</a> to <code>null</code></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   677
							<li>Fulfill <var>detachedWaitPromise</var> with <a>spaceAvailable</a></li>
bf65397910b7 More rewriting
Takeshi Yoshino <tyoshino@google.com>
parents: 126
diff changeset
   678
						</ol>
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   679
					</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   680
				</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   681
			</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   682
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   683
			<p>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   684
				When <a>dataSink</a> requests <var>amountNewlyRequested</var> more data, queue a task which runs the steps below:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   685
				<ol>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   686
					<li>Set <a>spaceAvailable</a> to <a>spaceAvailable</a> + <var>amountNewlyRequested</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   687
					<li><a>Process pendingWriteQueue</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   688
				</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   689
			</p>
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   690
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   691
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   692
				A WritableStream has an associated flag <dfn>sinkGone</dfn> which is set when the data sink is gone.
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   693
			</p>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   694
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   695
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   696
				A WritableStream has an associated object <dfn>sinkErrorDetail</dfn> which is initialized to null, and when the data sink is gone, set to the error detail object.
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   697
			</p>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   698
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   699
			<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   700
				When <a>dataSink</a> notifies the WritableStream of that the data sink is gone, queue a task which runs the steps below:
119
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   701
				<ol>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   702
					<li>Set <a>sinkGone</a></li>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   703
					<li>Set <a>sinkErrorDetail</a> to the error detail object</li>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   704
					<li><a>Process pendingWriteQueue</a></li>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   705
				</ol>
218f3b3a2df5 Add how to notify abort/error signal
Takeshi Yoshino <tyoshino@google.com>
parents: 118
diff changeset
   706
			</p>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   707
		</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   708
	</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   709
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   710
	<section class="section" id="readableByteStream">
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   711
		<h2>ReadableStream Interface</h2>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   712
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   713
			The ReadableStream interface defines a protocol for APIs which produce a byte stream. This protocol includes:
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   714
			<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   715
				<li>How to receive a read request from the reader and output bytes</li>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   716
				<li>How to transfer data in bulk to another <a>WritableStream</a> (by using the <code>pipe()</code> method)</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   717
				<li>How to mirror data to multiple destinations (by using the <code>fork()</code>)</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   718
			</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   719
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   720
			By returning a <a>Promise</a> and delaying fulfillment of it, the ReadableStream realizes asynchronous data consumption.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   721
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   722
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   723
		<p>
77
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   724
			Interfaces introduced in this section provide simple and convenient ways to consume data.
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   725
			They connect arbitrary byte stream producer and byte stream consuming JavaScript code using Promises and method invocations.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   726
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   727
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   728
		<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   729
			A ReadableStream has a one-to-one mapping with an associated data source, and has defined semantics for <a href='#interactingWithDataSource'>interacting with the data source internally</a>.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   730
			A data source, however, can have a one-to-many relationship with ReadableStream, in cases where <code>fork()</code> is used.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   731
		</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   732
77
3e2335dbad62 Rewording
Takeshi Yoshino <tyoshino@google.com>
parents: 76
diff changeset
   733
		<section class="section" id="readableByteStreamInterface">
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   734
			<h3>ReadableStream interface</h3>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   735
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   736
			<dl class="idl" title="interface ReadableStream">
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   737
				<dt>readonly attribute DOMString type</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   738
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   739
					Returns the ASCII-encoded string in lower case representing the media type of the <code>Stream</code>,
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   740
					expressed as an RFC2046 MIME type [[!RFC2046]].
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   741
					Conforming user agents SHOULD return the MIME type of the <code>ReadableStream</code>, if it is known.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   742
					If conforming user agents cannot determine the media type of the <code>ReadableStream</code>, they MUST return the empty string.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   743
					A string is a valid MIME type if it matches the media-type token defined in section 3.7 "Media Types" of RFC 2616 [[!HTTP11]].
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   744
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   745
125
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   746
				<dt>attribute StreamReadType readBinaryAs</dt>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   747
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   748
					<p>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   749
						Specifies what data type will be returned by a <code>read()</code> and <code>readUpTo()</code> method call.
125
98448480356b ByteStreamReadType -> StreamReadType
Takeshi Yoshino <tyoshino@google.com>
parents: 124
diff changeset
   750
						This attribute can be set to any of the supported types in <a>StreamReadType</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   751
						The default value for this attribute is "<code>arraybuffer</code>".
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   752
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   753
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   754
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   755
				<dt>attribute DOMString readEncoding</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   756
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   757
					<p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   758
						Specifies a <a>DOMString</a> that represents the label of an encoding [[!EncodingDetermination]].
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   759
						If set, it will be used as part of the encoding determination used when processing a <code>read()</code> method call.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   760
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   761
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   762
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   763
						This parameter is not designed to be specified as an argument of <code>read()</code> since it's not likely to be changed frequently.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   764
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   765
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   766
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   767
				<dt>attribute unsigned long long pullAmount</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   768
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   769
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   770
						This attribute provides ReadableStream with a hint of how much data the reader can consume currently.
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   771
						Each implementation of ReadableStream must initialize the value of pullAmount on construction.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   772
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   773
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   774
					<p>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   775
						When this attribute is set, <a>retrieve data</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   776
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   777
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   778
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   779
						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.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   780
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   781
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   782
						It's possible that the number of bytes received by <code>read()</code> is more than the pullAmount value.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   783
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   784
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   785
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   786
				<dt>Promise&amp;lt;StreamReadResult&gt; readUpTo()</dt>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   787
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   788
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   789
						This method reads data from the ReadableStream.
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   790
						The returned <a>Promise</a> is fulfilled only when the total cost of produced data becomes equal to or greater than the specified <a>cost</a> or the EOF is reached.
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   791
						The cost of data returned by this method is the same or less than the specified <var>size</var> argument.
121
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   792
						The cost of data returned by this method can be less than <var>size</var> when data cannot be fully converted into the type specified by <code>readBinaryAs</code> or an EOF was reached.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   793
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   794
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   795
					<p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   796
						This method must run the steps below:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   797
						<ol>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   798
							<li>If <a href="#widl-ReadableStream-readBinaryAs">readBinaryAs</a> is "<code>text</code>" throw a "<code><a>SyntaxError</a></code>"</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   799
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   800
							<li>If <a>readPending</a> is set, throw an "<code><a>InvalidStateError</a></code>"</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   801
							<li>Set <a>readPending</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   802
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   803
							<li>Let <var>latchedType</var> be the current value of <a href="#widl-ReadableStream-readBinaryAs">readBinaryAs</a></li>
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   804
							<li>Let <var>latchedEncoding</var> be the current value of <a href="#widl-ReadableStream-readEncoding">readEncoding</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   805
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   806
							<li>Set <a>readUpToPullAmount</a> to <var>size</var></li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   807
							<li>Set <a>amountBeingReturned</a> to 0</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   808
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   809
							<li><a>Retrieve data</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   810
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   811
							<li>Let <var>readPromise</var> be a new <a>Promise</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   812
							<li>Return <var>readPromise</var>, and then continue to process the steps in this algorithm</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   813
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   814
							<li>Wait until the total cost of data in <a>readDataBuffer</a> becomes equal to or greater than <var>size</var> or <a>eofReached</a> is set</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   815
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   816
							<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   817
								Queue a task which runs the steps below:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   818
								<ol>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   819
									<li>Let <var>readableAmount</var> be the total cost of data in <a>readDataBuffer</a></li>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   820
									<li>Let <var>maxAmountToConsume</var> be min(<var>size</var>, <var>readableAmount</var>)</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   821
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   822
									<li>Let <var>result</var> be a new <a>StreamReadResult</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   823
									<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   824
										<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   825
											<dt>If <var>latchedType</var> is "<code>none</code>"</dt>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   826
											<dd>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   827
												<ol>
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   828
													<li>Set <var>result</var>.<a href="#widl-StreamReadResult-data">data</a> to <code>undefined</code></li>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   829
													<li>Pop data from <a>readDataBuffer</a> as much as possible but up to <var>maxAmountToConsume</var></li>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   830
												</ol>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   831
											</dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   832
											<dt>Otherwise</dt>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   833
											<dd>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   834
												<ol>
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   835
													<li>Set <var>result</var>.<a href="#widl-StreamReadResult-data">data</a> to an object of the type specified by <var>latchedType</var> that can be created by consuming as much data as possible from <a>readDataBuffer</a> but up to <var>maxAmountToConsume</var></li>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   836
													<li>Pop the consumed data from <a>readDataBuffer</a></li>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   837
											</dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   838
										</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   839
									</li>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   840
									<li>Let <var>amountConsumed</var> be the total cost of data consumed in the last step</li>
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   841
									<li>Set <a href="#widl-StreamReadResult-amountConsumed">amountConsumed</a> of <var>result</var> to <var>amountConsumed</var></li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   842
									<li>Set <a href="#widl-StreamReadResult-eof">eof</a> of <var>result</var> to <code>true</code> if <a>readDataBuffer</a> is empty and <a>eofReached</a> is set</li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   843
									<li>Set <var>result</var>.<a href="#widl-StreamReadResult-error">error</a> to <a>sourceErrorDetail</a></li>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   844
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   845
									<li>Set <a>amountBeingReturned</a> to <var>amountConsumed</var></li>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   846
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   847
									<li>Set <a>readUpToPullAmount</a> to 0</li>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   848
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   849
									<li>Unset <a>readPending</a></li>
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   850
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   851
									<li>Fulfill <var>readPromise</var> with <var>result</var></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   852
								</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   853
							</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   854
						</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   855
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   856
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   857
					<dl class="parameters">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   858
						<dt>[Clamp] unsigned long long size</dt>
114
6cd4d6696cb8 Change readExact to readUpTo and make it able to handle non-byte type data
Takeshi Yoshino <tyoshino@google.com>
parents: 113
diff changeset
   859
						<dd>Max number of bytes to read.</dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   860
					</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   861
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   862
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   863
						This method is useful if
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   864
						<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   865
							<li>You don't want to get notified of new data unless bytes of the specified number become available.</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   866
							<li>You don't want to get your data fragmented into multiple parts, thus avoiding the need to buffer and combine chunks yourself.</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   867
						</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   868
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   869
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   870
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   871
				<dt>Promise&amp;lt;StreamReadResult&gt; read()</dt>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   872
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   873
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   874
						This method reads data from the ReadableStream.
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   875
						The speed of reading can be roughly adjusted by using <a href="#widl-StreamReadResult-pullAmount">pullAmount</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   876
						pullAmount doesn't necessarily limit the size of data being read by this method.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   877
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   878
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   879
					<p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   880
						This method must run the steps below:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   881
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   882
						<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   883
							<li>If <a>readPending</a> is set, throw an "<code><a>InvalidStateError</a></code>"</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   884
							<li>Set <a>readPending</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   885
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   886
							<li>Let <var>latchedType</var> be the current value of <a href="#widl-ReadableStream-readBinaryAs">readBinaryAs</a> attribute</li>
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
   887
							<li>Let <var>latchedEncoding</var> be the current value of <a href="#widl-ReadableStream-readEncoding">readEncoding</a> attribute</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   888
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   889
							<li>Set <a>amountBeingReturned</a> to 0</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   890
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   891
							<li><a>Retrieve data</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   892
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   893
							<li>Let <var>readPromise</var> be a new <a>Promise</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   894
							<li>Return <var>readPromise</var>, and then continue to process the steps in this algorithm</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   895
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   896
							<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   897
								<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   898
									<dt>If <var>latchedType</var> is "<code>text</code>"</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   899
									<dd>
121
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   900
										Wait until any of the following conditions is met, and then run the steps for the condition:
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   901
										<dl class="switch">
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   902
											<dt>All or part of bytes in <a>readDataBuffer</a> can be converted into a non-empty <a>DOMString</a> when decoded using <var>latchedEncoding</var></dt>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   903
											<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   904
												<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   905
													<li>Pop the bytes from <a>readDataBuffer</a></li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   906
													<li>Let <var>amountConsumed</var> be the number of the popped bytes</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   907
													<li>Let <var>readData</var> be the result of decoding</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   908
												</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   909
											</dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   910
											<dt>It's clear decoding bytes in <a>readDataBuffer</a> using <var>latchedEncoding</var> fails regardless bytes to be retrieved in the future are</dt>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   911
											<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   912
												<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   913
													<li>Reject <var>readPromise</var> with an "<code><a>InvalidStateError</a></code>"</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   914
													<li>Terminate these steps</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   915
												</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   916
											</dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   917
											<dt>Anything that doesn't represent bytes in <a>readDataBuffer</a> is encountered</dt>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   918
											<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   919
												<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   920
													<li>Reject <var>readPromise</var> with an "<code><a>InvalidStateError</a></code>"</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   921
													<li>Terminate these steps</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   922
												</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   923
											</dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   924
										</dl>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   925
									</dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   926
									<dt>If <var>latchedType</var> is "<code>arraybuffer</code>" or "<code>blob</code>"</dt>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   927
									<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   928
										Wait until any of the following conditions is met, and then run the steps for the condition:
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   929
										<dl class="switch">
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   930
											<dt>There're non-zero number of bytes in <a>readDataBuffer</a></dt>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   931
											<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   932
												<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   933
													<li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   934
														Pop the bytes from <a>readDataBuffer</a>, and then let <var>readBytes</var> be the popped bytes
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   935
														<section class="note">
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   936
															Implementations may choose to pop only part of bytes readable if it helps reducing memory copy.
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   937
														</section>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   938
													</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   939
													<li>Let <var>readData</var> be an object of the type specified by <var>latchedType</var> which represents <var>readBytes</var></li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   940
													<li>Let <var>amountConsumed</var> be the number of the popped bytes</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   941
												</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   942
											</dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   943
											<dt>Anything that doesn't represent bytes in <a>readDataBuffer</a> is encountered</dt>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   944
											<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   945
												<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   946
													<li>Reject <var>readPromise</var> with an "<code><a>InvalidStateError</a></code>"</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   947
													<li>Terminate these steps</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   948
												</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   949
											</dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   950
										</dl>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   951
									</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   952
									<dt>Otherwise</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   953
									<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   954
										<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   955
											<li>Wait until <a>readDataBuffer</a> becomes non-empty or <a>eofReached</a> is set</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   956
											<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   957
												<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   958
													<dt>If <var>latchedType</var> is "<code>none</code>"</dt>
121
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   959
													<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   960
														<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   961
															<li>Pop data from <a>readDataBuffer</a></li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   962
															<li>Let <var>readData</var> be <code>undefined</code></li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   963
														</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   964
													</dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   965
													<dt>Otherwise</dt>
121
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   966
													<dd>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   967
														<ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   968
															<li>Pop data from <a>readDataBuffer</a></li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   969
															<li>Let <var>readData</var> be an object representing the data</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   970
															<li>Let <var>amountConsumed</var> be the <a>cost</a> of the data</li>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   971
														</ol>
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   972
													</dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   973
												</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   974
											</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   975
										</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   976
									</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   977
								</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   978
							</li>
121
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   979
cbc891d653dd Remove stale text
Takeshi Yoshino <tyoshino@google.com>
parents: 120
diff changeset
   980
							<li>Queue a task which runs the rest of this algorithm</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   981
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   982
							<li>Let <var>result</var> be a new <a>StreamReadResult</a>.</li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   983
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-data">data</a> to <var>readData</var></li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   984
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-eof">eof</a> to <code>true</code> if <a>eofReached</a> is set and <a>readDataBuffer</a> is empty</li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   985
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-amountConsumed">amountConsumed</a> to <var>amountConsumed</var></li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
   986
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-error">error</a> to <a>sourceErrorDetail</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   987
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
   988
							<li>Set <a>amountBeingReturned</a> to <var>amountConsumed</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   989
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   990
							<li>Unset <a>readPending</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   991
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   992
							<li>Fulfill <var>readPromise</var> with <var>result</var></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   993
						</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   994
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
   995
78
12c164bee09f Add diagrams
Takeshi Yoshino <tyoshino@google.com>
parents: 77
diff changeset
   996
					<p>
83
afed6501a898 moved images, fixed typos, fixed header
fmoussa <feras.moussa@hotmail.com>
parents: 81
diff changeset
   997
						<img src="images/fulfilling.png" alt="How new data is automatically fetched">
78
12c164bee09f Add diagrams
Takeshi Yoshino <tyoshino@google.com>
parents: 77
diff changeset
   998
					</p>
12c164bee09f Add diagrams
Takeshi Yoshino <tyoshino@google.com>
parents: 77
diff changeset
   999
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1000
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1001
						This method is useful if
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1002
						<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1003
							<li>You don't care in what size and as how many fragments the data will be received</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1004
							<li>You want to limit the number of bytes read for flow control</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1005
						</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1006
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1007
				</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1008
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
  1009
				<dt>Promise&amp;lt;StreamReadResult&gt; pipe()</dt>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1010
				<dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1011
					<p>
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
  1012
						This method bulk transfers bytes from the ReadableStream to another <a>WritableStream</a>.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1013
					</p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1014
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1015
					<section class="note">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1016
						Fulfillment of the returned Promise doesn't necessarily mean that the data transferred to <var>destination</var> has been successfully read from it.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1017
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1018
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1019
					<section class="note">
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1020
						TODO: Rewrite this to update <a>amountBeingReturned</a> as numBytesAcknowledged of <a>PendingWriteDescriptor</a>s are updated
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1021
					</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1022
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1023
					<p>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1024
						This method must run the steps below:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1025
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1026
						<ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1027
							<li>If <a>readPending</a> is set, throw an "<code><a>InvalidStateError</a></code>"</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1028
							<li>Set <a>readPending</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1029
110
6a7a40bde1e5 Abort wait -> abort waiting
Takeshi Yoshino <tyoshino@google.com>
parents: 109
diff changeset
  1030
							<li>Run <a>abort waiting</a> algorithm on <var>destination</var></a>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1031
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1032
							<li>Set <a>amountBeingReturned</a> to 0</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1033
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1034
							<li><a>Retrieve data</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1035
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1036
							<li>Let <var>pipePromise</var> be a new <a>Promise</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1037
							<li>Return <var>pipePromise</var>, and then continue to process the steps in this algorithm</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1038
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1039
							<li>Let <var>totalAmountTransferred</var> be 0</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1040
							<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1041
								Repeat the steps below:
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1042
								<ul>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1043
									<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1044
										Whenever <a>readDataBuffer</a> is not empty or <a>eofReached</a> is set,
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1045
										<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1046
											<dt>If this happened in the event loop</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1047
											<dd>Run the steps below</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1048
											<dt>Otherwise</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1049
											<dd>Queue a task which runs the steps below</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1050
										</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1051
										<ol>
100
7421b9a22a7e More bug fix in pipe(). numBytesRequested is used where numBytesSpaceAvailable must be used.
Takeshi Yoshino <tyoshino@google.com>
parents: 99
diff changeset
  1052
											<li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1053
												Let <var>readableAmount</var> be the number of bytes in <a>readDataBuffer</a>
100
7421b9a22a7e More bug fix in pipe(). numBytesRequested is used where numBytesSpaceAvailable must be used.
Takeshi Yoshino <tyoshino@google.com>
parents: 99
diff changeset
  1054
												<section class="note">
7421b9a22a7e More bug fix in pipe(). numBytesRequested is used where numBytesSpaceAvailable must be used.
Takeshi Yoshino <tyoshino@google.com>
parents: 99
diff changeset
  1055
													It's fine to process only part of the bytes, and process the rest in the next task.
7421b9a22a7e More bug fix in pipe(). numBytesRequested is used where numBytesSpaceAvailable must be used.
Takeshi Yoshino <tyoshino@google.com>
parents: 99
diff changeset
  1056
												</section>
7421b9a22a7e More bug fix in pipe(). numBytesRequested is used where numBytesSpaceAvailable must be used.
Takeshi Yoshino <tyoshino@google.com>
parents: 99
diff changeset
  1057
											</li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1058
											<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1059
												<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1060
													<dt>If <var>size</var> is specified</dt>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1061
													<dd>Let <var>amountToTransfer</var> be min(<var>size</var> - <var>totalAmountTransferred</var>, <var>readableAmount</var>)</dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1062
													<dt>Otherwise</dt>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1063
													<dd>Let <var>amountToTransfer</var> be <var>readableAmount</var></dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1064
												</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1065
											</li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1066
											<li>Set <a>amountBeingReturned</a> to <a>amountBeingReturned</a> + <var>amountToTransfer</var></li>
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1067
											<li>Pop <var>amountToTransfer</var> bytes from <a>readDataBuffer</a>, and then write it to <a>dataSink</a> of <var>destination</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1068
98
3b89f8cea0fd More tuple -> pendingWrite renaming
Takeshi Yoshino <tyoshino@google.com>
parents: 97
diff changeset
  1069
											<li>Let <var>pendingWrite</var> be a new <a>PendingWriteDescriptor</a></li>
3b89f8cea0fd More tuple -> pendingWrite renaming
Takeshi Yoshino <tyoshino@google.com>
parents: 97
diff changeset
  1070
											<li>Set <var>pendingWrite.promise</var> to <code>null</code></li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1071
											<li>Set <var>pendingWrite.amount</var> to <var>amountToTransfer</var></li>
98
3b89f8cea0fd More tuple -> pendingWrite renaming
Takeshi Yoshino <tyoshino@google.com>
parents: 97
diff changeset
  1072
											<li>Push <var>pendingWrite</var> to <a>pendingWriteQueue</a> of <var>destination</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1073
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1074
											<li>Set <var>totalAmountTransferred</var> to <var>totalAmountTransferred</var> + <var>amountToTransfer</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1075
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1076
											<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1077
												<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1078
													<dt>If <a>eofReached</a> is set</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1079
													<dd>Break from this loop</dd>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1080
													<dt>If <var>size</var> is specified and <var>totalAmountTransferred</var> equals to <var>size</var></dt>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1081
													<dd>Break from this loop</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1082
												</dl>
102
a176607d4c3a TODO about pipe() finish timing
Takeshi Yoshino <tyoshino@google.com>
parents: 101
diff changeset
  1083
												<section class="note">
a176607d4c3a TODO about pipe() finish timing
Takeshi Yoshino <tyoshino@google.com>
parents: 101
diff changeset
  1084
													Need to revisit. Finish when write to the destination completes?
a176607d4c3a TODO about pipe() finish timing
Takeshi Yoshino <tyoshino@google.com>
parents: 101
diff changeset
  1085
												</section>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1086
											</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1087
										</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1088
									</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1089
									<li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1090
										Whenever <a>pendingWriteQueue</a> of <var>destination</var> is empty and <a>spaceAvailable</a> of <var>destination</var> is not 0,
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1091
										<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1092
											<dt>If this happened in the event loop</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1093
											<dd>Run the steps below</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1094
											<dt>Otherwise</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1095
											<dd>Queue a task which runs the steps below</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1096
										</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1097
										<ol>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1098
											<li>Let <var>destSpaceAvailable</var> be <a>spaceAvailable</a> of <var>destination</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1099
											<li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1100
												<dl class="switch">
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1101
													<dt>If <var>size</var> is specified</dt>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1102
													<dd>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1103
														Set <a>pipePullAmount</a> to min(<var>size</var> - <var>totalAmountTransferred</var>, <var>destSpaceAvailable</var>)
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1104
														<section class="note">
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
  1105
															If <a href="#widl-ReadableStream-pullAmount">pullAmount</a> is set to 0, pipe() transfers data in pull style.
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1106
															I.e. only bytes of the same number as the number of bytes writable to <var>destination</var> are retrieved from the data source.
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1107
														</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1108
														<section class="note">
123
2c23cbb3665f Revert name back to Readable/WritableStream
Takeshi Yoshino <tyoshino@google.com>
parents: 122
diff changeset
  1109
															Setting <a href="#widl-ReadableStream-pullAmount">pullAmount</a> to a small value doesn't have an effect of throttling the pace of pipe().
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1110
														</section>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1111
													</dd>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1112
													<dt>Otherwise</dt>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1113
													<dd>Set <a>pipePullAmount</a> to <var>destSpaceAvailable</var></dd>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1114
												</dl>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1115
											</li>
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1116
											<li>Set <a>amountBeingReturned</a> to 0</li>
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff changeset
  1117
											<li><a>Retrieve data</a></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1118
										</ol>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1119
									</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1120
								</ul>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1121
							</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1122
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1123
							<li>Set <a>pipePullAmount</a> to 0</li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1124
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1125
							<li>Unset <a>readPending</a></li>
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1126
124
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
  1127
							<li>Let <var>result</var> be a new <a>StreamReadResult</a></li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
  1128
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-data">data</a> to <code>undefined</code>.
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
  1129
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-eof">eof</a> to <code>true</code> if <a>eofReached</a></li>
9dc273a030cc - ByteStreamReadResult -> StreamReadResult
Takeshi Yoshino <tyoshino@google.com>
parents: 123
diff changeset
  1130
							<li>Set <var>result</var>.<a href="#widl-StreamReadResult-amountConsumed">amountConsumed</a> to <var>totalAmountTransferred</var></li>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1131
							<li>
101
7da4a886ff9f More pipe() bug fixes
Takeshi Yoshino <tyoshino@google.com>
parents: 100
diff changeset
  1132
								Fulfill <var>pipePromise</var> with <var>result</var>
76
63f6521d7457 Moved preview to overview, and added note about preview deprication
fmoussa <feras.moussa@hotmail.com>
parents: 46
diff changeset
  1133
								<section class="note">
107
276491848949 Rename variables agnostic to type of data Streams API handles
Takeshi Yoshino <tyoshino@google.com>
parents: 106
diff