Bug 957086 - patch 1 - nsIDataStore instead DataStore.jsm, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 Jun 2014 15:36:46 +0100
changeset 186356 7c1a3e1fe6def7c0357163a8bf3856e55e3f63f1
parent 186355 d6dc9b7afda43cebe335482aefd795cd8de42159
child 186357 d296d4109a41785e076c82c32c7d91f19be6d55c
push id26889
push userryanvm@gmail.com
push dateTue, 03 Jun 2014 19:21:45 +0000
treeherdermozilla-central@298b39b50ff7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs957086
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 957086 - patch 1 - nsIDataStore instead DataStore.jsm, r=ehsan
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/datastore/DataStore.manifest
dom/datastore/DataStoreImpl.js
dom/datastore/DataStoreImpl.jsm
dom/datastore/DataStoreService.js
dom/datastore/moz.build
dom/datastore/nsIDataStore.idl
mobile/android/installer/package-manifest.in
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -809,16 +809,17 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 
 #ifdef MOZ_SERVICES_FXACCOUNTS
 @BINPATH@/components/FxAccountsUIGlue.js
 @BINPATH@/components/services_fxaccounts.xpt
 #endif
 
 @BINPATH@/components/DataStore.manifest
 @BINPATH@/components/DataStoreService.js
+@BINPATH@/components/DataStoreImpl.js
 @BINPATH@/components/dom_datastore.xpt
 
 #ifdef MOZ_WEBSPEECH
 @BINPATH@/components/dom_webspeechsynth.xpt
 #endif
 
 #ifdef XP_MACOSX
 @BINPATH@/@DLL_PREFIX@plugin_child_interpose@DLL_SUFFIX@
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -853,16 +853,17 @@ bin/libfreebl_32int64_3.so
 #endif
 @BINPATH@/metro/components
 @BINPATH@/metro/defaults
 @BINPATH@/metro/modules
 #endif
 
 @BINPATH@/components/DataStore.manifest
 @BINPATH@/components/DataStoreService.js
+@BINPATH@/components/DataStoreImpl.js
 @BINPATH@/components/dom_datastore.xpt
 
 
 #ifdef MOZ_ASAN
 #ifdef CLANG_CXX
 @BINPATH@/llvm-symbolizer
 #endif
 #endif
--- a/dom/datastore/DataStore.manifest
+++ b/dom/datastore/DataStore.manifest
@@ -1,2 +1,4 @@
+component {db5c9602-030f-4bff-a3de-881a8de370f2} DataStoreImpl.js
+contract @mozilla.org/dom/datastore;1 {db5c9602-030f-4bff-a3de-881a8de370f2}
 component {d193d0e2-c677-4a7b-bb0a-19155b470f2e} DataStoreService.js
 contract @mozilla.org/datastore-service;1 {d193d0e2-c677-4a7b-bb0a-19155b470f2e}
rename from dom/datastore/DataStoreImpl.jsm
rename to dom/datastore/DataStoreImpl.js
--- a/dom/datastore/DataStoreImpl.jsm
+++ b/dom/datastore/DataStoreImpl.js
@@ -1,18 +1,16 @@
 /* -*- Mode: js2; js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 'use strict'
 
-this.EXPORTED_SYMBOLS = ["DataStore"];
-
 function debug(s) {
   //dump('DEBUG DataStore: ' + s + '\n');
 }
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 const REVISION_ADDED = "added";
 const REVISION_UPDATED = "updated";
@@ -54,27 +52,27 @@ function validateId(aId) {
     return aId.length;
   }
 
   aId = parseInt(aId);
   return (!isNaN(aId) && aId > 0);
 }
 
 /* DataStore object */
-this.DataStore = function(aWindow, aName, aOwner, aReadOnly) {
+function DataStore() {
   debug("DataStore created");
-  this.init(aWindow, aName, aOwner, aReadOnly);
+  this.wrappedJSObject = this;
 }
 
-this.DataStore.prototype = {
+DataStore.prototype = {
   classDescription: "DataStore XPCOM Component",
   classID: Components.ID("{db5c9602-030f-4bff-a3de-881a8de370f2}"),
   contractID: "@mozilla.org/dom/datastore-impl;1",
-  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports,
-                                         Components.interfaces.nsIObserver]),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDataStore, Ci.nsISupports,
+                                         Ci.nsIObserver]),
 
   callbacks: [],
 
   _window: null,
   _name: null,
   _owner: null,
   _readOnly: null,
   _revisionId: null,
