| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Object representing an image item (a photo). | 8 * Object representing an image item (a photo). |
| 9 * | 9 * |
| 10 * @param {FileEntry} entry Image entry. | 10 * @param {FileEntry} entry Image entry. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 * recently loaded image looks instant even if the image is not in the content | 53 * recently loaded image looks instant even if the image is not in the content |
| 54 * cache any more. Screen-scale images are small (~1Mpix) so we can afford to | 54 * cache any more. Screen-scale images are small (~1Mpix) so we can afford to |
| 55 * cache more of them. | 55 * cache more of them. |
| 56 * @type {Canvas} | 56 * @type {Canvas} |
| 57 */ | 57 */ |
| 58 this.contentImage = null; | 58 this.contentImage = null; |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Last accessed date to be used for selecting items whose cache are evicted. | 61 * Last accessed date to be used for selecting items whose cache are evicted. |
| 62 * @type {number} | 62 * @type {number} |
| 63 * @private |
| 63 */ | 64 */ |
| 64 this.lastAccessed_ = Date.now(); | 65 this.lastAccessed_ = Date.now(); |
| 65 | 66 |
| 66 /** | 67 /** |
| 67 * @type {boolean} | 68 * @type {boolean} |
| 68 * @private | 69 * @private |
| 69 */ | 70 */ |
| 70 this.original_ = original; | 71 this.original_ = original; |
| 71 | 72 |
| 72 Object.seal(this); | 73 Object.seal(this); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 223 |
| 223 tryNext(10); | 224 tryNext(10); |
| 224 }; | 225 }; |
| 225 | 226 |
| 226 /** | 227 /** |
| 227 * Writes the new item content to either the existing or a new file. | 228 * Writes the new item content to either the existing or a new file. |
| 228 * | 229 * |
| 229 * @param {VolumeManager} volumeManager Volume manager instance. | 230 * @param {VolumeManager} volumeManager Volume manager instance. |
| 230 * @param {string} fallbackDir Fallback directory in case the current directory | 231 * @param {string} fallbackDir Fallback directory in case the current directory |
| 231 * is read only. | 232 * is read only. |
| 233 * @param {boolean} overwrite Whether to overwrite the image to the item or not. |
| 232 * @param {HTMLCanvasElement} canvas Source canvas. | 234 * @param {HTMLCanvasElement} canvas Source canvas. |
| 233 * @param {ImageEncoder.MetadataEncoder} metadataEncoder MetadataEncoder. | 235 * @param {ImageEncoder.MetadataEncoder} metadataEncoder MetadataEncoder. |
| 234 * @param {function(boolean)=} opt_callback Callback accepting true for success. | 236 * @param {function(boolean)=} opt_callback Callback accepting true for success. |
| 235 */ | 237 */ |
| 236 Gallery.Item.prototype.saveToFile = function( | 238 Gallery.Item.prototype.saveToFile = function( |
| 237 volumeManager, fallbackDir, overwrite, canvas, metadataEncoder, | 239 volumeManager, fallbackDir, overwrite, canvas, metadataEncoder, |
| 238 opt_callback) { | 240 opt_callback) { |
| 239 ImageUtil.metrics.startInterval(ImageUtil.getMetricName('SaveTime')); | 241 ImageUtil.metrics.startInterval(ImageUtil.getMetricName('SaveTime')); |
| 240 | 242 |
| 241 var name = this.getFileName(); | 243 var name = this.getFileName(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 return Promise.reject(str('GALLERY_FILE_EXISTS')); | 349 return Promise.reject(str('GALLERY_FILE_EXISTS')); |
| 348 }, function() { | 350 }, function() { |
| 349 return new Promise( | 351 return new Promise( |
| 350 this.entry_.moveTo.bind(this.entry_, parentDirectory, newFileName)); | 352 this.entry_.moveTo.bind(this.entry_, parentDirectory, newFileName)); |
| 351 }.bind(this)); | 353 }.bind(this)); |
| 352 }.bind(this)); | 354 }.bind(this)); |
| 353 }.bind(this)).then(function(entry) { | 355 }.bind(this)).then(function(entry) { |
| 354 this.entry_ = entry; | 356 this.entry_ = entry; |
| 355 }.bind(this)); | 357 }.bind(this)); |
| 356 }; | 358 }; |
| OLD | NEW |