Bug 715814 - Implement Web Activities : Activity Object [r=mounir]
authorFabrice Desré <fabrice@mozilla.com>
Fri, 20 Jul 2012 17:41:30 +0200
changeset 99926 09094f943d293cf0268ec9a5fe7d304c08431ee2
parent 99925 53da353104ee4139cc8daef1f003ae5bc473544c
child 99927 7938ab0b63db406228cf8f2a5ce5b0dd346c2e99
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmounir
bugs715814
milestone17.0a1
Bug 715814 - Implement Web Activities : Activity Object [r=mounir]
b2g/installer/package-manifest.in
dom/activities/Makefile.in
dom/activities/interfaces/Makefile.in
dom/activities/interfaces/nsIActivityProxy.idl
dom/activities/src/Activities.manifest
dom/activities/src/Activity.cpp
dom/activities/src/Activity.h
dom/activities/src/ActivityProxy.js
dom/activities/src/Makefile.in
dom/base/DOMRequest.cpp
dom/base/DOMRequest.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
layout/build/Makefile.in
layout/build/nsLayoutModule.cpp
toolkit/toolkit-makefiles.sh
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -148,16 +148,17 @@
 @BINPATH@/components/content_htmldoc.xpt
 @BINPATH@/components/content_html.xpt
 @BINPATH@/components/content_xslt.xpt
 @BINPATH@/components/content_xtf.xpt
 @BINPATH@/components/cookie.xpt
 @BINPATH@/components/directory.xpt
 @BINPATH@/components/docshell.xpt
 @BINPATH@/components/dom.xpt
+@BINPATH@/components/dom_activities.xpt
 @BINPATH@/components/dom_apps.xpt
 @BINPATH@/components/dom_base.xpt
 #ifdef MOZ_B2G_RIL
 @BINPATH@/components/dom_telephony.xpt
 @BINPATH@/components/dom_wifi.xpt
 @BINPATH@/components/dom_system_gonk.xpt
 #endif
 @BINPATH@/components/dom_battery.xpt
@@ -471,16 +472,19 @@
 @BINPATH@/components/Webapps.manifest
 @BINPATH@/components/AppsService.js
 @BINPATH@/components/AppsService.manifest
 
 @BINPATH@/components/SystemMessageInternal.js
 @BINPATH@/components/SystemMessageManager.js
 @BINPATH@/components/SystemMessageManager.manifest
 
+@BINPATH@/components/ActivityProxy.js
+@BINPATH@/components/Activities.manifest
+
 @BINPATH@/components/AppProtocolHandler.js
 @BINPATH@/components/AppProtocolHandler.manifest
 
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsURLClassifier.manifest
--- a/dom/activities/Makefile.in
+++ b/dom/activities/Makefile.in
@@ -4,11 +4,11 @@
 
 DEPTH     = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-PARALLEL_DIRS = interfaces
+PARALLEL_DIRS = interfaces src
 
 include $(topsrcdir)/config/rules.mk
--- a/dom/activities/interfaces/Makefile.in
+++ b/dom/activities/interfaces/Makefile.in
@@ -11,11 +11,12 @@ include $(DEPTH)/config/autoconf.mk
 
 XPIDL_MODULE = dom_activities
 
 XPIDLSRCS = nsIDOMActivity.idl \
             nsIDOMActivityOptions.idl \
             nsIDOMActivityHandlerDescription.idl \
             nsIDOMActivityRequestHandler.idl \
             nsIDOMNavigatorActivities.idl \
+            nsIActivityProxy.idl \
             $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/activities/interfaces/nsIActivityProxy.idl
