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

Side by Side Diff: runtime/bin/io_service_patch.dart

Issue 24596003: Clean up IOService implementation to be shared between patched and non-patched code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | runtime/bin/socket_patch.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 const int FILE_EXISTS = 0; 5 patch class _IOService {
6 const int FILE_CREATE = 1;
7 const int FILE_DELETE = 2;
8 const int FILE_RENAME = 3;
9 const int FILE_OPEN = 4;
10 const int FILE_RESOLVE_SYMBOLIC_LINKS = 5;
11 const int FILE_CLOSE = 6;
12 const int FILE_POSITION = 7;
13 const int FILE_SET_POSITION = 8;
14 const int FILE_TRUNCATE = 9;
15 const int FILE_LENGTH = 10;
16 const int FILE_LENGTH_FROM_PATH = 11;
17 const int FILE_LAST_MODIFIED = 12;
18 const int FILE_FLUSH = 13;
19 const int FILE_READ_BYTE = 14;
20 const int FILE_WRITE_BYTE = 15;
21 const int FILE_READ = 16;
22 const int FILE_READ_INTO = 17;
23 const int FILE_WRITE_FROM = 18;
24 const int FILE_CREATE_LINK = 19;
25 const int FILE_DELETE_LINK = 20;
26 const int FILE_RENAME_LINK = 21;
27 const int FILE_LINK_TARGET = 22;
28 const int FILE_TYPE = 23;
29 const int FILE_IDENTICAL = 24;
30 const int FILE_STAT = 25;
31 const int SOCKET_LOOKUP = 26;
32 const int SOCKET_LIST_INTERFACES = 27;
33 const int SOCKET_REVERSE_LOOKUP = 28;
34 const int DIRECTORY_CREATE = 29;
35 const int DIRECTORY_DELETE = 30;
36 const int DIRECTORY_EXISTS = 31;
37 const int DIRECTORY_CREATE_TEMP = 32;
38 const int DIRECTORY_LIST_START = 33;
39 const int DIRECTORY_LIST_NEXT = 34;
40 const int DIRECTORY_LIST_STOP = 35;
41 const int DIRECTORY_RENAME = 36;
42 const int SSL_PROCESS_FILTER = 37;
43
44 class IOService {
45 // Lazy initialize service ports, 32 per isolate. 6 // Lazy initialize service ports, 32 per isolate.
46 static const int _SERVICE_PORT_COUNT = 32; 7 static const int _SERVICE_PORT_COUNT = 32;
47 static List<SendPort> _servicePort = new List(_SERVICE_PORT_COUNT); 8 static List<SendPort> _servicePort = new List(_SERVICE_PORT_COUNT);
48 static ReceivePort _receivePort; 9 static ReceivePort _receivePort;
49 static SendPort _replyToPort; 10 static SendPort _replyToPort;
50 static Map<int, Completer> _messageMap = {}; 11 static Map<int, Completer> _messageMap = {};
51 static int _id = 0; 12 static int _id = 0;
52 13
53 static Future dispatch(int request, List data) { 14 /* patch */ static Future dispatch(int request, List data) {
54 int id; 15 int id;
55 do { 16 do {
56 id = _getNextId(); 17 id = _getNextId();
57 } while (_messageMap.containsKey(id)); 18 } while (_messageMap.containsKey(id));
58 int index = id % _SERVICE_PORT_COUNT; 19 int index = id % _SERVICE_PORT_COUNT;
59 _initialize(index); 20 _initialize(index);
60 var completer = new Completer(); 21 var completer = new Completer();
61 _messageMap[id] = completer; 22 _messageMap[id] = completer;
62 _servicePort[index].send([id, request, data], _replyToPort); 23 _servicePort[index].send([id, request, data], _replyToPort);
63 return completer.future; 24 return completer.future;
(...skipping 18 matching lines...) Expand all
82 } 43 }
83 } 44 }
84 45
85 static int _getNextId() { 46 static int _getNextId() {
86 if (_id == 0x7FFFFFFF) _id = 0; 47 if (_id == 0x7FFFFFFF) _id = 0;
87 return _id++; 48 return _id++;
88 } 49 }
89 50
90 static SendPort _newServicePort() native "IOService_NewServicePort"; 51 static SendPort _newServicePort() native "IOService_NewServicePort";
91 } 52 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698