Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Data model for gallery. | 6 * Data model for gallery. |
| 7 * | 7 * |
| 8 * @param {!MetadataCache} metadataCache Metadata cache. | 8 * @param {!MetadataCache} metadataCache Metadata cache. |
| 9 * @param {!FileSystemMetadata} fileSystemMetadata | |
| 9 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. | 10 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. |
| 10 * @constructor | 11 * @constructor |
| 11 * @extends {cr.ui.ArrayDataModel} | 12 * @extends {cr.ui.ArrayDataModel} |
| 12 */ | 13 */ |
| 13 function GalleryDataModel(metadataCache, opt_watcher) { | 14 function GalleryDataModel(metadataCache, fileSystemMetadata, opt_watcher) { |
| 14 cr.ui.ArrayDataModel.call(this, []); | 15 cr.ui.ArrayDataModel.call(this, []); |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * Metadata cache. | 18 * Metadata cache. |
| 18 * @type {!MetadataCache} | 19 * @type {!MetadataCache} |
| 19 * @private | 20 * @private |
| 20 */ | 21 */ |
| 21 this.metadataCache_ = metadataCache; | 22 this.metadataCache_ = metadataCache; |
| 22 | 23 |
| 23 /** | 24 /** |
| 25 * File system metadata. | |
| 26 * @type {!FileSystemMetadata} | |
|
yawano
2015/02/25 06:39:54
very small nit: This can be const?
hirono
2015/02/25 06:45:22
Yes! Thanks!
| |
| 27 * @private | |
| 28 */ | |
| 29 this.fileSystemMetadata_ = fileSystemMetadata; | |
| 30 | |
| 31 /** | |
| 24 * Directory where the image is saved if the image is located in a read-only | 32 * Directory where the image is saved if the image is located in a read-only |
| 25 * volume. | 33 * volume. |
| 26 * @type {DirectoryEntry} | 34 * @type {DirectoryEntry} |
| 27 */ | 35 */ |
| 28 this.fallbackSaveDirectory = null; | 36 this.fallbackSaveDirectory = null; |
| 29 | 37 |
| 30 // Start to watch file system entries. | 38 // Start to watch file system entries. |
| 31 var watcher = opt_watcher ? opt_watcher : new EntryListWatcher(this); | 39 var watcher = opt_watcher ? opt_watcher : new EntryListWatcher(this); |
| 32 watcher.getEntry = function(item) { return item.getEntry(); }; | 40 watcher.getEntry = function(item) { return item.getEntry(); }; |
| 33 } | 41 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 this.dispatchEvent(event); | 95 this.dispatchEvent(event); |
| 88 | 96 |
| 89 if (!util.isSameEntry(oldEntry, item.getEntry())) { | 97 if (!util.isSameEntry(oldEntry, item.getEntry())) { |
| 90 // New entry is added and the item now tracks it. | 98 // New entry is added and the item now tracks it. |
| 91 // Add another item for the old entry. | 99 // Add another item for the old entry. |
| 92 var anotherItem = new Gallery.Item( | 100 var anotherItem = new Gallery.Item( |
| 93 oldEntry, | 101 oldEntry, |
| 94 oldLocationInfo, | 102 oldLocationInfo, |
| 95 oldMetadata, | 103 oldMetadata, |
| 96 this.metadataCache_, | 104 this.metadataCache_, |
| 105 this.fileSystemMetadata_, | |
| 97 item.isOriginal()); | 106 item.isOriginal()); |
| 98 // The item must be added behind the existing item so that it does | 107 // The item must be added behind the existing item so that it does |
| 99 // not change the index of the existing item. | 108 // not change the index of the existing item. |
| 100 // TODO(hirono): Update the item index of the selection model | 109 // TODO(hirono): Update the item index of the selection model |
| 101 // correctly. | 110 // correctly. |
| 102 this.splice(this.indexOf(item) + 1, 0, anotherItem); | 111 this.splice(this.indexOf(item) + 1, 0, anotherItem); |
| 103 } | 112 } |
| 104 | 113 |
| 105 fulfill(); | 114 fulfill(); |
| 106 }.bind(this)); | 115 }.bind(this)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } else { | 148 } else { |
| 140 // Force to free the buffer of the canvas by assigning zero size. | 149 // Force to free the buffer of the canvas by assigning zero size. |
| 141 sorted[i].screenImage.width = 0; | 150 sorted[i].screenImage.width = 0; |
| 142 sorted[i].screenImage.height = 0; | 151 sorted[i].screenImage.height = 0; |
| 143 sorted[i].screenImage = null; | 152 sorted[i].screenImage = null; |
| 144 } | 153 } |
| 145 } | 154 } |
| 146 } | 155 } |
| 147 } | 156 } |
| 148 }; | 157 }; |
| OLD | NEW |