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_); |
}; |