Bug 582032 - Part 1 - Adds a start method to nsIXULRuntime. r=cjones
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -36,16 +36,21 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
+#ifdef MOZ_IPC
+#include "mozilla/dom/ContentParent.h"
+using mozilla::dom::ContentParent;
+#endif
+
#if defined(XP_OS2) && defined(MOZ_OS2_HIGH_MEMORY)
// os2safe.h has to be included before os2.h, needed for high mem
#include <os2safe.h>
#endif
#define XPCOM_TRANSLATE_NSGM_ENTRY_POINT 1
#if defined(MOZ_WIDGET_QT)
@@ -759,16 +764,28 @@ NS_IMETHODIMP
nsXULAppInfo::GetProcessType(PRUint32* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = XRE_GetProcessType();
return NS_OK;
}
NS_IMETHODIMP
+nsXULAppInfo::EnsureContentProcess()
+{
+ if (XRE_GetProcessType() != GeckoProcessType_Default)
+ return NS_ERROR_NOT_AVAILABLE;
+
+ ContentParent* c = ContentParent::GetSingleton();
+ if (!c)
+ return NS_ERROR_NOT_AVAILABLE;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
nsXULAppInfo::InvalidateCachesOnRestart()
{
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DIR_STARTUP,
getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
if (!file)
--- a/xpcom/system/nsIXULRuntime.idl
+++ b/xpcom/system/nsIXULRuntime.idl
@@ -39,17 +39,17 @@
/**
* Provides information about the XUL runtime.
* @status UNSTABLE - This interface is not frozen and will probably change in
* future releases. If you need this functionality to be
* stable/frozen, please contact Benjamin Smedberg.
*/
-[scriptable, uuid(cb6078bb-c6b3-4f35-acfd-3b4efa934484)]
+[scriptable, uuid(7685dac8-3637-4660-a544-928c5ec0e714)]
interface nsIXULRuntime : nsISupports
{
/**
* Whether the application was launched in safe mode.
*/
readonly attribute boolean inSafeMode;
/**
@@ -102,9 +102,18 @@ interface nsIXULRuntime : nsISupports
readonly attribute unsigned long processType;
/**
* Signal the apprunner to invalidate caches on the next restart.
* This will cause components to be autoregistered and all
* fastload data to be re-created.
*/
void invalidateCachesOnRestart();
+
+ /**
+ * Starts a child process. This method is intented to pre-start a
+ * content child process so that when it is actually needed, it is
+ * ready to go.
+ *
+ * @throw NS_ERROR_NOT_AVAILABLE if not available.
+ */
+ void ensureContentProcess();
};