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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js

Issue 2292873003: Divide volume_manager.js into files for each classes and extract interfaces from them. (Closed)
Patch Set: Address comments. Created 4 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 * Thin wrapper for VolumeManager. This should be an interface proxy to talk 6 * Thin wrapper for VolumeManager. This should be an interface proxy to talk
7 * to VolumeManager. This class also filters Drive related data/events if 7 * to VolumeManager. This class also filters Drive related data/events if
8 * driveEnabled is set to false. 8 * driveEnabled is set to false.
9 * 9 *
10 * @constructor 10 * @constructor
(...skipping 30 matching lines...) Expand all
41 queue.run(function(callNextStep) { 41 queue.run(function(callNextStep) {
42 chrome.runtime.getBackgroundPage(/** @type {function(Window=)} */( 42 chrome.runtime.getBackgroundPage(/** @type {function(Window=)} */(
43 function(opt_backgroundPage) { 43 function(opt_backgroundPage) {
44 this.backgroundPage_ = opt_backgroundPage; 44 this.backgroundPage_ = opt_backgroundPage;
45 callNextStep(); 45 callNextStep();
46 }.bind(this))); 46 }.bind(this)));
47 }.bind(this)); 47 }.bind(this));
48 } 48 }
49 49
50 queue.run(function(callNextStep) { 50 queue.run(function(callNextStep) {
51 this.backgroundPage_.VolumeManager.getInstance(function(volumeManager) { 51 this.backgroundPage_.volumeManagerFactory.getInstance(
52 this.onReady_(volumeManager); 52 function(volumeManager) {
53 callNextStep(); 53 this.onReady_(volumeManager);
54 }.bind(this)); 54 callNextStep();
55 }.bind(this));
55 }.bind(this)); 56 }.bind(this));
56 } 57 }
57 58
58 /** 59 /**
59 * Extends cr.EventTarget. 60 * Extends cr.EventTarget.
60 */ 61 */
61 VolumeManagerWrapper.prototype.__proto__ = cr.EventTarget.prototype; 62 VolumeManagerWrapper.prototype.__proto__ = cr.EventTarget.prototype;
62 63
63 /** 64 /**
64 * @param {VolumeManagerCommon.VolumeType} volumeType 65 * @param {VolumeManagerCommon.VolumeType} volumeType
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 * @param {!Event} event Event object sent from VolumeManager. 153 * @param {!Event} event Event object sent from VolumeManager.
153 * @private 154 * @private
154 */ 155 */
155 VolumeManagerWrapper.prototype.onEvent_ = function(event) { 156 VolumeManagerWrapper.prototype.onEvent_ = function(event) {
156 var eventVolumeType; 157 var eventVolumeType;
157 switch (event.type) { 158 switch (event.type) {
158 case 'drive-connection-changed': 159 case 'drive-connection-changed':
159 eventVolumeType = VolumeManagerCommon.VolumeType.DRIVE; 160 eventVolumeType = VolumeManagerCommon.VolumeType.DRIVE;
160 break; 161 break;
161 case 'externally-unmounted': 162 case 'externally-unmounted':
163 event = /** @type {!ExternallyUnmountedEvent} */ (event);
162 eventVolumeType = event.volumeInfo.volumeType; 164 eventVolumeType = event.volumeInfo.volumeType;
163 break; 165 break;
164 } 166 }
165 167
166 if (this.isAllowedVolume_(eventVolumeType)) 168 if (eventVolumeType && this.isAllowedVolume_(eventVolumeType))
167 this.dispatchEvent(event); 169 this.dispatchEvent(event);
168 }; 170 };
169 171
170 /** 172 /**
171 * Called on events of modifying VolumeInfoList. 173 * Called on events of modifying VolumeInfoList.
172 * @param {Event} event Event object sent from VolumeInfoList. 174 * @param {Event} event Event object sent from VolumeInfoList.
173 * @private 175 * @private
174 */ 176 */
175 VolumeManagerWrapper.prototype.onVolumeInfoListUpdated_ = function(event) { 177 VolumeManagerWrapper.prototype.onVolumeInfoListUpdated_ = function(event) {
176 if (this.allowedPaths_ === AllowedPaths.ANY_PATH) { 178 if (this.allowedPaths_ === AllowedPaths.ANY_PATH) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 }; 372 };
371 373
372 /** 374 /**
373 * Returns current state of VolumeManagerWrapper. 375 * Returns current state of VolumeManagerWrapper.
374 * @return {string} Current state of VolumeManagerWrapper. 376 * @return {string} Current state of VolumeManagerWrapper.
375 */ 377 */
376 VolumeManagerWrapper.prototype.toString = function() { 378 VolumeManagerWrapper.prototype.toString = function() {
377 var initialized = this.isInitialized(); 379 var initialized = this.isInitialized();
378 var volumeManager = initialized ? 380 var volumeManager = initialized ?
379 this.volumeManager_ : 381 this.volumeManager_ :
380 this.backgroundPage_.VolumeManager.getInstanceForDebug(); 382 this.backgroundPage_.volumeManagerFactory.getInstanceForDebug();
381 383
382 var str = 'VolumeManagerWrapper\n' + 384 var str = 'VolumeManagerWrapper\n' +
383 '- Initialized: ' + initialized + '\n'; 385 '- Initialized: ' + initialized + '\n';
384 386
385 if (!initialized) 387 if (!initialized)
386 str += '- PendingTasksCount: ' + this.pendingTasks_.length + '\n'; 388 str += '- PendingTasksCount: ' + this.pendingTasks_.length + '\n';
387 389
388 return str + '- VolumeManager:\n' + 390 return str + '- VolumeManager:\n' +
389 ' ' + volumeManager.toString().replace(/\n/g, '\n '); 391 ' ' + volumeManager.toString().replace(/\n/g, '\n ');
390 }; 392 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698