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

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

Issue 7972028: Display active media players on chrome://media-internals. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: refactor! Created 9 years, 2 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('media', function() { 5 cr.define('media', function() {
6 6
7 /** 7 /**
8 * This class represents a collection of non-intersecting ranges. Ranges 8 * This class represents a collection of non-intersecting ranges. Ranges
9 * specified by (start, end) can be added and removed at will. It is used to 9 * specified by (start, end) can be added and removed at will. It is used to
10 * record which sections of a media file have been cached, e.g. the first and 10 * record which sections of a media file have been cached, e.g. the first and
11 * last few kB plus several MB in the middle. 11 * last few kB plus several MB in the middle.
12 * 12 *
13 * Example usage: 13 * Example usage:
14 * someRange.add(0, 100); // Contains 0-100. 14 * someRange.add(0, 100); // Contains 0-100.
15 * someRange.add(150, 200); // Contains 0-100, 150-200. 15 * someRange.add(150, 200); // Contains 0-100, 150-200.
16 * someRange.remove(25, 75); // Contains 0-24, 76-100, 150-200. 16 * someRange.remove(25, 75); // Contains 0-24, 76-100, 150-200.
17 * someRange.add(25, 149); // Contains 0-200. 17 * someRange.add(25, 149); // Contains 0-200.
18 */ 18 */
19 function DisjointRangeSet() { 19 function DisjointRangeSet() {
20 this.ranges_ = {}; 20 this.ranges_ = {};
21 }; 21 }
22 22
23 DisjointRangeSet.prototype = { 23 DisjointRangeSet.prototype = {
24 /** 24 /**
25 * Deletes all ranges intersecting with (start ... end) and returns the 25 * Deletes all ranges intersecting with (start ... end) and returns the
26 * extents of the cleared area. 26 * extents of the cleared area.
27 * @param {int} start The start of the range to remove. 27 * @param {int} start The start of the range to remove.
28 * @param {int} end The end of the range to remove. 28 * @param {int} end The end of the range to remove.
29 * @param {int} sloppiness 0 removes only strictly overlapping ranges, and 29 * @param {int} sloppiness 0 removes only strictly overlapping ranges, and
30 * 1 removes adjacent ones. 30 * 1 removes adjacent ones.
31 * @return {Object} The start and end of the newly cleared range. 31 * @return {Object} The start and end of the newly cleared range.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 for (var start in this.ranges_) 136 for (var start in this.ranges_)
137 max = Math.max(max, this.ranges_[start]); 137 max = Math.max(max, this.ranges_[start]);
138 return max; 138 return max;
139 }, 139 },
140 }; 140 };
141 141
142 return { 142 return {
143 DisjointRangeSet: DisjointRangeSet 143 DisjointRangeSet: DisjointRangeSet
144 }; 144 };
145 }); 145 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698