Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: client/samples/isolate/IsolateSample.dart

Issue 8835006: New version of dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/samples/dartcombat/views.dart ('k') | client/samples/sunflower/Sunflower.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * These are the messages we are going to send to the isolates 6 * These are the messages we are going to send to the isolates
7 * that we create. 7 * that we create.
8 */ 8 */
9 class MessageId { 9 class MessageId {
10 static final INIT = "init"; 10 static final INIT = "init";
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 case MessageId.GREETING: 117 case MessageId.GREETING:
118 greeting(message["args"][0], replyTo); 118 greeting(message["args"][0], replyTo);
119 break; 119 break;
120 } 120 }
121 }); 121 });
122 } 122 }
123 123
124 void init(String isolateName, SendPort chirpPort) { 124 void init(String isolateName, SendPort chirpPort) {
125 this.isolateName = isolateName; 125 this.isolateName = isolateName;
126 this.chirpPort = chirpPort; 126 this.chirpPort = chirpPort;
127 div = document.createElement("div"); 127 div = new Element.tag("div");
128 div.classes = ["isolate", "isolate${isolateName}"]; 128 div.classes = ["isolate", "isolate${isolateName}"];
129 div.innerHTML = document.query("#isolateTemplate"). 129 div.innerHTML = document.query("#isolateTemplate").
130 firstElementChild.dynamic.innerHTML; 130 firstElementChild.dynamic.innerHTML;
131 div.query(".isolateName").text = isolateName; 131 div.query(".isolateName").text = isolateName;
132 document.query("#isolateParent").nodes.add(div); 132 document.query("#isolateParent").nodes.add(div);
133 div.query(".chirpButton").on.click.add( 133 div.query(".chirpButton").on.click.add(
134 void _(Event) { chirpPort.call( 134 void _(Event) { chirpPort.call(
135 "this is a chirp message from isolate " + isolateName); 135 "this is a chirp message from isolate " + isolateName);
136 }, false); 136 }, false);
137 } 137 }
138 138
139 /** 139 /**
140 * Display the message we received, and send back a simple reply (unless 140 * Display the message we received, and send back a simple reply (unless
141 * the user has unchecked the reply checkbox). 141 * the user has unchecked the reply checkbox).
142 */ 142 */
143 void greeting(String message, SendPort replyTo) { 143 void greeting(String message, SendPort replyTo) {
144 div.query(".messageBox").dynamic.innerHTML = 144 div.query(".messageBox").dynamic.innerHTML =
145 "received message: <span class='messageText'>'${message}'</span>"; 145 "received message: <span class='messageText'>'${message}'</span>";
146 if (div.query(".replyCheckbox").dynamic.checked) { 146 if (div.query(".replyCheckbox").dynamic.checked) {
147 InputElement element = div.query(".delayTextbox"); 147 InputElement element = div.query(".delayTextbox");
148 int millis = Math.parseInt(element.value); 148 int millis = Math.parseInt(element.value);
149 window.setTimeout(() { 149 window.setTimeout(() {
150 replyTo.send("this is a reply from isolate '${isolateName}'", null); 150 replyTo.send("this is a reply from isolate '${isolateName}'", null);
151 }, millis); 151 }, millis);
152 } 152 }
153 } 153 }
154 } 154 }
OLDNEW
« no previous file with comments | « client/samples/dartcombat/views.dart ('k') | client/samples/sunflower/Sunflower.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698