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

Unified Diff: runtime/bin/vmservice/client/lib/src/app/settings.dart

Issue 335463008: Allow Observatory to run as a hosted web service (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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/vmservice/client/lib/src/app/settings.dart
diff --git a/runtime/bin/vmservice/client/lib/src/app/settings.dart b/runtime/bin/vmservice/client/lib/src/app/settings.dart
new file mode 100644
index 0000000000000000000000000000000000000000..29f0c23ef80ccefc47709ee260a09228034d7157
--- /dev/null
+++ b/runtime/bin/vmservice/client/lib/src/app/settings.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2014, 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.
+
+part of app;
+
+/// Static settings database.
+class _Settings {
+ static Storage _storage = window.localStorage;
+
+ /// Associated [o] with [key]. [o] must be JSON encodable.
+ static void set(String key, dynamic o) {
turnidge 2014/07/01 00:27:47 Maybe replace o -> obj or maybe o -> value?
Cutch 2014/07/01 17:14:51 Done. value.
+ _storage[key] = JSON.encode(o);
+ }
+
+ /// Get value associated with [key]. Return value will be a JSON encodable
+ /// object.
+ static dynamic get(String key) {
+ var val = _storage[key];
+ if (val == null) {
+ return null;
+ }
+ return JSON.decode(val);
+ }
+}
+
+/// A group of settings each prefixed with group name and a dot.
+class SettingsGroup {
+ /// Group name
+ final String group;
+
+ SettingsGroup(this.group);
+
+ String _fullKey(String key) => '$group.$key';
+
+ void set(String key, dynamic o) {
+ var fullKey = _fullKey(key);
+ _Settings.set(fullKey, o);
+ }
+
+ dynamic get(String key) {
+ var fullKey = _fullKey(key);
+ return _Settings.get(fullKey);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698