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

Side by Side Diff: tracing/tracing/base/unit.html

Issue 2776653002: [ESLint] Fix violations when enabling curly rule in eslint. (Closed)
Patch Set: rebase Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « tracing/tracing/base/timing_test.html ('k') | tracing/tracing/base/unit_scale.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2015 The Chromium Authors. All rights reserved. 3 Copyright 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/event.html"> 8 <link rel="import" href="/tracing/base/event.html">
9 <link rel="import" href="/tracing/base/event_target.html"> 9 <link rel="import" href="/tracing/base/event_target.html">
10 <link rel="import" href="/tracing/base/iteration_helpers.html"> 10 <link rel="import" href="/tracing/base/iteration_helpers.html">
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 minimumFractionDigits, 46 minimumFractionDigits,
47 maximumFractionDigits, 47 maximumFractionDigits,
48 }); 48 });
49 49
50 CACHED_FORMATTERS[key] = formatter; 50 CACHED_FORMATTERS[key] = formatter;
51 } 51 }
52 return formatter; 52 return formatter;
53 } 53 }
54 54
55 function max(a, b) { 55 function max(a, b) {
56 if (a === undefined) 56 if (a === undefined) return b;
57 return b; 57 if (b === undefined) return a;
58 if (b === undefined)
59 return a;
60 return a.scale > b.scale ? a : b; 58 return a.scale > b.scale ? a : b;
61 } 59 }
62 60
63 /** @enum */ 61 /** @enum */
64 var ImprovementDirection = { 62 var ImprovementDirection = {
65 DONT_CARE: 0, 63 DONT_CARE: 0,
66 BIGGER_IS_BETTER: 1, 64 BIGGER_IS_BETTER: 1,
67 SMALLER_IS_BETTER: 2 65 SMALLER_IS_BETTER: 2
68 }; 66 };
69 67
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return tr.b.convertUnit(us, tr.b.UnitPrefixScale.METRIC.MICRO, 197 return tr.b.convertUnit(us, tr.b.UnitPrefixScale.METRIC.MICRO,
200 tr.b.UnitPrefixScale.METRIC.MILLI); 198 tr.b.UnitPrefixScale.METRIC.MILLI);
201 }; 199 };
202 200
203 Object.defineProperty(Unit, 'currentTimeDisplayMode', { 201 Object.defineProperty(Unit, 'currentTimeDisplayMode', {
204 get: function() { 202 get: function() {
205 return Unit.currentTimeDisplayMode_; 203 return Unit.currentTimeDisplayMode_;
206 }, 204 },
207 // Use tr-v-ui-preferred-display-unit element instead of directly setting. 205 // Use tr-v-ui-preferred-display-unit element instead of directly setting.
208 set: function(value) { 206 set: function(value) {
209 if (Unit.currentTimeDisplayMode_ === value) 207 if (Unit.currentTimeDisplayMode_ === value) return;
210 return;
211 208
212 Unit.currentTimeDisplayMode_ = value; 209 Unit.currentTimeDisplayMode_ = value;
213 Unit.dispatchEvent(new tr.b.Event('display-mode-changed')); 210 Unit.dispatchEvent(new tr.b.Event('display-mode-changed'));
214 } 211 }
215 }); 212 });
216 213
217 Unit.didPreferredTimeDisplayUnitChange = function() { 214 Unit.didPreferredTimeDisplayUnitChange = function() {
218 var largest = undefined; 215 var largest = undefined;
219 // TODO(aiolos): base should not depend on ui. Move the functionality of 216 // TODO(aiolos): base should not depend on ui. Move the functionality of
220 // searching for preferred-display-unit out of Unit. 217 // searching for preferred-display-unit out of Unit.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 'Unknown improvement direction: ' + improvementDirection); 294 'Unknown improvement direction: ' + improvementDirection);
298 } 295 }
299 }; 296 };
300 297
301 Unit.defineUnitVariant_ = function(params, isDelta, improvementDirection) { 298 Unit.defineUnitVariant_ = function(params, isDelta, improvementDirection) {
302 var nameSuffix = isDelta ? 'Delta' : ''; 299 var nameSuffix = isDelta ? 'Delta' : '';
303 nameSuffix += Unit.nameSuffixForImprovementDirection(improvementDirection); 300 nameSuffix += Unit.nameSuffixForImprovementDirection(improvementDirection);
304 301
305 var unitName = params.baseUnitName + nameSuffix; 302 var unitName = params.baseUnitName + nameSuffix;
306 var jsonName = params.baseJsonName + nameSuffix; 303 var jsonName = params.baseJsonName + nameSuffix;
307 if (Unit.byName[unitName] !== undefined) 304 if (Unit.byName[unitName] !== undefined) {
308 throw new Error('Unit \'' + unitName + '\' already exists'); 305 throw new Error('Unit \'' + unitName + '\' already exists');
309 if (Unit.byJSONName[jsonName] !== undefined) 306 }
307 if (Unit.byJSONName[jsonName] !== undefined) {
310 throw new Error('JSON unit \'' + jsonName + '\' alread exists'); 308 throw new Error('JSON unit \'' + jsonName + '\' alread exists');
309 }
311 310
312 var scaleBaseUnit = params.scaleBaseUnit; 311 var scaleBaseUnit = params.scaleBaseUnit;
313 if (!scaleBaseUnit) { 312 if (!scaleBaseUnit) {
314 var formatSpec = params.formatSpec; 313 var formatSpec = params.formatSpec;
315 if (typeof formatSpec === 'function') formatSpec = formatSpec(); 314 if (typeof formatSpec === 'function') formatSpec = formatSpec();
316 var baseSymbol = formatSpec.unitScale ? 315 var baseSymbol = formatSpec.unitScale ?
317 formatSpec.unitScale[0].baseSymbol : (formatSpec.baseSymbol || ''); 316 formatSpec.unitScale[0].baseSymbol : (formatSpec.baseSymbol || '');
318 scaleBaseUnit = { value: 1, symbol: baseSymbol, baseSymbol: baseSymbol }; 317 scaleBaseUnit = { value: 1, symbol: baseSymbol, baseSymbol: baseSymbol };
319 } 318 }
320 var unit = new Unit(unitName, jsonName, scaleBaseUnit, 319 var unit = new Unit(unitName, jsonName, scaleBaseUnit,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 maximumFractionDigits: 1 425 maximumFractionDigits: 1
427 } 426 }
428 }); 427 });
429 428
430 return { 429 return {
431 ImprovementDirection, 430 ImprovementDirection,
432 Unit, 431 Unit,
433 }; 432 };
434 }); 433 });
435 </script> 434 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/base/timing_test.html ('k') | tracing/tracing/base/unit_scale.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698