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

Side by Side Diff: chrome/browser/resources/media_internals/event_list.js

Issue 12153002: Move chrome://media-internals to content. This allows us to hide implementation details from the pu… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('media', function() {
6 'use strict';
7
8 /**
9 * This class holds a list of MediaLogEvents.
10 * It inherits from <li> and contains a tabular list of said events,
11 * the time at which they occurred, and their parameters.
12 */
13 var EventList = cr.ui.define('li');
14
15 EventList.prototype = {
16 __proto__: HTMLLIElement.prototype,
17 startTime_: null,
18
19 /**
20 * Decorate this list item as an EventList.
21 */
22 decorate: function() {
23 this.table_ = document.createElement('table');
24 var details = document.createElement('details');
25 var summary = media.makeElement('summary', 'Log:');
26 details.appendChild(summary);
27 details.appendChild(this.table_);
28 this.appendChild(details);
29
30 var hRow = document.createElement('tr');
31 hRow.appendChild(media.makeElement('th', 'Time:'));
32 hRow.appendChild(media.makeElement('th', 'Event:'));
33 hRow.appendChild(media.makeElement('th', 'Parameters:'));
34 var header = document.createElement('thead');
35 header.appendChild(hRow);
36 this.table_.appendChild(header);
37 },
38
39 /**
40 * Add an event to the list. It is stored as a new row in this.table_.
41 * @param {Object} event The MediaLogEvent that has occurred.
42 */
43 addEvent: function(event) {
44 var timeInMs = event.time * 1000; // Work with milliseconds.
45 this.startTime_ = this.startTime_ || timeInMs;
46 timeInMs -= this.startTime_;
47
48 var row = document.createElement('tr');
49 row.appendChild(media.makeElement('td', timeInMs.toFixed(1)));
50 row.appendChild(media.makeElement('td', event.type));
51 var params = [];
52 for (var key in event.params) {
53 params.push(key + ': ' + event.params[key]);
54 }
55
56 row.appendChild(media.makeElement('td', params.join(', ')));
57 this.table_.appendChild(row);
58 }
59 };
60
61 return {
62 EventList: EventList
63 };
64 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698