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

Unified Diff: runtime/bin/websocket_impl.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/stream_util.dart ('k') | runtime/lib/math_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/websocket_impl.dart
diff --git a/runtime/bin/websocket_impl.dart b/runtime/bin/websocket_impl.dart
index 6be62008a96b76d94dec5ea1cac50a9c81bdbedc..6880dcc94b51c3ba065537cb6e3240748f9d916b 100644
--- a/runtime/bin/websocket_impl.dart
+++ b/runtime/bin/websocket_impl.dart
@@ -727,6 +727,7 @@ class _WebSocketClientConnection
}
void _generateNonceAndHash() {
+ Random random = new Random();
assert(_nonce == null);
void intToBigEndianBytes(int value, List<int> bytes, int offset) {
bytes[offset] = (value >> 24) & 0xFF;
@@ -738,11 +739,11 @@ class _WebSocketClientConnection
// Generate 16 random bytes. Use the last four bytes for the hash code.
List<int> nonce = new List<int>(16);
for (int i = 0; i < 4; i++) {
- int r = (Math.random() * 0x100000000).toInt();
+ int r = random.nextInt(0x100000000);
intToBigEndianBytes(r, nonce, i * 4);
}
_nonce = _Base64._encode(nonce);
- _hash = (Math.random() * 0x100000000).toInt();
+ _hash = random.nextInt(0x100000000);
}
bool _isWebSocketUpgrade(HttpClientResponse response) {
« no previous file with comments | « runtime/bin/stream_util.dart ('k') | runtime/lib/math_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698