Bug 969043 - Log warning in save()/deleteAll() calls outside of sync window (r=margaret)

This commit is contained in:
Lucas Rocha 2014-03-20 15:31:42 +00:00
Родитель 60cbf7f188
Коммит 5cdf6d897c
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -89,6 +89,10 @@ var gTimerRegistered = false;
// Map of datasetId -> { interval: <integer>, callback: <function> }
var gSyncCallbacks = {};
// Whether or not writes to the provider are expected.
// e.g. save() and deleteAll()
var gWritesAreExpected = false;
/**
* nsITimerCallback implementation. Checks to see if it's time to sync any registered datasets.
*
@ -154,7 +158,10 @@ this.HomeProvider = Object.freeze({
return false;
}
gWritesAreExpected = true;
callback(datasetId);
gWritesAreExpected = false;
return true;
},
@ -292,6 +299,10 @@ HomeStorage.prototype = {
* @resolves When the operation has completed.
*/
save: function(data) {
if (!gWritesAreExpected) {
Cu.reportError("HomeStorage: save() called outside of sync window");
}
return Task.spawn(function save_task() {
let db = yield getDatabaseConnection();
try {
@ -331,6 +342,10 @@ HomeStorage.prototype = {
* @resolves When the operation has completed.
*/
deleteAll: function() {
if (!gWritesAreExpected) {
Cu.reportError("HomeStorage: deleteAll() called outside of sync window");
}
return Task.spawn(function delete_all_task() {
let db = yield getDatabaseConnection();
try {