@@ -0,0 +1,18 @@
+/* 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 nsIDOMMozActivity;
+interface nsIDOMMozActivityOptions;
+
+/**
+  * Implemented by @mozilla.org/dom/activities/proxy;1
+  */
+[scriptable, uuid(2241faf9-6219-4bc0-95f3-18651ac8a18b)]
+interface nsIActivityProxy : nsISupports
+{
+    void startActivity(in nsIDOMMozActivity activity, in nsIDOMMozActivityOptions options);
+    void cleanup();
+};
new file mode 100644
--- /dev/null
+++ b/dom/activities/src/Activities.manifest
@@ -0,0 +1,2 @@
+component {ba9bd5cb-76a0-4ecf-a7b3-d2f7c43c5949} ActivityProxy.js
+contract @mozilla.org/dom/activities/proxy;1 {ba9bd5cb-76a0-4ecf-a7b3-d2f7c43c5949}
new file mode 100644
--- /dev/null
+++ b/dom/activities/src/Activity.cpp
@@ -0,0 +1,78 @@
+/* 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 "Activity.h"
+#include "nsDOMClassInfo.h"
+#include "nsContentUtils.h"
+#include "nsIDOMActivityOptions.h"
+
+using namespace mozilla::dom;
+
+DOMCI_DATA(MozActivity, Activity)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Activity)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMMozActivity)
+  NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozActivity)
+NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
+
+NS_IMPL_ADDREF_INHERITED(Activity, DOMRequest)
+NS_IMPL_RELEASE_INHERITED(Activity, DOMRequest)
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(Activity)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(Activity,
+                                                  DOMRequest)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProxy)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(Activity,
+                                                DOMRequest)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProxy)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(Activity, DOMRequest)
+NS_IMPL_CYCLE_COLLECTION_TRACE_END
+
+NS_IMETHODIMP
+Activity::Initialize(nsISupports* aOwner,
+                     JSContext* aContext,
+                     JSObject* aObject,
+                     PRUint32 aArgc,
+                     JS::Value* aArgv)
+{
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aOwner);
+  NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
+
+  Init(window);
+
+  // We expect a single argument, which is a nsIDOMMozActivityOptions.
+  if (aArgc != 1 || !aArgv[0].isObject()) {
+    return NS_ERROR_INVALID_ARG;
+  }
+ 
+  nsCOMPtr<nsISupports> tmp;
+  nsContentUtils::XPConnect()->WrapJS(aContext, aArgv[0].toObjectOrNull(),
+                                      NS_GET_IID(nsIDOMMozActivityOptions),
+                                      getter_AddRefs(tmp));
+  nsCOMPtr<nsIDOMMozActivityOptions> options = do_QueryInterface(tmp);
+  if (!options) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  // Instantiate a JS proxy that will do the child <-> parent communication
+  // with the JS implementation of the backend.
+  nsresult rv;
+  mProxy = do_CreateInstance("@mozilla.org/dom/activities/proxy;1", &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  mProxy->StartActivity(this, options);
+  return NS_OK;
+}
+
+Activity::~Activity() {
+  if (mProxy) {
+    mProxy->Cleanup();
+  }
+}
new file mode 100644
--- /dev/null
+++ b/dom/activities/src/Activity.h
@@ -0,0 +1,45 @@
+/* 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/. */
+
+#ifndef mozilla_dom_activities_Activity_h
+#define mozilla_dom_activities_Activity_h
+
+#include "nsIDOMActivity.h"
+#include "nsIActivityProxy.h"
+#include "DOMRequest.h"
+#include "nsIJSNativeInitializer.h"
+
+#define NS_DOMACTIVITY_CID                          \
+ {0x1c5b0930, 0xc90c, 0x4e9c, {0xaf, 0x4e, 0xb0, 0xb7, 0xa6, 0x59, 0xb4, 0xed}}
+
+#define NS_DOMACTIVITY_CONTRACTID "@mozilla.org/dom/activity;1" 
+
+namespace mozilla {
+namespace dom {
+
+class Activity : public nsIDOMMozActivity
+               , public nsIJSNativeInitializer // In order to get a window for the DOMRequest
+               , public DOMRequest
+{
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_NSIDOMMOZACTIVITY
+  NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
+  NS_FORWARD_NSIDOMDOMREQUEST(DOMRequest::)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Activity, DOMRequest)
+
+  // nsIJSNativeInitializer
+  NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aContext,
+                        JSObject* aObject, PRUint32 aArgc, jsval* aArgv);
+
+protected:
+  nsCOMPtr<nsIActivityProxy> mProxy;
+
+  ~Activity();
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_activities_Activity_h
new file mode 100644
--- /dev/null
+++ b/dom/activities/src/ActivityProxy.js
@@ -0,0 +1,78 @@
+/* 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";
+ 
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+ 
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
+  return Cc["@mozilla.org/childprocessmessagemanager;1"]
+           .getService(Ci.nsIFrameMessageManager)
+           .QueryInterface(Ci.nsISyncMessageSender);
+});
+
+function debug(aMsg) {
+  //dump("-- ActivityProxy " + Date.now() + " : " + aMsg + "\n");
+}
+
+/**
+  * nsIActivityProxy implementation
+  * We keep a reference to the C++ Activity object, and
+  * communicate with the Message Manager to know when to 
+  * fire events on it.
+  */
+function ActivityProxy() {
+  debug("ActivityProxy");
+  this.activity = null;
+}
+
+ActivityProxy.prototype = {
+  startActivity: function actProxy_startActivity(aActivity, aOptions) {
+    debug("startActivity");
+
+    this.activity = aActivity;
+    this.id = Cc["@mozilla.org/uuid-generator;1"]
+                .getService(Ci.nsIUUIDGenerator)
+                .generateUUID().toString();
+    cpmm.sendAsyncMessage("Activity:Start", { id: this.id, options: aOptions });
+
+    cpmm.addMessageListener("Activity:FireSuccess", this);
+    cpmm.addMessageListener("Activity:FireError", this);
+  },
+
+  receiveMessage: function actProxy_receiveMessage(aMessage) {
+    debug("Got message: " + aMessage.name);
+    let msg = aMessage.json;
+    if (msg.id != this.id)
+      return;
+    debug("msg=" + JSON.stringify(msg));
+
+    switch(aMessage.name) {
+      case "Activity:FireSuccess":
+        debug("FireSuccess");
+        Services.DOMRequest.fireSuccess(this.activity, msg.result);
+        break;
+      case "Activity:FireError":
+        debug("FireError");
+        Services.DOMRequest.fireError(this.activity, msg.error);
+        break;
+    }
+  },
+
+  cleanup: function actProxy_cleanup() {
+    debug("cleanup");
+    cpmm.removeMessageListener("Activity:FireSuccess", this);
+    cpmm.removeMessageListener("Activity:FireError", this);
+  },
+
+  classID: Components.ID("{ba9bd5cb-76a0-4ecf-a7b3-d2f7c43c5949}"),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIActivityProxy])
+}
+
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityProxy]);
new file mode 100644
--- /dev/null
+++ b/dom/activities/src/Makefile.in
@@ -0,0 +1,34 @@
+# 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/.
+
+DEPTH     = ../../..
+topsrcdir = @top_srcdir@
+srcdir    = @srcdir@
+VPATH     = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE           = dom
+LIBRARY_NAME     = dom_activities_s
+LIBXUL_LIBRARY   = 1
+FORCE_STATIC_LIB = 1
+
+include $(topsrcdir)/dom/dom-config.mk
+
+CPPSRCS = \
+  Activity.cpp \
+  $(NULL)
+
+EXPORTS_NAMESPACES = mozilla/dom
+EXPORTS_mozilla/dom = \
+  Activity.h \
+  $(NULL)
+
+EXTRA_COMPONENTS = \
+  ActivityProxy.js \
+  Activities.manifest \
+  $(NULL)
+
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/config/rules.mk
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -16,16 +16,31 @@
 using mozilla::dom::DOMRequest;
 using mozilla::dom::DOMRequestService;
 
 DOMRequest::DOMRequest(nsIDOMWindow* aWindow)
   : mResult(JSVAL_VOID)
   , mDone(false)
   , mRooted(false)
 {
+  Init(aWindow);
+}
+
+// We need this constructor for dom::Activity that inherits from DOMRequest
+// but has no window available from the constructor.
+DOMRequest::DOMRequest()
+  : mResult(JSVAL_VOID)
+  , mDone(false)
+  , mRooted(false)
+{
+}
+
+void
+DOMRequest::Init(nsIDOMWindow* aWindow)
+{
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
   BindToOwner(window->IsInnerWindow() ? window.get() :
                                         window->GetCurrentInnerWindow());
 }
 
 DOMCI_DATA(DOMRequest, DOMRequest)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(DOMRequest)
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -37,29 +37,32 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
                                                          nsDOMEventTargetHelper)
 
   void FireSuccess(jsval aResult);
   void FireError(const nsAString& aError);
   void FireError(nsresult aError);
 
   DOMRequest(nsIDOMWindow* aWindow);
