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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_copy_manager.js

Issue 12212187: [Cleanup] Files.app: Misc style fixes in Javascript code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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 if (chrome.extension) { 5 if (chrome.extension) {
6 var getContentWindows = function() { 6 var getContentWindows = function() {
7 return chrome.extension.getViews(); 7 return chrome.extension.getViews();
8 }; 8 };
9 } 9 }
10 10
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 rv.percentage = rv.completedBytes / rv.totalBytes; 284 rv.percentage = rv.completedBytes / rv.totalBytes;
285 if (rv.pendingItems === 1) 285 if (rv.pendingItems === 1)
286 rv.filename = pendingFile.name; 286 rv.filename = pendingFile.name;
287 287
288 return rv; 288 return rv;
289 }; 289 };
290 290
291 /** 291 /**
292 * Send an event to all the FileManager windows. 292 * Send an event to all the FileManager windows.
293 * 293 *
294 * @private
295 * @param {string} eventName Event name. 294 * @param {string} eventName Event name.
296 * @param {Object} eventArgs An object with arbitrary event parameters. 295 * @param {Object} eventArgs An object with arbitrary event parameters.
296 * @private
297 */ 297 */
298 FileCopyManager.prototype.sendEvent_ = function(eventName, eventArgs) { 298 FileCopyManager.prototype.sendEvent_ = function(eventName, eventArgs) {
299 if (this.cancelRequested_) 299 if (this.cancelRequested_)
300 return; // Swallow events until cancellation complete. 300 return; // Swallow events until cancellation complete.
301 301
302 eventArgs.status = this.getStatus(); 302 eventArgs.status = this.getStatus();
303 303
304 var windows = getContentWindows(); 304 var windows = getContentWindows();
305 for (var i = 0; i < windows.length; i++) { 305 for (var i = 0; i < windows.length; i++) {
306 var w = windows[i]; 306 var w = windows[i];
(...skipping 27 matching lines...) Expand all
334 FileCopyManager.prototype.log_ = function() { 334 FileCopyManager.prototype.log_ = function() {
335 var windows = getContentWindows(); 335 var windows = getContentWindows();
336 for (var i = 0; i < windows.length; i++) { 336 for (var i = 0; i < windows.length; i++) {
337 windows[i].console.log.apply(windows[i].console, arguments); 337 windows[i].console.log.apply(windows[i].console, arguments);
338 } 338 }
339 }; 339 };
340 340
341 /** 341 /**
342 * Dispatch a simple copy-progress event with reason and optional err data. 342 * Dispatch a simple copy-progress event with reason and optional err data.
343 * 343 *
344 * @private
345 * @param {string} reason Event type. 344 * @param {string} reason Event type.
346 * @param {FileCopyManager.Error} opt_err Error. 345 * @param {FileCopyManager.Error} opt_err Error.
346 * @private
347 */ 347 */
348 FileCopyManager.prototype.sendProgressEvent_ = function(reason, opt_err) { 348 FileCopyManager.prototype.sendProgressEvent_ = function(reason, opt_err) {
349 var event = {}; 349 var event = {};
350 event.reason = reason; 350 event.reason = reason;
351 if (opt_err) 351 if (opt_err)
352 event.error = opt_err; 352 event.error = opt_err;
353 this.sendEvent_('copy-progress', event); 353 this.sendEvent_('copy-progress', event);
354 }; 354 };
355 355
356 /** 356 /**
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 FileCopyManager.prototype.doCancel_ = function() { 409 FileCopyManager.prototype.doCancel_ = function() {
410 this.resetQueue_(); 410 this.resetQueue_();
411 this.cancelRequested_ = false; 411 this.cancelRequested_ = false;
412 this.sendProgressEvent_('CANCELLED'); 412 this.sendProgressEvent_('CANCELLED');
413 }; 413 };
414 414
415 /** 415 /**
416 * Used internally to check if a cancel has been requested, and handle 416 * Used internally to check if a cancel has been requested, and handle
417 * it if so. 417 * it if so.
418 * 418 *
419 * @return {boolean} If canceled.
419 * @private 420 * @private
420 * @return {boolean} If canceled.
421 */ 421 */
422 FileCopyManager.prototype.maybeCancel_ = function() { 422 FileCopyManager.prototype.maybeCancel_ = function() {
423 if (!this.cancelRequested_) 423 if (!this.cancelRequested_)
424 return false; 424 return false;
425 425
426 this.doCancel_(); 426 this.doCancel_();
427 return true; 427 return true;
428 }; 428 };
429 429
430 /** 430 /**
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 // If the queue size is 1 after pushing our task, it was empty before, 610 // If the queue size is 1 after pushing our task, it was empty before,
611 // so we need to kick off queue processing and dispatch BEGIN event. 611 // so we need to kick off queue processing and dispatch BEGIN event.
612 612
613 this.sendProgressEvent_('BEGIN'); 613 this.sendProgressEvent_('BEGIN');
614 this.serviceNextTask_(onTaskSuccess, onTaskError); 614 this.serviceNextTask_(onTaskSuccess, onTaskError);
615 }; 615 };
616 616
617 /** 617 /**
618 * Service all entries in the next copy task. 618 * Service all entries in the next copy task.
619 * 619 *
620 * @private
621 * @param {Function} successCallback On success. 620 * @param {Function} successCallback On success.
622 * @param {Function} errorCallback On error. 621 * @param {Function} errorCallback On error.
622 * @private
623 */ 623 */
624 FileCopyManager.prototype.serviceNextTask_ = function( 624 FileCopyManager.prototype.serviceNextTask_ = function(
625 successCallback, errorCallback) { 625 successCallback, errorCallback) {
626 var self = this; 626 var self = this;
627 var task = this.copyTasks_[0]; 627 var task = this.copyTasks_[0];
628 628
629 var onFilesystemError = function(err) { 629 var onFilesystemError = function(err) {
630 errorCallback(new FileCopyManager.Error('FILESYSTEM_ERROR', err)); 630 errorCallback(new FileCopyManager.Error('FILESYSTEM_ERROR', err));
631 }; 631 };
632 632
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 if (!task.zip) 677 if (!task.zip)
678 this.serviceNextTaskEntry_(task, onEntryServiced, errorCallback); 678 this.serviceNextTaskEntry_(task, onEntryServiced, errorCallback);
679 else 679 else
680 this.serviceZipTask_(task, onTaskComplete, errorCallback); 680 this.serviceZipTask_(task, onTaskComplete, errorCallback);
681 }; 681 };
682 682
683 /** 683 /**
684 * Service the next entry in a given task. 684 * Service the next entry in a given task.
685 * TODO(olege): Refactor this method into a separate class. 685 * TODO(olege): Refactor this method into a separate class.
686 * 686 *
687 * @private
688 * @param {FileManager.Task} task A task. 687 * @param {FileManager.Task} task A task.
689 * @param {Function} successCallback On success. 688 * @param {Function} successCallback On success.
690 * @param {Function} errorCallback On error. 689 * @param {Function} errorCallback On error.
690 * @private
691 */ 691 */
692 FileCopyManager.prototype.serviceNextTaskEntry_ = function( 692 FileCopyManager.prototype.serviceNextTaskEntry_ = function(
693 task, successCallback, errorCallback) { 693 task, successCallback, errorCallback) {
694 if (this.maybeCancel_()) 694 if (this.maybeCancel_())
695 return; 695 return;
696 696
697 var self = this; 697 var self = this;
698 var sourceEntry = task.getNextEntry(); 698 var sourceEntry = task.getNextEntry();
699 699
700 if (!sourceEntry) { 700 if (!sourceEntry) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 */ 1277 */
1278 FileCopyManager.prototype.sendDeleteEvent_ = function(task, reason) { 1278 FileCopyManager.prototype.sendDeleteEvent_ = function(task, reason) {
1279 this.sendEvent_('delete', { 1279 this.sendEvent_('delete', {
1280 reason: reason, 1280 reason: reason,
1281 id: task.id, 1281 id: task.id,
1282 urls: task.entries.map(function(e) { 1282 urls: task.entries.map(function(e) {
1283 return util.makeFilesystemUrl(e.fullPath); 1283 return util.makeFilesystemUrl(e.fullPath);
1284 }) 1284 })
1285 }); 1285 });
1286 }; 1286 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698