Chris Craik | b2cbf15 | 2015-07-28 16:26:29 -0700 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | Copyright (c) 2015 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="/base/guid.html"> |
| 9 | <link rel="import" href="/base/range.html"> |
| 10 | <link rel="import" href="/model/event_container.html"> |
| 11 | <link rel="import" href="/model/power_series.html"> |
| 12 | |
| 13 | <script> |
| 14 | 'use strict'; |
| 15 | |
| 16 | /** |
| 17 | * @fileoverview Provides the Device class. |
| 18 | */ |
| 19 | tr.exportTo('tr.model', function() { |
| 20 | |
| 21 | /** |
| 22 | * Device represents the device-level objects in the model. |
| 23 | * @constructor |
| 24 | * @extends {tr.model.EventContainer} |
| 25 | */ |
| 26 | function Device(model) { |
| 27 | if (!model) |
| 28 | throw new Error('Must provide a model.'); |
| 29 | |
| 30 | tr.model.EventContainer.call(this); |
| 31 | |
| 32 | this.guid = tr.b.GUID.allocate(); |
| 33 | this.powerSeries_ = undefined; |
| 34 | this.vSyncTimestamps_ = []; |
| 35 | }; |
| 36 | |
| 37 | Device.compare = function(x, y) { |
| 38 | return x.guid - y.guid; |
| 39 | }; |
| 40 | |
| 41 | Device.prototype = { |
| 42 | __proto__: tr.model.EventContainer.prototype, |
| 43 | |
| 44 | compareTo: function(that) { |
| 45 | return Device.compare(this, that); |
| 46 | }, |
| 47 | |
| 48 | get userFriendlyName() { |
| 49 | return 'Device'; |
| 50 | }, |
| 51 | |
| 52 | get userFriendlyDetails() { |
| 53 | return 'Device'; |
| 54 | }, |
| 55 | |
| 56 | get stableId() { |
| 57 | return 'Device'; |
| 58 | }, |
| 59 | |
| 60 | getSettingsKey: function() { |
| 61 | return 'device'; |
| 62 | }, |
| 63 | |
| 64 | get powerSeries() { |
| 65 | return this.powerSeries_; |
| 66 | }, |
| 67 | |
| 68 | set powerSeries(powerSeries) { |
| 69 | this.powerSeries_ = powerSeries; |
| 70 | }, |
| 71 | |
| 72 | get vSyncTimestamps() { |
| 73 | return this.vSyncTimestamps_; |
| 74 | }, |
| 75 | |
| 76 | set vSyncTimestamps(value) { |
| 77 | this.vSyncTimestamps_ = value; |
| 78 | }, |
| 79 | |
| 80 | updateBounds: function() { |
| 81 | this.bounds.reset(); |
| 82 | |
| 83 | this.iterateAllChildEventContainers(function(child) { |
| 84 | child.updateBounds(); |
| 85 | this.bounds.addRange(child.bounds); |
| 86 | }, this); |
| 87 | }, |
| 88 | |
| 89 | shiftTimestampsForward: function(amount) { |
| 90 | this.iterateAllChildEventContainers(function(child) { |
| 91 | child.shiftTimestampsForward(amount); |
| 92 | }); |
| 93 | |
| 94 | for (var i = 0; i < this.vSyncTimestamps_.length; i++) |
| 95 | this.vSyncTimestamps_[i] += amount; |
| 96 | }, |
| 97 | |
| 98 | addCategoriesToDict: function(categoriesDict) { |
| 99 | }, |
| 100 | |
| 101 | iterateAllEventsInThisContainer: function(eventTypePredicate, |
| 102 | callback, opt_this) { |
| 103 | }, |
| 104 | |
| 105 | iterateAllChildEventContainers: function(callback, opt_this) { |
| 106 | if (this.powerSeries_) |
| 107 | callback.call(opt_this, this.powerSeries_); |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | return { |
| 112 | Device: Device |
| 113 | }; |
| 114 | }); |
| 115 | </script> |