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

Unified Diff: content/browser/resources/media/new/player_info.js

Issue 18889006: Removed old media-internals page and rewrote it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved all 'new' media internals files into its own folder for a smooth transition. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/resources/media/new/player_info.js
diff --git a/content/browser/resources/media/new/player_info.js b/content/browser/resources/media/new/player_info.js
new file mode 100644
index 0000000000000000000000000000000000000000..8ed9c43ff3913b272d20f3db9ae8a26a108c7774
--- /dev/null
+++ b/content/browser/resources/media/new/player_info.js
@@ -0,0 +1,83 @@
+// 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.
+
+
+/**
+ * @fileoverview A class for keeping track of the details of a player.
+ */
+
+var PlayerInfo = (function () {
+ "use strict";
+
+ /**
+ * A class that keeps track of properties on a media player.
+ * @param id A unique id that can be used to identify this player.
+ * @constructor
+ */
+ function PlayerInfo(id) {
+ this.id = id;
+ // The current value of the properties for this player
+ this.properties = {};
+ // All of the past (and present) values of the properties
+ this.pastValues = {};
+
+ // Every single event in the order in which they were received
+ this.allEvents = [];
+ this.lastRendered = 0;
+
+ this.firstTimestamp = -1;
+ }
+
+
+ /**
+ * Adds or set a property on this player.
+ * This is the default logging method as it keeps track of old values
+ * @param timestamp The time in milliseconds since the Epoch
+ * @param key A String key that describes the property
+ * @param value The value of the property.
+ */
+ PlayerInfo.prototype.addProperty = function (timestamp, key, value) {
+ // The first timestamp that we get will be recorded.
+ // Then, all future timestamps are deltas of that.
+ if (this.firstTimestamp === -1) {
+ this.firstTimestamp = timestamp;
+ }
+
+ if (typeof key !== 'string') {
+ throw new Error(typeof key + " is not a valid key type");
+ }
+
+ this.properties[key] = value;
+
+ if (!this.pastValues[key]) {
+ // Preallocate for performance
+ this.pastValues[key] = new Array(512);
+ }
+
+ var recordValue = {
+ time: timestamp - this.firstTimestamp,
+ key: key,
+ value: value
+ };
+
+ this.pastValues[key].push(recordValue);
+ this.allEvents.push(recordValue);
+ };
+
+
+ /**
+ * Adds or set a property on this player.
+ * Does not keep track of old values. This is better for
+ * values that get spammed repeatedly.
+ * @param timestamp The time in milliseconds since the Epoch
+ * @param key A String key that describes the property
+ * @param value The value of the property.
+ */
+ PlayerInfo.prototype.addPropertyNoRecord = function (timestamp, key, value) {
+ this.addProperty(timestamp, key, value);
+ this.allEvents.pop();
+ };
+
+ return PlayerInfo;
+}());
« no previous file with comments | « content/browser/resources/media/new/number_graph.js ('k') | content/browser/resources/media/new/player_list_painter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698