Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: ui/file_manager/file_manager/background/js/volume_manager.js

Issue 1010163002: Files.app: Fix closure error which will raised by the updated compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define FakeEntry record type and use it. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * Represents each volume, such as "drive", "download directory", each "USB 6 * Represents each volume, such as "drive", "download directory", each "USB
7 * flush storage", or "mounted zip archive" etc. 7 * flush storage", or "mounted zip archive" etc.
8 * 8 *
9 * @constructor 9 * @constructor
10 * @struct 10 * @struct
(...skipping 26 matching lines...) Expand all
37 isReadOnly, 37 isReadOnly,
38 profile, 38 profile,
39 label, 39 label,
40 extensionId, 40 extensionId,
41 hasMedia) { 41 hasMedia) {
42 this.volumeType_ = volumeType; 42 this.volumeType_ = volumeType;
43 this.volumeId_ = volumeId; 43 this.volumeId_ = volumeId;
44 this.fileSystem_ = fileSystem; 44 this.fileSystem_ = fileSystem;
45 this.label_ = label; 45 this.label_ = label;
46 this.displayRoot_ = null; 46 this.displayRoot_ = null;
47
48 /** @type {Object.<string, !FakeEntry>} */
47 this.fakeEntries_ = {}; 49 this.fakeEntries_ = {};
48 50
49 /** @type {Promise.<DirectoryEntry>} */ 51 /** @type {Promise.<!DirectoryEntry>} */
50 this.displayRootPromise_ = null; 52 this.displayRootPromise_ = null;
51 53
52 if (volumeType === VolumeManagerCommon.VolumeType.DRIVE) { 54 if (volumeType === VolumeManagerCommon.VolumeType.DRIVE) {
53 // TODO(mtomasz): Convert fake entries to DirectoryProvider. 55 // TODO(mtomasz): Convert fake entries to DirectoryProvider.
54 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_OFFLINE] = { 56 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_OFFLINE] = {
55 isDirectory: true, 57 isDirectory: true,
56 rootType: VolumeManagerCommon.RootType.DRIVE_OFFLINE, 58 rootType: VolumeManagerCommon.RootType.DRIVE_OFFLINE,
57 toURL: function() { return 'fake-entry://drive_offline'; } 59 toURL: function() { return 'fake-entry://drive_offline'; }
58 }; 60 };
59 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME] = { 61 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME] = {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return this.fileSystem_; 102 return this.fileSystem_;
101 }, 103 },
102 /** 104 /**
103 * @return {DirectoryEntry} Display root path. It is null before finishing to 105 * @return {DirectoryEntry} Display root path. It is null before finishing to
104 * resolve the entry. 106 * resolve the entry.
105 */ 107 */
106 get displayRoot() { 108 get displayRoot() {
107 return this.displayRoot_; 109 return this.displayRoot_;
108 }, 110 },
109 /** 111 /**
110 * @return {Object.<string, Object>} Fake entries. 112 * @return {Object.<string, !FakeEntry>} Fake entries.
111 */ 113 */
112 get fakeEntries() { 114 get fakeEntries() {
113 return this.fakeEntries_; 115 return this.fakeEntries_;
114 }, 116 },
115 /** 117 /**
116 * @return {(string|undefined)} Error identifier. 118 * @return {(string|undefined)} Error identifier.
117 */ 119 */
118 get error() { 120 get error() {
119 return this.error_; 121 return this.error_;
120 }, 122 },
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 */ 161 */
160 get hasMedia() { 162 get hasMedia() {
161 return this.hasMedia_; 163 return this.hasMedia_;
162 } 164 }
163 }; 165 };
164 166
165 /** 167 /**
166 * Starts resolving the display root and obtains it. It may take long time for 168 * Starts resolving the display root and obtains it. It may take long time for
167 * Drive. Once resolved, it is cached. 169 * Drive. Once resolved, it is cached.
168 * 170 *
169 * @param {function(DirectoryEntry)=} opt_onSuccess Success callback with the 171 * @param {function(!DirectoryEntry)=} opt_onSuccess Success callback with the
170 * display root directory as an argument. 172 * display root directory as an argument.
171 * @param {function(*)=} opt_onFailure Failure callback. 173 * @param {function(*)=} opt_onFailure Failure callback.
172 * @return {Promise.<DirectoryEntry>} 174 * @return {Promise.<!DirectoryEntry>}
173 */ 175 */
174 VolumeInfo.prototype.resolveDisplayRoot = function(opt_onSuccess, 176 VolumeInfo.prototype.resolveDisplayRoot = function(opt_onSuccess,
175 opt_onFailure) { 177 opt_onFailure) {
176 if (!this.displayRootPromise_) { 178 if (!this.displayRootPromise_) {
177 // TODO(mtomasz): Do not add VolumeInfo which failed to resolve root, and 179 // TODO(mtomasz): Do not add VolumeInfo which failed to resolve root, and
178 // remove this if logic. Call opt_onSuccess() always, instead. 180 // remove this if logic. Call opt_onSuccess() always, instead.
179 if (this.volumeType !== VolumeManagerCommon.VolumeType.DRIVE) { 181 if (this.volumeType !== VolumeManagerCommon.VolumeType.DRIVE) {
180 if (this.fileSystem_) 182 if (this.fileSystem_)
181 this.displayRootPromise_ = /** @type {Promise.<DirectoryEntry>} */ ( 183 this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ (
182 Promise.resolve(this.fileSystem_.root)); 184 Promise.resolve(this.fileSystem_.root));
183 else 185 else
184 this.displayRootPromise_ = /** @type {Promise.<DirectoryEntry>} */ ( 186 this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ (
185 Promise.reject(this.error)); 187 Promise.reject(this.error));
186 } else { 188 } else {
187 // For Drive, we need to resolve. 189 // For Drive, we need to resolve.
188 var displayRootURL = this.fileSystem_.root.toURL() + '/root'; 190 var displayRootURL = this.fileSystem_.root.toURL() + '/root';
189 this.displayRootPromise_ = new Promise( 191 this.displayRootPromise_ = new Promise(
190 window.webkitResolveLocalFileSystemURL.bind(null, displayRootURL)); 192 window.webkitResolveLocalFileSystemURL.bind(null, displayRootURL));
191 } 193 }
192 194
193 // Store the obtained displayRoot. 195 // Store the obtained displayRoot.
194 this.displayRootPromise_.then(function(displayRoot) { 196 this.displayRootPromise_.then(function(displayRoot) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 VolumeInfoList.prototype.findIndex = function(volumeId) { 412 VolumeInfoList.prototype.findIndex = function(volumeId) {
411 for (var i = 0; i < this.model_.length; i++) { 413 for (var i = 0; i < this.model_.length; i++) {
412 if (this.model_.item(i).volumeId === volumeId) 414 if (this.model_.item(i).volumeId === volumeId)
413 return i; 415 return i;
414 } 416 }
415 return -1; 417 return -1;
416 }; 418 };
417 419
418 /** 420 /**
419 * Searches the information of the volume that contains the passed entry. 421 * Searches the information of the volume that contains the passed entry.
420 * @param {!Entry|!Object} entry Entry on the volume to be found. 422 * @param {!Entry|!FakeEntry} entry Entry on the volume to be found.
421 * @return {VolumeInfo} The volume's information, or null if not found. 423 * @return {VolumeInfo} The volume's information, or null if not found.
422 */ 424 */
423 VolumeInfoList.prototype.findByEntry = function(entry) { 425 VolumeInfoList.prototype.findByEntry = function(entry) {
424 for (var i = 0; i < this.length; i++) { 426 for (var i = 0; i < this.length; i++) {
425 var volumeInfo = this.item(i); 427 var volumeInfo = this.item(i);
426 if (volumeInfo.fileSystem && 428 if (volumeInfo.fileSystem &&
427 util.isSameFileSystem(volumeInfo.fileSystem, entry.filesystem)) { 429 util.isSameFileSystem(volumeInfo.fileSystem, entry.filesystem)) {
428 return volumeInfo; 430 return volumeInfo;
429 } 431 }
430 // Additionally, check fake entries. 432 // Additionally, check fake entries.
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 if (volumeInfo.profile.isCurrentProfile && 816 if (volumeInfo.profile.isCurrentProfile &&
815 volumeInfo.volumeType === volumeType) 817 volumeInfo.volumeType === volumeType)
816 return volumeInfo; 818 return volumeInfo;
817 } 819 }
818 return null; 820 return null;
819 }; 821 };
820 822
821 /** 823 /**
822 * Obtains location information from an entry. 824 * Obtains location information from an entry.
823 * 825 *
824 * @param {(!Entry|!Object)} entry File or directory entry. It can be a fake 826 * @param {(!Entry|!FakeEntry)} entry File or directory entry. It can be a fake
825 * entry. 827 * entry.
826 * @return {EntryLocation} Location information. 828 * @return {EntryLocation} Location information.
827 */ 829 */
828 VolumeManager.prototype.getLocationInfo = function(entry) { 830 VolumeManager.prototype.getLocationInfo = function(entry) {
829 var volumeInfo = this.volumeInfoList.findByEntry(entry); 831 var volumeInfo = this.volumeInfoList.findByEntry(entry);
830 if (!volumeInfo) 832 if (!volumeInfo)
831 return null; 833 return null;
832 834
833 if (util.isFakeEntry(entry)) { 835 if (util.isFakeEntry(entry)) {
834 return new EntryLocation( 836 return new EntryLocation(
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 this.isDriveBased; 1037 this.isDriveBased;
1036 1038
1037 /** 1039 /**
1038 * Whether the entry is read only or not. 1040 * Whether the entry is read only or not.
1039 * @type {boolean} 1041 * @type {boolean}
1040 */ 1042 */
1041 this.isReadOnly = isReadOnly; 1043 this.isReadOnly = isReadOnly;
1042 1044
1043 Object.freeze(this); 1045 Object.freeze(this);
1044 } 1046 }
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/background/js/task_queue.js ('k') | ui/file_manager/file_manager/common/js/externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698