Chromium Code Reviews| Index: chrome/browser/resources/media_internals/event_list.js |
| diff --git a/chrome/browser/resources/media_internals/event_list.js b/chrome/browser/resources/media_internals/event_list.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4695e91af9c2ed97175b323c3ddff0acc4408d3e |
| --- /dev/null |
| +++ b/chrome/browser/resources/media_internals/event_list.js |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2011 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. |
| + |
| +cr.define('media', function() { |
| + 'use strict'; |
| + |
| + /** |
| + * This class holds a list of MediaLogEvents. |
| + * It inherits from <li> and contains a tabular list of said events, |
| + * the time at which they occurred, and their parameters. |
| + */ |
| + var EventList = cr.ui.define('li'); |
| + |
| + EventList.prototype = { |
| + __proto__: HTMLLIElement.prototype, |
| + |
| + /** |
| + * Decorate this list item as an EventList. |
| + */ |
| + decorate: function() { |
| + this.table_ = document.createElement('table'); |
| + var details = document.createElement('details'); |
| + var summary = media.makeElement('summary', 'Log:'); |
| + details.appendChild(summary); |
| + details.appendChild(this.table_); |
| + this.appendChild(details); |
| + |
| + this.startTime_ = null; |
|
arv (Not doing code reviews)
2011/09/22 19:26:04
This is better done on the prototype
startTime_:
scherkus (not reviewing)
2011/09/23 06:52:41
Done.
|
| + |
| + var hRow = document.createElement('tr'); |
| + hRow.appendChild(media.makeElement('th', 'Time:')); |
| + hRow.appendChild(media.makeElement('th', 'Event:')); |
| + hRow.appendChild(media.makeElement('th', 'Parameters:')); |
| + var header = document.createElement('thead'); |
| + header.appendChild(hRow); |
| + this.table_.appendChild(header); |
| + }, |
| + |
| + /** |
| + * Add an event to the list. It is stored as a new row in this.table_. |
| + * @param {Object} event The MediaLogEvent that has occurred. |
| + */ |
| + addEvent: function(event) { |
| + this.startTime_ = this.startTime_ || event.time; |
| + event.time -= this.startTime_; |
| + |
| + var row = document.createElement('tr'); |
| + row.appendChild(media.makeElement('td', media.round(event.time))); |
| + row.appendChild(media.makeElement('td', event.type)); |
| + var params = []; |
| + for (var p in event.params) { |
| + params.push(p + ': ' + event.params[p]); |
| + } |
| + |
| + row.appendChild(media.makeElement('td', params.join(', '))); |
| + this.table_.appendChild(row); |
| + } |
| + }; |
| + |
| + return { |
| + EventList: EventList |
| + }; |
| +}); |