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 {!MetadataModel} metadataModel | 8 * @param {!MetadataModel} metadataModel |
9 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. | 9 * @param {!EntryListWatcher=} opt_watcher Entry list watcher. |
10 * @constructor | 10 * @constructor |
(...skipping 12 matching lines...) Expand all Loading... |
23 /** | 23 /** |
24 * Directory where the image is saved if the image is located in a read-only | 24 * Directory where the image is saved if the image is located in a read-only |
25 * volume. | 25 * volume. |
26 * @public {DirectoryEntry} | 26 * @public {DirectoryEntry} |
27 */ | 27 */ |
28 this.fallbackSaveDirectory = null; | 28 this.fallbackSaveDirectory = null; |
29 | 29 |
30 // Start to watch file system entries. | 30 // Start to watch file system entries. |
31 var watcher = opt_watcher ? opt_watcher : new EntryListWatcher(this); | 31 var watcher = opt_watcher ? opt_watcher : new EntryListWatcher(this); |
32 watcher.getEntry = function(item) { return item.getEntry(); }; | 32 watcher.getEntry = function(item) { return item.getEntry(); }; |
| 33 |
| 34 this.addEventListener('splice', this.onSplice_.bind(this)); |
33 } | 35 } |
34 | 36 |
35 /** | 37 /** |
36 * Maximum number of full size image cache. | 38 * Maximum number of full size image cache. |
37 * @type {number} | 39 * @type {number} |
38 * @const | 40 * @const |
39 * @private | 41 * @private |
40 */ | 42 */ |
41 GalleryDataModel.MAX_FULL_IMAGE_CACHE_ = 3; | 43 GalleryDataModel.MAX_FULL_IMAGE_CACHE_ = 3; |
42 | 44 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } else { | 147 } else { |
146 // Force to free the buffer of the canvas by assigning zero size. | 148 // Force to free the buffer of the canvas by assigning zero size. |
147 sorted[i].screenImage.width = 0; | 149 sorted[i].screenImage.width = 0; |
148 sorted[i].screenImage.height = 0; | 150 sorted[i].screenImage.height = 0; |
149 sorted[i].screenImage = null; | 151 sorted[i].screenImage = null; |
150 } | 152 } |
151 } | 153 } |
152 } | 154 } |
153 } | 155 } |
154 }; | 156 }; |
| 157 |
| 158 /** |
| 159 * Handles entry delete. |
| 160 * @param {!Event} event |
| 161 * @private |
| 162 */ |
| 163 GalleryDataModel.prototype.onSplice_ = function(event) { |
| 164 if (!event.removed || !event.removed.length) |
| 165 return; |
| 166 var removedURLs = event.removed.map(function(item) { |
| 167 return item.getEntry().toURL(); |
| 168 }); |
| 169 this.metadataModel_.notifyEntriesRemoved(removedURLs); |
| 170 }; |
OLD | NEW |