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

Unified Diff: chrome/browser/resources/hotword/training_manager.js

Issue 1023063004: Hotword: Check for the existence of a speaker model. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Typo 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/hotword/manager.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/hotword/training_manager.js
diff --git a/chrome/browser/resources/hotword/training_manager.js b/chrome/browser/resources/hotword/training_manager.js
index 61c68c2b89efa9af2d68560f546d61218196aac5..8bdc440e80bada2bcc27b5c081859ac5c1e5a941 100644
--- a/chrome/browser/resources/hotword/training_manager.js
+++ b/chrome/browser/resources/hotword/training_manager.js
@@ -28,11 +28,12 @@ cr.define('hotword', function() {
}
/**
- * Handles a success event on mounting the file system event.
+ * Handles a success event on mounting the file system event and deletes
+ * the user data files.
* @param {FileSystem} fs The FileSystem object.
* @private
*/
- TrainingManager.onRequestFileSystemSuccess_ = function(fs) {
+ TrainingManager.deleteFiles_ = function(fs) {
fs.root.getFile(hotword.constants.SPEAKER_MODEL_FILE_NAME, {create: false},
TrainingManager.deleteFile_, TrainingManager.fileErrorHandler_);
@@ -73,12 +74,52 @@ cr.define('hotword', function() {
};
/**
+ * Handles a success event on mounting the file system checks for the
Anand Mistry (off Chromium) 2015/03/23 03:10:03 ...mounting the file system _and_ checks for...
kcarattini 2015/03/23 22:59:39 Done.
+ * existence of the speaker model.
+ * @param {FileSystem} fs The FileSystem object.
+ * @private
+ */
+ TrainingManager.speakerModelExists_ = function(fs) {
+ fs.root.getFile(hotword.constants.SPEAKER_MODEL_FILE_NAME, {create: false},
+ TrainingManager.sendSpeakerModelExistsResponse_,
+ TrainingManager.fileErrorHandler_);
+ };
+
+ /**
+ * Sends a response throught the HotwordPrivateApi indicating whether
Anand Mistry (off Chromium) 2015/03/23 03:10:03 throught
kcarattini 2015/03/23 22:59:40 Done.
+ * the speaker model exists.
+ * @param {FileEntry} fileEntry The FileEntry object.
+ * @private
+ */
+ TrainingManager.sendSpeakerModelExistsResponse_ = function(fileEntry) {
+ if (fileEntry.isFile) {
+ hotword.debug('File found: ' + fileEntry.fullPath);
+ if (hotword.DEBUG || window.localStorage['hotword.DEBUG']) {
+ fileEntry.getMetadata(function(md) {
+ hotword.debug('File size: ' + md.size);
+ });
+ }
+ }
+ chrome.hotwordPrivate.speakerModelExistsResult(fileEntry.isFile);
+ };
+
+ /**
* Handles a request to delete the speaker model.
*/
TrainingManager.handleDeleteSpeakerModel = function() {
window.webkitRequestFileSystem(PERSISTENT,
hotword.constants.FILE_SYSTEM_SIZE_BYTES,
- TrainingManager.onRequestFileSystemSuccess_,
+ TrainingManager.deleteFiles_,
+ TrainingManager.fileErrorHandler_);
+ };
+
+ /**
+ * Handles a request for the speaker model existence.
+ */
+ TrainingManager.handleSpeakerModelExists = function() {
+ window.webkitRequestFileSystem(PERSISTENT,
+ hotword.constants.FILE_SYSTEM_SIZE_BYTES,
+ TrainingManager.speakerModelExists_,
TrainingManager.fileErrorHandler_);
};
« no previous file with comments | « chrome/browser/resources/hotword/manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698