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

Unified Diff: runtime/observatory/lib/base64.dart

Issue 1374113006: Use the new Base64 support from dart:convert in Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | runtime/observatory/lib/service.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/base64.dart
diff --git a/runtime/observatory/lib/base64.dart b/runtime/observatory/lib/base64.dart
deleted file mode 100644
index 4bb0f705328202cf851d78e102eda1eb5b0a508b..0000000000000000000000000000000000000000
--- a/runtime/observatory/lib/base64.dart
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library base64;
-
-import 'dart:typed_data';
-
-const _decodeTable =
- const [null, null, null, null, null, null, null, null,
- null, null, null, null, null, null, null, null,
- null, null, null, null, null, null, null, null,
- null, null, null, null, null, null, null, null,
- null, null, null, null, null, null, null, null,
- null, null, null, 62, null, null, null, 63,
- 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, null, null, null, 0, null, null,
- null, 0, 1, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, null, null, null, null, null,
- null, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51];
-
-Uint8List decodeBase64(String s) {
- if (s.length % 4 != 0) throw "Malformed Base64: $s";
-
- var odd_bits = 0;
- if (s[s.length - 1] == '=') {
- if (s[s.length - 2] == '=') {
- odd_bits = 2;
- } else {
- odd_bits = 1;
- }
- }
-
- var decodedByteLength = s.length ~/ 4 * 3 - odd_bits;
- var result = new Uint8List(decodedByteLength);
- var limit = s.length;
- if (odd_bits != 0) {
- limit = limit - 4;
- }
-
- var i = 0, j = 0;
- while (i < limit) {
- var triple = _decodeTable[s.codeUnitAt(i++)];
- triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
- triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
- triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
- result[j++] = triple >> 16;
- result[j++] = (triple >> 8) & 255;
- result[j++] = triple & 255;
- }
-
- if (odd_bits != 0) {
- var triple = _decodeTable[s.codeUnitAt(i++)];
- triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
- triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
- triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
- result[j++] = triple >> 16;
- if (odd_bits == 1) {
- result[j++] = (triple >> 8) & 255;
- }
- }
- assert(j == decodedByteLength);
- return result;
-}
« no previous file with comments | « no previous file | runtime/observatory/lib/service.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698