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

Side by Side Diff: content/browser/resources/media/new/player_info.js

Issue 23769009: Removes the --enable-new-media-internals flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unused files from old-media-internals Created 7 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2013 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 /**
6 * @fileoverview A class for keeping track of the details of a player.
7 */
8
9 var PlayerInfo = (function() {
10 'use strict';
11
12 /**
13 * A class that keeps track of properties on a media player.
14 * @param id A unique id that can be used to identify this player.
15 */
16 function PlayerInfo(id) {
17 this.id = id;
18 // The current value of the properties for this player.
19 this.properties = {};
20 // All of the past (and present) values of the properties.
21 this.pastValues = {};
22
23 // Every single event in the order in which they were received.
24 this.allEvents = [];
25 this.lastRendered = 0;
26
27 this.firstTimestamp_ = -1;
28 }
29
30 PlayerInfo.prototype = {
31 /**
32 * Adds or set a property on this player.
33 * This is the default logging method as it keeps track of old values.
34 * @param timestamp The time in milliseconds since the Epoch.
35 * @param key A String key that describes the property.
36 * @param value The value of the property.
37 */
38 addProperty: function(timestamp, key, value) {
39 // The first timestamp that we get will be recorded.
40 // Then, all future timestamps are deltas of that.
41 if (this.firstTimestamp_ === -1) {
42 this.firstTimestamp_ = timestamp;
43 }
44
45 if (typeof key !== 'string') {
46 throw new Error(typeof key + ' is not a valid key type');
47 }
48
49 this.properties[key] = value;
50
51 if (!this.pastValues[key]) {
52 this.pastValues[key] = [];
53 }
54
55 var recordValue = {
56 time: timestamp - this.firstTimestamp_,
57 key: key,
58 value: value
59 };
60
61 this.pastValues[key].push(recordValue);
62 this.allEvents.push(recordValue);
63 },
64
65 /**
66 * Adds or set a property on this player.
67 * Does not keep track of old values. This is better for
68 * values that get spammed repeatedly.
69 * @param timestamp The time in milliseconds since the Epoch.
70 * @param key A String key that describes the property.
71 * @param value The value of the property.
72 */
73 addPropertyNoRecord: function(timestamp, key, value) {
74 this.addProperty(timestamp, key, value);
75 this.allEvents.pop();
76 }
77 };
78
79 return PlayerInfo;
80 }());
OLDNEW
« no previous file with comments | « content/browser/resources/media/new/media_internals.js ('k') | content/browser/resources/media/new/util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698