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

Side by Side Diff: chrome/browser/resources/file_manager/js/metadata/function_sequence.js

Issue 12212185: [Cleanup] Files.app: Fill 'TODO' comments to missing descriptions in @param annotation. (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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @class FunctionSequence to invoke steps in sequence 7 * @class FunctionSequence to invoke steps in sequence
8 * 8 *
9 * @param {string} name //TODO(JSDOC).
9 * @param {Array} steps array of functions to invoke in sequence. 10 * @param {Array} steps array of functions to invoke in sequence.
10 * @param {Object} logger logger. 11 * @param {Object} logger logger.
11 * @param {Function} callback callback to invoke on success. 12 * @param {Function} callback callback to invoke on success.
12 * @param {Function} failureCallback callback to invoke on failure. 13 * @param {Function} failureCallback callback to invoke on failure.
13 */ 14 */
14 function FunctionSequence(name, steps, logger, callback, failureCallback) { 15 function FunctionSequence(name, steps, logger, callback, failureCallback) {
15 // Private variables hidden in closure 16 // Private variables hidden in closure
16 this.currentStepIdx_ = -1; 17 this.currentStepIdx_ = -1;
17 this.failed_ = false; 18 this.failed_ = false;
18 this.steps_ = steps; 19 this.steps_ = steps;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 this.callback_(); 76 this.callback_();
76 } 77 }
77 }; 78 };
78 79
79 /** 80 /**
80 * Advances to next step. 81 * Advances to next step.
81 * This method should not be used externally. In external 82 * This method should not be used externally. In external
82 * cases should be used nextStep function, which is defined in closure and thus 83 * cases should be used nextStep function, which is defined in closure and thus
83 * has access to internal variables of functionsequence. 84 * has access to internal variables of functionsequence.
84 * @private 85 * @private
86 * @param {...} var_args //TODO(JSDOC).
85 */ 87 */
86 FunctionSequence.prototype.nextStep_ = function(var_args) { 88 FunctionSequence.prototype.nextStep_ = function(var_args) {
87 if (this.failed_) { 89 if (this.failed_) {
88 return; 90 return;
89 } 91 }
90 92
91 if (++this.currentStepIdx_ >= this.steps_.length) { 93 if (++this.currentStepIdx_ >= this.steps_.length) {
92 this.logger.vlog('Sequence ended'); 94 this.logger.vlog('Sequence ended');
93 this.callback_.apply(this, arguments); 95 this.callback_.apply(this, arguments);
94 } else { 96 } else {
95 this.logger.vlog('Attempting to start step [' + 97 this.logger.vlog('Attempting to start step [' +
96 this.steps_[this.currentStepIdx_].name + 98 this.steps_[this.currentStepIdx_].name +
97 ']'); 99 ']');
98 try { 100 try {
99 this.steps_[this.currentStepIdx_].apply(this, arguments); 101 this.steps_[this.currentStepIdx_].apply(this, arguments);
100 } catch (e) { 102 } catch (e) {
101 this.onError(e.toString()); 103 this.onError(e.toString());
102 } 104 }
103 } 105 }
104 }; 106 };
105 107
106 /** 108 /**
107 * This function should be called only once on start, so start sequence pipeline 109 * This function should be called only once on start, so start sequence pipeline
110 * @param {...} var_args //TODO(JSDOC).
108 */ 111 */
109 FunctionSequence.prototype.start = function(var_args) { 112 FunctionSequence.prototype.start = function(var_args) {
110 if (this.started) { 113 if (this.started) {
111 throw new Error('"Start" method of FunctionSequence was called twice'); 114 throw new Error('"Start" method of FunctionSequence was called twice');
112 } 115 }
113 116
114 this.logger.log('Starting sequence with ' + arguments.length + ' arguments'); 117 this.logger.log('Starting sequence with ' + arguments.length + ' arguments');
115 118
116 this.started = true; 119 this.started = true;
117 this.nextStep.apply(this, arguments); 120 this.nextStep.apply(this, arguments);
118 }; 121 };
119 122
120 /** 123 /**
121 * Add Function object mimics to FunctionSequence 124 * Add Function object mimics to FunctionSequence
122 * @private 125 * @private
126 * @param {*} obj //TODO(JSDOC).
127 * @param {Array.*} args /TODO(JSDOC).
123 */ 128 */
124 FunctionSequence.prototype.apply_ = function(obj, args) { 129 FunctionSequence.prototype.apply_ = function(obj, args) {
125 this.start.apply(this, args); 130 this.start.apply(this, args);
126 }; 131 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698