OLD | NEW |
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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 const String _DART_SESSION_ID = "DARTSESSID"; | 7 const String _DART_SESSION_ID = "DARTSESSID"; |
8 | 8 |
9 // A _HttpSession is a node in a double-linked list, with _next and _prev being | 9 // A _HttpSession is a node in a double-linked list, with _next and _prev being |
10 // the previous and next pointers. | 10 // the previous and next pointers. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 // Map implementation: | 48 // Map implementation: |
49 bool containsValue(value) => _data.containsValue(value); | 49 bool containsValue(value) => _data.containsValue(value); |
50 bool containsKey(key) => _data.containsKey(key); | 50 bool containsKey(key) => _data.containsKey(key); |
51 operator [](key) => _data[key]; | 51 operator [](key) => _data[key]; |
52 void operator []=(key, value) { _data[key] = value; } | 52 void operator []=(key, value) { _data[key] = value; } |
53 putIfAbsent(key, ifAbsent) => _data.putIfAbsent(key, ifAbsent); | 53 putIfAbsent(key, ifAbsent) => _data.putIfAbsent(key, ifAbsent); |
54 addAll(Map other) => _data.addAll(other); | 54 addAll(Map other) => _data.addAll(other); |
55 remove(key) => _data.remove(key); | 55 remove(key) => _data.remove(key); |
56 void clear() => _data.clear(); | 56 void clear() { _data.clear(); } |
57 void forEach(void f(key, value)) => _data.forEach(f); | 57 void forEach(void f(key, value)) { _data.forEach(f); } |
58 Iterable get keys => _data.keys; | 58 Iterable get keys => _data.keys; |
59 Iterable get values => _data.values; | 59 Iterable get values => _data.values; |
60 int get length => _data.length; | 60 int get length => _data.length; |
61 bool get isEmpty => _data.isEmpty; | 61 bool get isEmpty => _data.isEmpty; |
62 bool get isNotEmpty => _data.isNotEmpty; | 62 bool get isNotEmpty => _data.isNotEmpty; |
63 | 63 |
64 String toString() => 'HttpSession id:$id $_data'; | 64 String toString() => 'HttpSession id:$id $_data'; |
65 } | 65 } |
66 | 66 |
67 // Private class used to manage all the active sessions. The sessions are stored | 67 // Private class used to manage all the active sessions. The sessions are stored |
(...skipping 29 matching lines...) Expand all Loading... |
97 _addToTimeoutQueue(session); | 97 _addToTimeoutQueue(session); |
98 return session; | 98 return session; |
99 } | 99 } |
100 | 100 |
101 void set sessionTimeout(int timeout) { | 101 void set sessionTimeout(int timeout) { |
102 _sessionTimeout = timeout; | 102 _sessionTimeout = timeout; |
103 _stopTimer(); | 103 _stopTimer(); |
104 _startTimer(); | 104 _startTimer(); |
105 } | 105 } |
106 | 106 |
107 void close() => _stopTimer(); | 107 void close() { _stopTimer(); } |
108 | 108 |
109 void _bumpToEnd(_HttpSession session) { | 109 void _bumpToEnd(_HttpSession session) { |
110 _removeFromTimeoutQueue(session); | 110 _removeFromTimeoutQueue(session); |
111 _addToTimeoutQueue(session); | 111 _addToTimeoutQueue(session); |
112 } | 112 } |
113 | 113 |
114 void _addToTimeoutQueue(_HttpSession session) { | 114 void _addToTimeoutQueue(_HttpSession session) { |
115 if (_head == null) { | 115 if (_head == null) { |
116 assert(_tail == null); | 116 assert(_tail == null); |
117 _tail = _head = session; | 117 _tail = _head = session; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 | 166 |
167 void _stopTimer() { | 167 void _stopTimer() { |
168 if (_timer != null) { | 168 if (_timer != null) { |
169 _timer.cancel(); | 169 _timer.cancel(); |
170 _timer = null; | 170 _timer = null; |
171 } | 171 } |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
OLD | NEW |