+  DOMRequest();
 
   virtual ~DOMRequest()
   {
     if (mRooted) {
       UnrootResultVal();
     }
   }
 
 protected:
   void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
 
   virtual void RootResultVal();
   virtual void UnrootResultVal();
+
+  void Init(nsIDOMWindow* aWindow);
 };
 
 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMREQUESTSERVICE
 
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -519,16 +519,18 @@ using mozilla::dom::indexedDB::IDBWrappe
 #include "BluetoothManager.h"
 #include "BluetoothAdapter.h"
 #include "BluetoothDevice.h"
 #include "BluetoothDeviceEvent.h"
 #endif
 
 #include "nsIDOMNavigatorSystemMessages.h"
 
+#include "mozilla/dom/Activity.h"
+
 #include "DOMError.h"
 #include "DOMRequest.h"
 #include "nsIOpenWindowEventDetail.h"
 #include "nsIDOMGlobalObjectConstructor.h"
 
 #include "DOMFileHandle.h"
 #include "FileRequest.h"
 #include "LockedFile.h"
@@ -1694,16 +1696,18 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(DOMFileHandle, FileHandle, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(FileRequest, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(LockedFile, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(MozActivity, nsEventTargetSH,
+                           EVENTTARGET_SCRIPTABLE_FLAGS)
 };
 
 // Objects that should be constructable through |new Name();|
 struct nsContractIDMapData
 {
   PRInt32 mDOMClassInfoID;
   const char *mContractID;
 };
@@ -1718,16 +1722,17 @@ static const nsContractIDMapData kConstr
   NS_DEFINE_CONSTRUCTOR_DATA(FormData, NS_FORMDATA_CONTRACTID)
   NS_DEFINE_CONSTRUCTOR_DATA(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID)
   NS_DEFINE_CONSTRUCTOR_DATA(WebSocket, NS_WEBSOCKET_CONTRACTID)
   NS_DEFINE_CONSTRUCTOR_DATA(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID)
   NS_DEFINE_CONSTRUCTOR_DATA(XSLTProcessor,
                              "@mozilla.org/document-transformer;1?type=xslt")
   NS_DEFINE_CONSTRUCTOR_DATA(EventSource, NS_EVENTSOURCE_CONTRACTID)
   NS_DEFINE_CONSTRUCTOR_DATA(MutationObserver, NS_DOMMUTATIONOBSERVER_CONTRACTID)
+  NS_DEFINE_CONSTRUCTOR_DATA(MozActivity, NS_DOMACTIVITY_CONTRACTID)
 };
 
 #define NS_DEFINE_EVENT_CTOR(_class)                        \
   nsresult                                                  \
   NS_DOM##_class##Ctor(nsISupports** aInstancePtrResult)    \
   {                                                         \
     nsIDOMEvent* e = nsnull;                                \
     nsresult rv = NS_NewDOM##_class(&e, nsnull, nsnull);    \
@@ -2485,16 +2490,17 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorTelephony)
 #endif
     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorNetwork,
                                         network::IsAPIEnabled())
 #ifdef MOZ_B2G_BT
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorBluetooth)
 #endif
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorSystemMessages)
+
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPlugin)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(PluginArray, nsIDOMPluginArray)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPluginArray)
@@ -4538,16 +4544,22 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(LockedFile, nsIDOMLockedFile)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLockedFile)
   DOM_CLASSINFO_MAP_END
 
