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

Side by Side Diff: content/browser/resources/media/main/playerManager.js

Issue 18889006: Removed old media-internals page and rewrote it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * @fileoverview Keeps track of all the existing
3 * PlayerProperty objects and is the entry-point for messages from the backend.
4 */
5 var PlayerManager = (function () {
6 "use strict";
7
8 function PlayerManager() {
9 this.players = {};
10 this.renderman = new RenderManager(this);
11
12 var removeCheckbox = document.querySelector("#removal-checkbox");
13 this.shouldRemovePlayer = function () {
14 return removeCheckbox.checked;
15 };
16 removeCheckbox.onclick = function () {
17 if (removeCheckbox.checked) {
18 goog.object.forEach(this.players, function (playerInfo, id) {
19 if (playerInfo.toRemove) {
20 this.removePlayer(id);
21 }
22 }, this);
23 }
24 }.bind(this);
25 }
26
27
28 /**
29 * Adds a player to the list of players to manage.
30 */
31 PlayerManager.prototype.addPlayer = function (id) {
32 if (this.players[id]) {
33 return;
34 }
35 // Make the PlayerProperty and add it to the mapping
36 this.players[id] = new PlayerInfo(id);
37
38 this.renderman.redrawList();
39 };
40
41 PlayerManager.prototype.removePlayer = function (id) {
42 if (this.shouldRemovePlayer()) {
43 delete this.players[id];
44 } else if (this.players[id]) {
45 this.players[id].toRemove = true;
46 }
47 this.renderman.redrawList();
48 };
49
50
51 PlayerManager.prototype.selectPlayer = function (id) {
52 if (!this.players[id]) {
53 throw new Error("[selectPlayer] Id " + id + " does not exist.");
54 }
55
56 this.renderman.select(id);
57 };
58
59 PlayerManager.prototype.updatePlayerInfoNoRecord =
60 function (id, timestamp, key, value) {
61 if (!this.players[id]) {
62 console.error("[updatePlayerInfo] Id " + id +
63 " does not exist");
64 return;
65 }
66
67 this.players[id].addPropertyNoRecord(timestamp, key, value);
68
69
70 // If we can potentially rename the player, do so.
71 if (key === 'name' || key === 'url') {
72 this.renderman.redrawList();
73 }
74
75 this.renderman.update();
76 };
77
78 PlayerManager.prototype.updatePlayerInfo =
79 function (id, timestamp, key, value) {
80 if (!this.players[id]) {
81 console.error("[updatePlayerInfo] Id " + id +
82 " does not exist");
83 return;
84 }
85
86 this.players[id].addProperty(timestamp, key, value);
87
88
89 // If we can potentially rename the player, do so.
90 if (key === 'name' || key === 'url') {
91 this.renderman.redrawList();
92 }
93
94 this.renderman.update();
95 };
96
97 return PlayerManager;
98 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698