OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @param {MetadataDispatcher} parent Parent object. | 6 * @param {MetadataDispatcher} parent Parent object. |
7 * @param {string} type Parser type. | 7 * @param {string} type Parser type. |
8 * @param {RegExp} urlFilter RegExp to match URLs. | 8 * @param {RegExp} urlFilter RegExp to match URLs. |
9 * @constructor | 9 * @constructor |
10 */ | 10 */ |
11 function MetadataParser(parent, type, urlFilter) { | 11 function MetadataParser(parent, type, urlFilter) { |
12 this.parent_ = parent; | 12 this.parent_ = parent; |
13 this.type = type; | 13 this.type = type; |
14 this.urlFilter = urlFilter; | 14 this.urlFilter = urlFilter; |
15 this.verbose = parent.verbose; | 15 this.verbose = parent.verbose; |
16 this.mimeType = 'unknown'; | 16 this.mimeType = 'unknown'; |
17 } | 17 } |
18 | 18 |
19 /** | 19 /** |
20 * Output an error message. | 20 * Output an error message. |
21 * @param {Object...} var_args Arguments | 21 * @param {Object...} var_args Arguments. |
22 */ | 22 */ |
23 MetadataParser.prototype.error = function(var_args) { | 23 MetadataParser.prototype.error = function(var_args) { |
24 this.parent_.error.apply(this.parent_, arguments); | 24 this.parent_.error.apply(this.parent_, arguments); |
25 }; | 25 }; |
26 | 26 |
27 /** | 27 /** |
28 * Output a log message. | 28 * Output a log message. |
29 * @param {Object...} var_args Arguments | 29 * @param {Object...} var_args Arguments. |
30 */ | 30 */ |
31 MetadataParser.prototype.log = function(var_args) { | 31 MetadataParser.prototype.log = function(var_args) { |
32 this.parent_.log.apply(this.parent_, arguments); | 32 this.parent_.log.apply(this.parent_, arguments); |
33 }; | 33 }; |
34 | 34 |
35 /** | 35 /** |
36 * Output a log message if |verbose| flag is on. | 36 * Output a log message if |verbose| flag is on. |
37 * @param {Object...} var_args Arguments | 37 * @param {Object...} var_args Arguments. |
38 */ | 38 */ |
39 MetadataParser.prototype.vlog = function(var_args) { | 39 MetadataParser.prototype.vlog = function(var_args) { |
40 if (this.verbose) | 40 if (this.verbose) |
41 this.parent_.log.apply(this.parent_, arguments); | 41 this.parent_.log.apply(this.parent_, arguments); |
42 }; | 42 }; |
43 | 43 |
44 /** | 44 /** |
45 * @return {Object} Metadata object with the minimal set of properties. | 45 * @return {Object} Metadata object with the minimal set of properties. |
46 */ | 46 */ |
47 MetadataParser.prototype.createDefaultMetadata = function() { | 47 MetadataParser.prototype.createDefaultMetadata = function() { |
48 return { | 48 return { |
49 type: this.type, | 49 type: this.type, |
50 mimeType: this.mimeType | 50 mimeType: this.mimeType |
51 }; | 51 }; |
52 }; | 52 }; |
53 | 53 |
54 /* Base class for image metadata parsers */ | 54 /* Base class for image metadata parsers */ |
55 function ImageParser(parent, type, urlFilter) { | 55 function ImageParser(parent, type, urlFilter) { |
56 MetadataParser.apply(this, arguments); | 56 MetadataParser.apply(this, arguments); |
57 this.mimeType = 'image/' + this.type; | 57 this.mimeType = 'image/' + this.type; |
58 } | 58 } |
59 | 59 |
60 ImageParser.prototype = {__proto__: MetadataParser.prototype}; | 60 ImageParser.prototype = {__proto__: MetadataParser.prototype}; |
OLD | NEW |