@@ -531,8 +529,10 @@ this.DataStore.prototype = {
     let cursorImpl = this._window.DataStoreCursorImpl.
                                   _create(this._window, this._cursor);
 
     let exposedCursor = new this._window.DataStoreCursor();
     exposedCursor.setDataStoreCursorImpl(cursorImpl);
     return exposedCursor;
   }
 };
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DataStore]);
--- a/dom/datastore/DataStoreService.js
+++ b/dom/datastore/DataStoreService.js
@@ -11,17 +11,16 @@
 function debug(s) {
   //dump('DEBUG DataStoreService: ' + s + '\n');
 }
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 Cu.import('resource://gre/modules/Services.jsm');
-Cu.import('resource://gre/modules/DataStoreImpl.jsm');
 Cu.import("resource://gre/modules/DataStoreDB.jsm");
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
                                    "@mozilla.org/childprocessmessagemanager;1",
                                    "nsIMessageSender");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
@@ -345,20 +344,26 @@ DataStoreService.prototype = {
     let results = new aWindow.Array();
 
     if (!callbackPending) {
       aResolve(results);
       return;
     }
 
     for (let i = 0; i < aStores.length; ++i) {
-      let obj = new DataStore(aWindow, aStores[i].name,
-                              aStores[i].owner, aStores[i].readOnly);
+      let obj = Cc["@mozilla.org/dom/datastore;1"]
+                  .createInstance(Ci.nsIDataStore);
+      if (!obj || !obj.wrappedJSObject) {
+        dump("Failed to create a DataStore object.\n");
+        return;
+      }
 
-      let storeImpl = aWindow.DataStoreImpl._create(aWindow, obj);
+      obj.init(aWindow, aStores[i].name, aStores[i].owner, aStores[i].readOnly);
+
+      let storeImpl = aWindow.DataStoreImpl._create(aWindow, obj.wrappedJSObject);
 
       let exposedStore = new aWindow.DataStore();
       exposedStore.setDataStoreImpl(storeImpl);
 
       obj.exposedObject = exposedStore;
 
       results.push(exposedStore);
 
--- a/dom/datastore/moz.build
+++ b/dom/datastore/moz.build
@@ -1,15 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
+    'nsIDataStore.idl',
     'nsIDataStoreService.idl',
 ]
 
 XPIDL_MODULE = 'dom_datastore'
 
 EXPORTS.mozilla.dom += [
     'DataStore.h',
     'DataStoreCursor.h',
@@ -21,22 +22,22 @@ SOURCES += [
 ]
 
 LOCAL_INCLUDES += [
     '/js/xpconnect/wrappers',
 ]
 
 EXTRA_COMPONENTS += [
     'DataStore.manifest',
+    'DataStoreImpl.js',
     'DataStoreService.js',
 ]
 
 EXTRA_JS_MODULES += [
     'DataStoreChangeNotifier.jsm',
     'DataStoreCursorImpl.jsm',
     'DataStoreDB.jsm',
-    'DataStoreImpl.jsm',
     'DataStoreServiceInternal.jsm',
 ]
 
 MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
 
 FINAL_LIBRARY = 'xul'
new file mode 100644
--- /dev/null
+++ b/dom/datastore/nsIDataStore.idl
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+interface nsIDOMWindow;
+
+// NOTE: This is a temporary interface.
+// It will be removed in the next patches for rewriting DataStore in C++.
+[scriptable, uuid(0b41fef5-14ba-48b0-923c-3d8fb64692ae)]
+interface nsIDataStore : nsISupports
+{
+  void init(in nsIDOMWindow window,
+            in DOMString name,
+            in DOMString manifestURL,
+            in boolean readOnly);
+
+  attribute jsval exposedObject;
+
+  void retrieveRevisionId(in jsval cb);
+};
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -620,9 +620,10 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 #endif
 
 #ifdef MOZ_ANDROID_SYNTHAPKS
 @BINPATH@/components/WebappsUpdateTimer.js
 #endif
 
 @BINPATH@/components/DataStore.manifest
 @BINPATH@/components/DataStoreService.js
+@BINPATH@/components/DataStoreImpl.js
 @BINPATH@/components/dom_datastore.xpt