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

Unified Diff: ui/file_manager/file_manager/foreground/js/metadata/mpeg_parser.js

Issue 391313003: Files.app: mpeg metadata parser must not be stateful. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« 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/file_manager/foreground/js/metadata/mpeg_parser.js
diff --git a/ui/file_manager/file_manager/foreground/js/metadata/mpeg_parser.js b/ui/file_manager/file_manager/foreground/js/metadata/mpeg_parser.js
index 03637cff6ad5909773a354e9218af691c43ec128..36ede26cf34ad15629f3d55c51d5b2634c63e5ef 100644
--- a/ui/file_manager/file_manager/foreground/js/metadata/mpeg_parser.js
+++ b/ui/file_manager/file_manager/foreground/js/metadata/mpeg_parser.js
@@ -149,10 +149,10 @@ MpegParser.createRootParser = function(metadata) {
* @param {function} onError Error callback.
*/
MpegParser.prototype.parse = function(file, metadata, callback, onError) {
- this.rootParser_ = MpegParser.createRootParser(metadata);
+ var rootParser = MpegParser.createRootParser(metadata);
// Kick off the processing by reading the first atom's header.
- this.requestRead(file, 0, MpegParser.HEADER_SIZE, null,
+ this.requestRead(rootParser, file, 0, MpegParser.HEADER_SIZE, null,
onError, callback.bind(null, metadata));
};
@@ -231,6 +231,7 @@ MpegParser.prototype.parseMpegAtomsInRange = function(
};
/**
+ * @param {Object} rootParser Parser definition.
* @param {File} file File.
* @param {number} filePos Start position in the file.
* @param {number} size Atom size.
@@ -239,13 +240,14 @@ MpegParser.prototype.parseMpegAtomsInRange = function(
* @param {function} onSuccess Success callback.
*/
MpegParser.prototype.requestRead = function(
- file, filePos, size, name, onError, onSuccess) {
+ rootParser, file, filePos, size, name, onError, onSuccess) {
var self = this;
var reader = new FileReader();
reader.onerror = onError;
reader.onload = function(event) {
self.processTopLevelAtom(
- reader.result, file, filePos, size, name, onError, onSuccess);
+ reader.result, rootParser, file, filePos, size, name,
+ onError, onSuccess);
};
this.vlog('reading @' + filePos + ':' + size);
reader.readAsArrayBuffer(file.slice(filePos, filePos + size));
@@ -253,6 +255,7 @@ MpegParser.prototype.requestRead = function(
/**
* @param {ArrayBuffer} buf Data buffer.
+ * @param {Object} rootParser Parser definition.
* @param {File} file File.
* @param {number} filePos Start position in the file.
* @param {number} size Atom size.
@@ -261,7 +264,7 @@ MpegParser.prototype.requestRead = function(
* @param {function} onSuccess Success callback.
*/
MpegParser.prototype.processTopLevelAtom = function(
- buf, file, filePos, size, name, onError, onSuccess) {
+ buf, rootParser, file, filePos, size, name, onError, onSuccess) {
try {
var br = new ByteReader(buf);
@@ -280,7 +283,7 @@ MpegParser.prototype.processTopLevelAtom = function(
// Process the top level atom.
if (name) { // name is null only the first time.
this.applyParser(
- this.rootParser_[name],
+ rootParser[name],
br,
{start: 0, end: atomEnd, name: name},
filePos
@@ -298,12 +301,13 @@ MpegParser.prototype.processTopLevelAtom = function(
// If we do not have a parser for the next atom, skip the content and
// read only the header (the one after the next).
- if (!this.rootParser_[nextName]) {
+ if (!rootParser[nextName]) {
filePos += nextSize - MpegParser.HEADER_SIZE;
nextSize = MpegParser.HEADER_SIZE;
}
- this.requestRead(file, filePos, nextSize, nextName, onError, onSuccess);
+ this.requestRead(rootParser, file, filePos, nextSize, nextName,
+ onError, onSuccess);
} else {
// The previous read did not return the next atom header, EOF reached.
this.vlog('EOF @' + filePos);
« 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