OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 abstract class _IOResourceInfo { | 7 abstract class _IOResourceInfo { |
8 final String type; | 8 final String type; |
9 final int id; | 9 final int id; |
10 String get name; | 10 String get name; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // Not all call sites use this. In some cases, e.g., a socket, a read does | 45 // Not all call sites use this. In some cases, e.g., a socket, a read does |
46 // not always mean that we actually read some bytes (we may do a read to see | 46 // not always mean that we actually read some bytes (we may do a read to see |
47 // if there are some bytes available). | 47 // if there are some bytes available). |
48 void addRead(int bytes) { | 48 void addRead(int bytes) { |
49 totalRead += bytes; | 49 totalRead += bytes; |
50 readCount++; | 50 readCount++; |
51 lastRead = _IOResourceInfo.timestamp; | 51 lastRead = _IOResourceInfo.timestamp; |
52 } | 52 } |
53 | 53 |
54 // In cases where we read but did not neccesarily get any bytes, use this to | 54 // In cases where we read but did not necessarily get any bytes, use this to |
55 // update the readCount and timestamp. Manually update totalRead if any bytes | 55 // update the readCount and timestamp. Manually update totalRead if any bytes |
56 // where acutally read. | 56 // where actually read. |
57 void didRead() { addRead(0); } | 57 void didRead() { addRead(0); } |
58 | 58 |
59 void addWrite(int bytes) { | 59 void addWrite(int bytes) { |
60 totalWritten += bytes; | 60 totalWritten += bytes; |
61 writeCount++; | 61 writeCount++; |
62 lastWrite = _IOResourceInfo.timestamp; | 62 lastWrite = _IOResourceInfo.timestamp; |
63 } | 63 } |
64 | 64 |
65 _ReadWriteResourceInfo(String type) : | 65 _ReadWriteResourceInfo(String type) : |
66 totalRead = 0, | 66 totalRead = 0, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 static SocketOpened(_SocketResourceInfo info) { | 272 static SocketOpened(_SocketResourceInfo info) { |
273 assert(!openSockets.containsKey(info.id)); | 273 assert(!openSockets.containsKey(info.id)); |
274 openSockets[info.id] = info; | 274 openSockets[info.id] = info; |
275 } | 275 } |
276 | 276 |
277 static SocketClosed(_SocketResourceInfo info) { | 277 static SocketClosed(_SocketResourceInfo info) { |
278 assert(openSockets.containsKey(info.id)); | 278 assert(openSockets.containsKey(info.id)); |
279 openSockets.remove(info.id); | 279 openSockets.remove(info.id); |
280 } | 280 } |
281 } | 281 } |
OLD | NEW |