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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* @fileoverview Provides the Process class.
*/
base.require('tracing.trace_model.cpu');
base.require('tracing.trace_model.process_base');
base.exportTo('tracing.trace_model', function() {
var Cpu = tracing.trace_model.Cpu;
var ProcessBase = tracing.trace_model.ProcessBase;
/**
* The Kernel represents kernel-level objects in the
* model.
* @constructor
*/
function Kernel(model) {
if (model === undefined)
throw new Error('model must be provided');
ProcessBase.call(this, model);
this.cpus = {};
};
/**
* Comparison between kernels is pretty meaningless.
*/
Kernel.compare = function(x, y) {
return 0;
};
Kernel.prototype = {
__proto__: ProcessBase.prototype,
compareTo: function(that) {
return Kernel.compare(this, that);
},
get userFriendlyName() {
return 'Kernel';
},
get userFriendlyDetails() {
return 'Kernel';
},
/**
* @return {Cpu} Gets a specific Cpu or creates one if
* it does not exist.
*/
getOrCreateCpu: function(cpuNumber) {
if (!this.cpus[cpuNumber])
this.cpus[cpuNumber] = new Cpu(cpuNumber);
return this.cpus[cpuNumber];
},
shiftTimestampsForward: function(amount) {
ProcessBase.prototype.shiftTimestampsForward.call(this);
for (var cpuNumber in this.cpus)
this.cpus[cpuNumber].shiftTimestampsForward(amount);
},
updateBounds: function() {
ProcessBase.prototype.updateBounds.call(this);
for (var cpuNumber in this.cpus) {
var cpu = this.cpus[cpuNumber];
cpu.updateBounds();
this.bounds.addRange(cpu.bounds);
}
},
addCategoriesToDict: function(categoriesDict) {
ProcessBase.prototype.addCategoriesToDict.call(this, categoriesDict);
for (var cpuNumber in this.cpus)
this.cpus[cpuNumber].addCategoriesToDict(categoriesDict);
},
getSettingsKey: function() {
return 'kernel';
},
iterateAllEvents: function(callback) {
for (var cpuNumber in this.cpus)
this.cpus[cpuNumber].iterateAllEvents(callback);
ProcessBase.prototype.iterateAllEvents.call(this, callback);
}
};
return {
Kernel: Kernel
};
});
|