+  DOM_CLASSINFO_MAP_BEGIN(MozActivity, nsIDOMMozActivity)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozActivity)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
+  DOM_CLASSINFO_MAP_END
+
 #ifdef DEBUG
   {
     PRUint32 i = ArrayLength(sClassInfoData);
 
     if (i != eDOMClassInfoIDCount) {
       NS_ERROR("The number of items in sClassInfoData doesn't match the "
                "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
 
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -536,8 +536,10 @@ DOMCI_CLASS(BluetoothDeviceEvent)
 
 DOMCI_CLASS(DOMError)
 DOMCI_CLASS(DOMRequest)
 DOMCI_CLASS(OpenWindowEventDetail)
 
 DOMCI_CLASS(DOMFileHandle)
 DOMCI_CLASS(FileRequest)
 DOMCI_CLASS(LockedFile)
+
+DOMCI_CLASS(MozActivity)
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -54,16 +54,17 @@ SHARED_LIBRARY_LIBS = \
 	$(DEPTH)/content/xml/document/src/$(LIB_PREFIX)gkconxmldoc_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/xslt/src/base/$(LIB_PREFIX)txbase_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/xslt/src/xml/$(LIB_PREFIX)txxml_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/xslt/src/xpath/$(LIB_PREFIX)txxpath_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/xslt/src/xslt/$(LIB_PREFIX)txxslt_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/xbl/src/$(LIB_PREFIX)gkconxbl_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/xul/document/src/$(LIB_PREFIX)gkconxuldoc_s.$(LIB_SUFFIX) \
 	$(DEPTH)/view/src/$(LIB_PREFIX)gkview_s.$(LIB_SUFFIX) \
+	$(DEPTH)/dom/activities/src/$(LIB_PREFIX)dom_activities_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/base/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/battery/$(LIB_PREFIX)dom_battery_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/contacts/$(LIB_PREFIX)jsdomcontacts_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/alarm/$(LIB_PREFIX)domalarm_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/devicestorage/$(LIB_PREFIX)domdevicestorage_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/file/$(LIB_PREFIX)domfile_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/power/$(LIB_PREFIX)dom_power_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/settings/$(LIB_PREFIX)jsdomsettings_s.$(LIB_SUFFIX) \
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -85,19 +85,21 @@
 #include "nsScriptNameSpaceManager.h"
 #include "nsIControllerContext.h"
 #include "nsDOMScriptObjectFactory.h"
 #include "nsDOMStorage.h"
 #include "nsJSON.h"
 #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
 #include "mozilla/dom/DOMRequest.h"
 #include "mozilla/OSFileConstants.h"
+#include "mozilla/dom/Activity.h"
 
 using mozilla::dom::indexedDB::IndexedDatabaseManager;
 using mozilla::dom::DOMRequestService;
+using mozilla::dom::Activity;
 
 #ifdef MOZ_B2G_RIL
 #include "SystemWorkerManager.h"
 using mozilla::dom::gonk::SystemWorkerManager;
 #define SYSTEMWORKERMANAGER_CID \
   {0xd53b6524, 0x6ac3, 0x42b0, {0xae, 0xca, 0x62, 0xb3, 0xc4, 0xe5, 0x2b, 0x04}}
 #define SYSTEMWORKERMANAGER_CONTRACTID \
   "@mozilla.org/telephony/system-worker-manager;1"
@@ -243,16 +245,17 @@ using mozilla::dom::alarm::AlarmHalServi
 // Factory Constructor
 NS_GENERIC_FACTORY_CONSTRUCTOR(txMozillaXSLTProcessor)
 NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsXPathEvaluator, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsXMLHttpRequest, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsEventSource)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebSocket)
+NS_GENERIC_FACTORY_CONSTRUCTOR(Activity)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDOMFileReader, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFormData)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlobProtocolHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMParser)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDOMStorageManager,
                                          nsDOMStorageManager::GetInstance)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChannelPolicy)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(IndexedDatabaseManager,
@@ -728,16 +731,17 @@ NS_DEFINE_NAMED_CID(TRANSFORMIIX_XPATH_E
 NS_DEFINE_NAMED_CID(TRANSFORMIIX_NODESET_CID);
 NS_DEFINE_NAMED_CID(NS_XMLSERIALIZER_CID);
 NS_DEFINE_NAMED_CID(NS_FILEREADER_CID);
 NS_DEFINE_NAMED_CID(NS_FORMDATA_CID);
 NS_DEFINE_NAMED_CID(NS_BLOBPROTOCOLHANDLER_CID);
 NS_DEFINE_NAMED_CID(NS_XMLHTTPREQUEST_CID);
 NS_DEFINE_NAMED_CID(NS_EVENTSOURCE_CID);
 NS_DEFINE_NAMED_CID(NS_WEBSOCKET_CID);
+NS_DEFINE_NAMED_CID(NS_DOMACTIVITY_CID);
 NS_DEFINE_NAMED_CID(NS_DOMPARSER_CID);
 NS_DEFINE_NAMED_CID(NS_DOMSTORAGE2_CID);
 NS_DEFINE_NAMED_CID(NS_DOMSTORAGEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_DOMJSON_CID);
 NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID);
 NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID);
 NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID);
 #ifdef MOZ_B2G_RIL
