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

Side by Side Diff: chrome/browser/resources/hotword/state_manager.js

Issue 620913003: Add messages on assertions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/resources/hotword/nacl_manager.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 cr.define('hotword', function() { 5 cr.define('hotword', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Class to manage hotwording state. Starts/stops the hotword detector based 9 * Class to manage hotwording state. Starts/stops the hotword detector based
10 * on user settings, session requests, and any other factors that play into 10 * on user settings, session requests, and any other factors that play into
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 this.startRecognizer_(); 168 this.startRecognizer_();
169 } 169 }
170 }, 170 },
171 171
172 /** 172 /**
173 * Start the recognizer plugin. Assumes the plugin has been loaded and is 173 * Start the recognizer plugin. Assumes the plugin has been loaded and is
174 * ready to start. 174 * ready to start.
175 * @private 175 * @private
176 */ 176 */
177 startRecognizer_: function() { 177 startRecognizer_: function() {
178 assert(this.pluginManager_); 178 assert(this.pluginManager_, 'No NaCl plugin loaded');
179 if (this.state_ != State_.RUNNING) { 179 if (this.state_ != State_.RUNNING) {
180 this.state_ = State_.RUNNING; 180 this.state_ = State_.RUNNING;
181 this.pluginManager_.startRecognizer(); 181 this.pluginManager_.startRecognizer();
182 } 182 }
183 if (this.sessionStartedCb_) { 183 if (this.sessionStartedCb_) {
184 this.sessionStartedCb_(); 184 this.sessionStartedCb_();
185 this.sessionStartedCb_ = null; 185 this.sessionStartedCb_ = null;
186 } 186 }
187 }, 187 },
188 188
(...skipping 18 matching lines...) Expand all
207 }, 207 },
208 208
209 /** 209 /**
210 * Handle the hotword plugin being ready to start. 210 * Handle the hotword plugin being ready to start.
211 * @private 211 * @private
212 */ 212 */
213 onReady_: function() { 213 onReady_: function() {
214 if (this.state_ != State_.STARTING) { 214 if (this.state_ != State_.STARTING) {
215 // At this point, we should not be in the RUNNING state. Doing so would 215 // At this point, we should not be in the RUNNING state. Doing so would
216 // imply the hotword detector was started without being ready. 216 // imply the hotword detector was started without being ready.
217 assert(this.state_ != State_.RUNNING); 217 assert(this.state_ != State_.RUNNING, 'Unexpected RUNNING state');
218 this.shutdownPluginManager_(); 218 this.shutdownPluginManager_();
219 return; 219 return;
220 } 220 }
221 this.startRecognizer_(); 221 this.startRecognizer_();
222 }, 222 },
223 223
224 /** 224 /**
225 * Handle an error from the hotword plugin. 225 * Handle an error from the hotword plugin.
226 * @private 226 * @private
227 */ 227 */
228 onError_: function() { 228 onError_: function() {
229 this.state_ = State_.ERROR; 229 this.state_ = State_.ERROR;
230 this.shutdownPluginManager_(); 230 this.shutdownPluginManager_();
231 }, 231 },
232 232
233 /** 233 /**
234 * Handle hotword triggering. 234 * Handle hotword triggering.
235 * @private 235 * @private
236 */ 236 */
237 onTrigger_: function() { 237 onTrigger_: function() {
238 hotword.debug('Hotword triggered!'); 238 hotword.debug('Hotword triggered!');
239 assert(this.pluginManager_); 239 assert(this.pluginManager_, 'No NaCl plugin loaded on trigger');
240 // Detector implicitly stops when the hotword is detected. 240 // Detector implicitly stops when the hotword is detected.
241 this.state_ = State_.STOPPED; 241 this.state_ = State_.STOPPED;
242 242
243 // Play the chime. 243 // Play the chime.
244 this.chime_.play(); 244 this.chime_.play();
245 245
246 chrome.hotwordPrivate.notifyHotwordRecognition('search', function() {}); 246 chrome.hotwordPrivate.notifyHotwordRecognition('search', function() {});
247 247
248 // Implicitly clear the session. A session needs to be started in order to 248 // Implicitly clear the session. A session needs to be started in order to
249 // restart the detector. 249 // restart the detector.
(...skipping 25 matching lines...) Expand all
275 this.sessionSource_ = null; 275 this.sessionSource_ = null;
276 this.sessionStartedCb_ = null; 276 this.sessionStartedCb_ = null;
277 this.updateStateFromStatus_(); 277 this.updateStateFromStatus_();
278 } 278 }
279 }; 279 };
280 280
281 return { 281 return {
282 StateManager: StateManager 282 StateManager: StateManager
283 }; 283 };
284 }); 284 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/hotword/nacl_manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698