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

Side by Side Diff: samples/sample_extension/sample_asynchronous_extension.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months 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 | « samples/newissues/newissues.dart ('k') | samples/solar3d/web/solar.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library sample_asynchronous_extension; 5 library sample_asynchronous_extension;
6 6
7 import 'dart-ext:sample_extension'; 7 import 'dart-ext:sample_extension';
8 8
9 // A class caches the native port used to call an asynchronous extension. 9 // A class caches the native port used to call an asynchronous extension.
10 class RandomArray { 10 class RandomArray {
11 static SendPort _port; 11 static SendPort _port;
12 12
13 void randomArray(int seed, int length, void callback(List result)) { 13 void randomArray(int seed, int length, void callback(List result)) {
14 var args = new List(2); 14 var args = new List.fixedLength(2);
15 args[0] = seed; 15 args[0] = seed;
16 args[1] = length; 16 args[1] = length;
17 _servicePort.call(args).then((result) { 17 _servicePort.call(args).then((result) {
18 if (result != null) { 18 if (result != null) {
19 callback(result); 19 callback(result);
20 } else { 20 } else {
21 throw new Exception("Random array creation failed"); 21 throw new Exception("Random array creation failed");
22 } 22 }
23 }); 23 });
24 } 24 }
25 25
26 SendPort get _servicePort { 26 SendPort get _servicePort {
27 if (_port == null) { 27 if (_port == null) {
28 _port = _newServicePort(); 28 _port = _newServicePort();
29 } 29 }
30 return _port; 30 return _port;
31 } 31 }
32 32
33 SendPort _newServicePort() native "RandomArray_ServicePort"; 33 SendPort _newServicePort() native "RandomArray_ServicePort";
34 } 34 }
OLDNEW
« no previous file with comments | « samples/newissues/newissues.dart ('k') | samples/solar3d/web/solar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698