Bug 938406 - DataStore - proper event sent when the first revision is created, r=ehsan

This commit is contained in:
Andrea Marchesini 2013-12-12 10:18:37 +00:00
parent 8e419cfcfb
commit 114ee4d87a
5 changed files with 16 additions and 12 deletions

View File

@ -9,7 +9,7 @@
this.EXPORTED_SYMBOLS = ["DataStore"];
function debug(s) {
// dump('DEBUG DataStore: ' + s + '\n');
//dump('DEBUG DataStore: ' + s + '\n');
}
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;

View File

@ -9,7 +9,7 @@
this.EXPORTED_SYMBOLS = ['DataStoreCursor'];
function debug(s) {
// dump('DEBUG DataStoreCursor: ' + s + '\n');
//dump('DEBUG DataStoreCursor: ' + s + '\n');
}
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;

View File

@ -9,7 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
this.EXPORTED_SYMBOLS = ['DataStoreDB'];
function debug(s) {
// dump('DEBUG DataStoreDB: ' + s + '\n');
//dump('DEBUG DataStoreDB: ' + s + '\n');
}
const DATASTOREDB_VERSION = 1;

View File

@ -9,7 +9,7 @@
/* static functions */
function debug(s) {
// dump('DEBUG DataStoreService: ' + s + '\n');
//dump('DEBUG DataStoreService: ' + s + '\n');
}
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
@ -137,17 +137,13 @@ DataStoreService.prototype = {
request.onsuccess = function(aEvent) {
let cursor = aEvent.target.result;
if (cursor) {
ppmm.broadcastAsyncMessage('datastore-first-revision-created',
{ name: aName, owner: aOwner });
debug("First revision already created.");
self.enableDataStore(aAppId, aName, aOwner);
} else {
// If the revision doesn't exist, let's create the first one.
db.addRevision(aRevisionStore, 0, REVISION_VOID, function() {
debug("First revision created.");
if (aName in self.stores && aAppId in self.stores[aName]) {
self.stores[aName][aAppId].enabled = true;
ppmm.broadcastAsyncMessage('datastore-first-revision-created',
{ name: aName, owner: aOwner });
}
self.enableDataStore(aAppId, aName, aOwner);
});
}
};
@ -155,6 +151,14 @@ DataStoreService.prototype = {
);
},
enableDataStore: function(aAppId, aName, aOwner) {
if (aName in this.stores && aAppId in this.stores[aName]) {
this.stores[aName][aAppId].enabled = true;
ppmm.broadcastAsyncMessage('datastore-first-revision-created',
{ name: aName, owner: aOwner });
}
},
addPermissions: function(aAppId, aName, aOrigin, aOwner, aReadOnly) {
// When a new DataStore is installed, the permissions must be set for the
// owner app.

View File

@ -9,7 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
this.EXPORTED_SYMBOLS = ["DataStoreServiceInternal"];
function debug(s) {
// dump('DEBUG DataStoreServiceInternal: ' + s + '\n');
//dump('DEBUG DataStoreServiceInternal: ' + s + '\n');
}
Cu.import("resource://gre/modules/XPCOMUtils.jsm");