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

Unified Diff: tracing/tracing/base/range.html

Issue 1300433003: Add range toJSON and fromDict (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Created 5 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 | « no previous file | tracing/tracing/base/range_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/base/range.html
diff --git a/tracing/tracing/base/range.html b/tracing/tracing/base/range.html
index b3722146ea7eb2990b5980a4d5b37614ce140e07..767c8671fa386e76f8e8463487497155c5fc4e74 100644
--- a/tracing/tracing/base/range.html
+++ b/tracing/tracing/base/range.html
@@ -132,6 +132,29 @@ tr.exportTo('tr.b', function() {
return new Range();
return Range.fromExplicitRange(min, max);
+ },
+
+ toJSON: function() {
+ if (this.isEmpty_)
+ return {isEmpty: true};
+ return {
+ isEmpty: false,
+ max: this.max,
+ min: this.min
+ };
+ }
+ };
+
+ Range.fromDict = function(d) {
+ if (d.isEmpty === true) {
+ return new Range();
+ } else if (d.isEmpty === false) {
+ var range = new Range();
+ range.min = d.min;
+ range.max = d.max;
+ return range;
+ } else {
+ throw new Error('Not a range');
}
};
« no previous file with comments | « no previous file | tracing/tracing/base/range_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698