@@ -999,16 +1003,17 @@ static const mozilla::Module::CIDEntry k
   { &kTRANSFORMIIX_NODESET_CID, false, NULL, txNodeSetAdaptorConstructor },
   { &kNS_XMLSERIALIZER_CID, false, NULL, nsDOMSerializerConstructor },
   { &kNS_FILEREADER_CID, false, NULL, nsDOMFileReaderConstructor },
   { &kNS_FORMDATA_CID, false, NULL, nsFormDataConstructor },
   { &kNS_BLOBPROTOCOLHANDLER_CID, false, NULL, nsBlobProtocolHandlerConstructor },
   { &kNS_XMLHTTPREQUEST_CID, false, NULL, nsXMLHttpRequestConstructor },
   { &kNS_EVENTSOURCE_CID, false, NULL, nsEventSourceConstructor },
   { &kNS_WEBSOCKET_CID, false, NULL, nsWebSocketConstructor },
+  { &kNS_DOMACTIVITY_CID, false, NULL, ActivityConstructor },
   { &kNS_DOMPARSER_CID, false, NULL, nsDOMParserConstructor },
   { &kNS_DOMSTORAGE2_CID, false, NULL, NS_NewDOMStorage2 },
   { &kNS_DOMSTORAGEMANAGER_CID, false, NULL, nsDOMStorageManagerConstructor },
   { &kNS_DOMJSON_CID, false, NULL, NS_NewJSON },
   { &kNS_TEXTEDITOR_CID, false, NULL, nsPlaintextEditorConstructor },
   { &kINDEXEDDB_MANAGER_CID, false, NULL, IndexedDatabaseManagerConstructor },
   { &kDOMREQUEST_SERVICE_CID, false, NULL, DOMRequestServiceConstructor },
 #ifdef MOZ_B2G_RIL
