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 /** | 5 /** |
6 * Object representing an image item (a photo). | 6 * Object representing an image item (a photo). |
7 * | 7 * |
8 * @param {!FileEntry} entry Image entry. | 8 * @param {!FileEntry} entry Image entry. |
9 * @param {!EntryLocation} locationInfo Entry location information. | 9 * @param {!EntryLocation} locationInfo Entry location information. |
10 * @param {!Object} metadata Metadata for the entry. | 10 * @param {!Object} metadata Metadata for the entry. |
11 * @param {!MetadataCache} metadataCache Metadata cache instance. | 11 * @param {!MetadataCache} metadataCache Metadata cache instance. |
| 12 * @param {!FileSystemMetadata} fileSystemMetadata File system metadata. |
12 * @param {boolean} original Whether the entry is original or edited. | 13 * @param {boolean} original Whether the entry is original or edited. |
13 * @constructor | 14 * @constructor |
14 * @struct | 15 * @struct |
15 */ | 16 */ |
16 Gallery.Item = function( | 17 Gallery.Item = function( |
17 entry, locationInfo, metadata, metadataCache, original) { | 18 entry, locationInfo, metadata, metadataCache, fileSystemMetadata, |
| 19 original) { |
18 /** | 20 /** |
19 * @type {!FileEntry} | 21 * @type {!FileEntry} |
20 * @private | 22 * @private |
21 */ | 23 */ |
22 this.entry_ = entry; | 24 this.entry_ = entry; |
23 | 25 |
24 /** | 26 /** |
25 * @type {!EntryLocation} | 27 * @type {!EntryLocation} |
26 * @private | 28 * @private |
27 */ | 29 */ |
28 this.locationInfo_ = locationInfo; | 30 this.locationInfo_ = locationInfo; |
29 | 31 |
30 /** | 32 /** |
31 * @type {!Object} | 33 * @type {!Object} |
32 * @private | 34 * @private |
33 */ | 35 */ |
34 this.metadata_ = Object.preventExtensions(metadata); | 36 this.metadata_ = Object.preventExtensions(metadata); |
35 | 37 |
36 /** | 38 /** |
37 * @type {!MetadataCache} | 39 * @type {!MetadataCache} |
38 * @private | 40 * @private |
39 * @const | 41 * @const |
40 */ | 42 */ |
41 this.metadataCache_ = metadataCache; | 43 this.metadataCache_ = metadataCache; |
42 | 44 |
| 45 /** |
| 46 * @type {!FileSystemMetadata} |
| 47 * @private |
| 48 * @const |
| 49 */ |
| 50 this.fileSystemMetadata_ = fileSystemMetadata; |
| 51 |
43 // TODO(yawano): Change this.contentImage and this.screenImage to private | 52 // TODO(yawano): Change this.contentImage and this.screenImage to private |
44 // fields and provide utility methods for them (e.g. revokeFullImageCache). | 53 // fields and provide utility methods for them (e.g. revokeFullImageCache). |
45 /** | 54 /** |
46 * The content cache is used for prefetching the next image when going through | 55 * The content cache is used for prefetching the next image when going through |
47 * the images sequentially. The real life photos can be large (18Mpix = 72Mb | 56 * the images sequentially. The real life photos can be large (18Mpix = 72Mb |
48 * pixel array) so we want only the minimum amount of caching. | 57 * pixel array) so we want only the minimum amount of caching. |
49 * @type {(HTMLCanvasElement|HTMLImageElement)} | 58 * @type {(HTMLCanvasElement|HTMLImageElement)} |
50 */ | 59 */ |
51 this.contentImage = null; | 60 this.contentImage = null; |
52 | 61 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 function(metadataList) { | 264 function(metadataList) { |
256 if (metadataList.length === 1) { | 265 if (metadataList.length === 1) { |
257 this.metadata_ = metadataList[0]; | 266 this.metadata_ = metadataList[0]; |
258 if (opt_callback) | 267 if (opt_callback) |
259 opt_callback(true); | 268 opt_callback(true); |
260 } else { | 269 } else { |
261 if (opt_callback) | 270 if (opt_callback) |
262 opt_callback(false); | 271 opt_callback(false); |
263 } | 272 } |
264 }.bind(this)); | 273 }.bind(this)); |
| 274 this.fileSystemMetadata_.notifyEntriesChanged([this.entry_]); |
265 }.bind(this); | 275 }.bind(this); |
266 | 276 |
267 var onError = function(error) { | 277 var onError = function(error) { |
268 console.error('Error saving from gallery', name, error); | 278 console.error('Error saving from gallery', name, error); |
269 ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('SaveResult'), 0, 2); | 279 ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('SaveResult'), 0, 2); |
270 if (opt_callback) | 280 if (opt_callback) |
271 opt_callback(false); | 281 opt_callback(false); |
272 }; | 282 }; |
273 | 283 |
274 var doSave = function(newFile, fileEntry) { | 284 var doSave = function(newFile, fileEntry) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 return Promise.reject(str('GALLERY_FILE_EXISTS')); | 372 return Promise.reject(str('GALLERY_FILE_EXISTS')); |
363 }, function() { | 373 }, function() { |
364 return new Promise( | 374 return new Promise( |
365 this.entry_.moveTo.bind(this.entry_, parentDirectory, newFileName)); | 375 this.entry_.moveTo.bind(this.entry_, parentDirectory, newFileName)); |
366 }.bind(this)); | 376 }.bind(this)); |
367 }.bind(this)); | 377 }.bind(this)); |
368 }.bind(this)).then(function(entry) { | 378 }.bind(this)).then(function(entry) { |
369 this.entry_ = entry; | 379 this.entry_ = entry; |
370 }.bind(this)); | 380 }.bind(this)); |
371 }; | 381 }; |
OLD | NEW |