OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <!-- | |
3 Copyright 2016 The Chromium Authors. All rights reserved. | |
4 Use of this source code is governed by a BSD-style license that can be | |
5 found in the LICENSE file. | |
6 --> | |
7 | |
8 <link rel="import" href="/tracing/base/utils.html"> | |
9 <link rel="import" href="/tracing/value/diagnostics/diagnostic.html"> | |
10 | |
11 <script> | |
12 'use strict'; | |
13 | |
14 tr.exportTo('tr.v.d', function() { | |
15 class DeviceInfo extends tr.v.d.Diagnostic { | |
16 constructor(opt_info) { | |
17 super(); | |
18 | |
19 const info = opt_info || {}; | |
20 this.chromeVersion_ = info.chromeVersion || ''; | |
21 this.osName_ = info.osName || ''; | |
22 this.osVersion_ = info.osVersion || ''; | |
23 this.gpuInfo_ = info.gpuInfo || undefined; | |
24 this.arch_ = info.arch || undefined; | |
25 this.ram_ = info.ram || 0; | |
26 } | |
27 | |
28 addToHistogram(hist) { | |
29 hist.diagnostics.set(tr.v.d.RESERVED_NAMES.DEVICE, this); | |
30 } | |
31 | |
32 /** | |
33 * @param {!tr.v.Histogram} hist | |
34 * @return {(undefined|!tr.v.d.DeviceInfo)} | |
35 */ | |
36 static getFromHistogram(hist) { | |
37 return hist.diagnostics.get(tr.v.d.RESERVED_NAMES.DEVICE); | |
38 } | |
39 | |
40 clone() { | |
41 const clone = new tr.v.d.MergedDeviceInfo(); | |
42 clone.addDiagnostic(this); | |
43 return clone; | |
44 } | |
45 | |
46 asDictInto_(d) { | |
47 d.chromeVersion = this.chromeVersion; | |
48 d.osName = this.osName; | |
49 d.osVersion = this.osVersion; | |
50 d.gpuInfo = this.gpuInfo; | |
51 d.arch = this.arch; | |
52 d.ram = this.ram; | |
53 } | |
54 | |
55 static fromDict(d) { | |
56 return new DeviceInfo(d); | |
57 } | |
58 | |
59 get chromeVersion() { | |
60 return this.chromeVersion_; | |
61 } | |
62 | |
63 get osName() { | |
64 return this.osName_; | |
65 } | |
66 | |
67 get osVersion() { | |
68 return this.osVersion_; | |
69 } | |
70 | |
71 get gpuInfo() { | |
72 return this.gpuInfo_; | |
73 } | |
74 | |
75 get arch() { | |
76 return this.arch_; | |
77 } | |
78 | |
79 get ram() { | |
80 return this.ram_; | |
81 } | |
82 } | |
83 | |
84 tr.v.d.Diagnostic.register(DeviceInfo, { | |
85 elementName: 'tr-v-ui-device-info-span' | |
86 }); | |
87 | |
88 return { | |
89 DeviceInfo, | |
90 }; | |
91 }); | |
92 </script> | |
OLD | NEW |