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

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: 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
Index: runtime/bin/websocket_impl.dart
diff --git a/runtime/bin/websocket_impl.dart b/runtime/bin/websocket_impl.dart
index 6be62008a96b76d94dec5ea1cac50a9c81bdbedc..a673c25b80b2cfc2ebda189d02db535207b878b7 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.nextDouble() * 0x100000000).toInt();
Anders Johnsen 2012/08/22 07:37:53 Use nextInt(0x100000000)?
Mads Ager (google) 2012/08/22 13:42:41 Done.
intToBigEndianBytes(r, nonce, i * 4);
}
_nonce = _Base64._encode(nonce);
- _hash = (Math.random() * 0x100000000).toInt();
+ _hash = (random.nextDouble() * 0x100000000).toInt();
Anders Johnsen 2012/08/22 07:37:53 Ditto.
Mads Ager (google) 2012/08/22 13:42:41 Done.
}
bool _isWebSocketUpgrade(HttpClientResponse response) {

Powered by Google App Engine
This is Rietveld 408576698