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 * Namespace for utility functions. | 6 * Namespace for utility functions. |
7 */ | 7 */ |
8 var util = {}; | 8 var util = {}; |
9 | 9 |
10 /** | 10 /** |
(...skipping 30 matching lines...) Expand all Loading... |
41 * Install a sensible toString() on the FileError object. | 41 * Install a sensible toString() on the FileError object. |
42 * | 42 * |
43 * FileError.prototype.code is a numeric code describing the cause of the | 43 * FileError.prototype.code is a numeric code describing the cause of the |
44 * error. The FileError constructor has a named property for each possible | 44 * error. The FileError constructor has a named property for each possible |
45 * error code, but provides no way to map the code to the named property. | 45 * error code, but provides no way to map the code to the named property. |
46 * This toString() implementation fixes that. | 46 * This toString() implementation fixes that. |
47 */ | 47 */ |
48 util.installFileErrorToString = function() { | 48 util.installFileErrorToString = function() { |
49 FileError.prototype.toString = function() { | 49 FileError.prototype.toString = function() { |
50 return '[object FileError: ' + util.getFileErrorMnemonic(this.code) + ']'; | 50 return '[object FileError: ' + util.getFileErrorMnemonic(this.code) + ']'; |
51 } | 51 }; |
52 }; | 52 }; |
53 | 53 |
54 /** | 54 /** |
55 * @param {number} code The file error code. | 55 * @param {number} code The file error code. |
56 * @return {string} The file error mnemonic. | 56 * @return {string} The file error mnemonic. |
57 */ | 57 */ |
58 util.getFileErrorMnemonic = function(code) { | 58 util.getFileErrorMnemonic = function(code) { |
59 for (var key in FileError) { | 59 for (var key in FileError) { |
60 if (key.search(/_ERR$/) != -1 && FileError[key] == code) | 60 if (key.search(/_ERR$/) != -1 && FileError[key] == code) |
61 return key; | 61 return key; |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 * overriden). | 1251 * overriden). |
1252 * @param {Object} object The object. | 1252 * @param {Object} object The object. |
1253 * @param {string} propertyName The property name. | 1253 * @param {string} propertyName The property name. |
1254 * @param {*} value Value to set. | 1254 * @param {*} value Value to set. |
1255 */ | 1255 */ |
1256 util.callInheritedSetter = function(object, propertyName, value) { | 1256 util.callInheritedSetter = function(object, propertyName, value) { |
1257 var d = util.findPropertyDescriptor(Object.getPrototypeOf(object), | 1257 var d = util.findPropertyDescriptor(Object.getPrototypeOf(object), |
1258 propertyName); | 1258 propertyName); |
1259 d.set.call(object, value); | 1259 d.set.call(object, value); |
1260 }; | 1260 }; |
OLD | NEW |