@@ -1135,16 +1140,17 @@ static const mozilla::Module::ContractID
   { TRANSFORMIIX_NODESET_CONTRACTID, &kTRANSFORMIIX_NODESET_CID },
   { NS_XMLSERIALIZER_CONTRACTID, &kNS_XMLSERIALIZER_CID },
   { NS_FILEREADER_CONTRACTID, &kNS_FILEREADER_CID },
   { NS_FORMDATA_CONTRACTID, &kNS_FORMDATA_CID },
   { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX BLOBURI_SCHEME, &kNS_BLOBPROTOCOLHANDLER_CID },
   { NS_XMLHTTPREQUEST_CONTRACTID, &kNS_XMLHTTPREQUEST_CID },
   { NS_EVENTSOURCE_CONTRACTID, &kNS_EVENTSOURCE_CID },
   { NS_WEBSOCKET_CONTRACTID, &kNS_WEBSOCKET_CID },
+  { NS_DOMACTIVITY_CONTRACTID, &kNS_DOMACTIVITY_CID },
   { NS_DOMPARSER_CONTRACTID, &kNS_DOMPARSER_CID },
   { "@mozilla.org/dom/storage;2", &kNS_DOMSTORAGE2_CID },
   { "@mozilla.org/dom/storagemanager;1", &kNS_DOMSTORAGEMANAGER_CID },
   { "@mozilla.org/dom/json;1", &kNS_DOMJSON_CID },
   { "@mozilla.org/editor/texteditor;1", &kNS_TEXTEDITOR_CID },
   { INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID },
   { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID },
 #ifdef MOZ_B2G_RIL  
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -32,16 +32,17 @@ MAKEFILES_dom="
   dom/interfaces/stylesheets/Makefile
   dom/interfaces/svg/Makefile
   dom/interfaces/traversal/Makefile
   dom/interfaces/xbl/Makefile
   dom/interfaces/xpath/Makefile
   dom/interfaces/xul/Makefile
   dom/activities/Makefile
   dom/activities/interfaces/Makefile
+  dom/activities/src/Makefile
   dom/alarm/Makefile
   dom/base/Makefile
   dom/battery/Makefile
   dom/file/Makefile
   dom/indexedDB/Makefile
   dom/ipc/Makefile
   dom/locales/Makefile
   dom/messages/Makefile