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

Unified Diff: ui/file_manager/audio_player/js/audio_player.js

Issue 2456153002: Audio player: Throttle concurrent loading of audio metadata. (Closed)
Patch Set: Added a comment. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/audio_player/js/audio_player.js
diff --git a/ui/file_manager/audio_player/js/audio_player.js b/ui/file_manager/audio_player/js/audio_player.js
index 0bb4ee2b6d3076ff1548fd1b1ee849b8fb4c8a12..8781ea157bfd9e9dfa9c73c6fe97030bfcd884c0 100644
--- a/ui/file_manager/audio_player/js/audio_player.js
+++ b/ui/file_manager/audio_player/js/audio_player.js
@@ -47,6 +47,15 @@ function AudioPlayer(container) {
/** @type {AudioPlayerElement} */ (document.querySelector('audio-player'));
this.player_.tracks = [];
+ /**
+ * Queue to throttle concurrent reading of audio file metadata.
+ * Here we loads up to 25 songs concurrently to cover the number of songs in
+ * an album in most cases. This number should not be too large so that the
+ * number of open file descriptors will not hit the system limit.
+ * @private {AsyncUtil.ConcurrentQueue}
+ */
+ this.loadMetadataQueue_ = new AsyncUtil.ConcurrentQueue(25);
+
// Restore the saved state from local storage, and update the local storage
// if the states are changed.
var STORAGE_PREFIX = 'audioplayer-';
@@ -216,8 +225,12 @@ AudioPlayer.prototype.load = function(playlist) {
* @private
*/
AudioPlayer.prototype.loadMetadata_ = function(track) {
- this.fetchMetadata_(
- this.entries_[track], this.displayMetadata_.bind(this, track));
+ this.loadMetadataQueue_.run(function(callback) {
+ this.fetchMetadata_(this.entries_[track], function(metadata) {
+ this.displayMetadata_(track, metadata);
+ callback();
+ }.bind(this));
+ }.bind(this));
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698