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

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

Issue 23536020: Adds cache and buffer graphs to the properties pane. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaned up code 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * A global object that gets used by the C++ interface. 6 * A global object that gets used by the C++ interface.
7 */ 7 */
8 var media = (function() { 8 var media = (function() {
9 'use strict'; 9 'use strict';
10 10
11 var manager_ = null; 11 var manager_ = null;
12 var eventPhases_ = {};
scherkus (not reviewing) 2013/09/04 23:20:53 can we get some short comments describing what eac
Ty Overby 2013/09/05 21:01:02 Done.
13 var eventTypes_ = {};
14
15 var cacheEntries_ = {};
16 var cacheEntriesByKey_ = {};
17
18 var requestURLs_ = {};
19
20 var media = {
21 BAR_WIDTH: 200,
22 BAR_HEIGHT: 25
23 };
12 24
13 /** 25 /**
14 * Users of |media| must call initialize prior to calling other methods. 26 * Users of |media| must call initialize prior to calling other methods.
15 */ 27 */
16 media.initialize = function(manager) { 28 media.initialize = function(manager) {
17 manager_ = manager; 29 manager_ = manager;
18 }; 30 };
19 31
20 media.onReceiveEverything = function(everything) { 32 media.onReceiveEverything = function(everything) {
21 for (var key in everything.audio_streams) { 33 for (var key in everything.audio_streams) {
22 media.updateAudioStream(everything.audio_streams[key]); 34 media.updateAudioStream(everything.audio_streams[key]);
23 } 35 }
24 }; 36 };
25 37
26 media.onNetUpdate = function(update) { 38 media.onReceiveConstants = function(constants) {
27 // TODO(tyoverby): Implement 39 for (var key in constants.eventTypes) {
40 var value = constants.eventTypes[key];
41 eventTypes_[value] = key;
42 }
43
44 for (var key in constants.eventPhases) {
45 var value = constants.eventPhases[key];
46 eventPhases_[value] = key;
47 }
48 };
49
50 media.cacheForUrl = function(url) {
51 return cacheEntriesByKey_[url];
52 };
53
54 media.onNetUpdate = function(updates) {
55 updates.forEach(function(update) {
56 var id = update.source.id;
57 if (!cacheEntries_[id])
58 cacheEntries_[id] = new media.CacheEntry;
59
60 switch (eventPhases_[update.phase] + '.' + eventTypes_[update.type]) {
61 case 'PHASE_BEGIN.DISK_CACHE_ENTRY_IMPL':
scherkus (not reviewing) 2013/09/04 23:20:53 case statements should be indented by 2 more space
Ty Overby 2013/09/05 21:01:02 Done.
62 var key = update.params.key;
63
64 // Merge this source with anything we already know about this key.
65 if (cacheEntriesByKey_[key]) {
66 cacheEntriesByKey_[key].merge(cacheEntries_[id]);
67 cacheEntries_[id] = cacheEntriesByKey_[key];
68 } else {
69 cacheEntriesByKey_[key] = cacheEntries_[id];
70 }
71 cacheEntriesByKey_[key].key = key;
72 break;
73
74 case 'PHASE_BEGIN.SPARSE_READ':
75 cacheEntries_[id].readBytes(update.params.offset,
76 update.params.buff_len);
77 cacheEntries_[id].sparse = true;
78 break;
79
80 case 'PHASE_BEGIN.SPARSE_WRITE':
81 cacheEntries_[id].writeBytes(update.params.offset,
82 update.params.buff_len);
83 cacheEntries_[id].sparse = true;
84 break;
85
86 case 'PHASE_BEGIN.URL_REQUEST_START_JOB':
87 requestURLs_[update.source.id] = update.params.url;
88 break;
89
90 case 'PHASE_NONE.HTTP_TRANSACTION_READ_RESPONSE_HEADERS':
91 // Record the total size of the file if this was a range request.
92 var range = /content-range:\s*bytes\s*\d+-\d+\/(\d+)/i.exec(
93 update.params.headers);
94 var key = requestURLs_[update.source.id];
95 delete requestURLs_[update.source.id];
96 if (range && key) {
97 if (!cacheEntriesByKey_[key]) {
98 cacheEntriesByKey_[key] = new media.CacheEntry;
99 cacheEntriesByKey_[key].key = key;
100 }
101 cacheEntriesByKey_[key].size = range[1];
102 }
103 break;
104 }
105 });
28 }; 106 };
29 107
30 media.onRendererTerminated = function(renderId) { 108 media.onRendererTerminated = function(renderId) {
31 util.object.forEach(manager_.players_, function(playerInfo, id) { 109 util.object.forEach(manager_.players_, function(playerInfo, id) {
32 if (playerInfo.properties['render_id'] == renderId) { 110 if (playerInfo.properties['render_id'] == renderId) {
33 manager_.removePlayer(id); 111 manager_.removePlayer(id);
34 } 112 }
35 }); 113 });
36 }; 114 };
37 115
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 170 }
93 propertyCount += 1; 171 propertyCount += 1;
94 }); 172 });
95 173
96 if (propertyCount === 0) { 174 if (propertyCount === 0) {
97 manager_.updatePlayerInfo( 175 manager_.updatePlayerInfo(
98 source, event.ticksMillis, 'EVENT', event.type); 176 source, event.ticksMillis, 'EVENT', event.type);
99 } 177 }
100 }; 178 };
101 179
180 chrome.send('getEverything');
102 return media; 181 return media;
103 }()); 182 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698