зеркало из https://github.com/mozilla/pjs.git
NOT PART OF BUILD!
New embedding APIs for *simple* initialisation by hiding all the XPCOM initialisation and kludges that embedding apps have to do.
This commit is contained in:
Родитель
c88d7e8ab9
Коммит
9af63e0f5d
|
@ -0,0 +1,41 @@
|
||||||
|
#!nmake
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public
|
||||||
|
# License Version 1.1 (the "License"); you may not use this file
|
||||||
|
# except in compliance with the License. You may obtain a copy of
|
||||||
|
# the License at http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS
|
||||||
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
# implied. See the License for the specific language governing
|
||||||
|
# rights and limitations under the License.
|
||||||
|
#
|
||||||
|
# The Original Code is the Mozilla browser.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is Netscape
|
||||||
|
# Communications, Inc. Portions created by Netscape are
|
||||||
|
# Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# Adam Lock <adamlock@netscape.com>
|
||||||
|
|
||||||
|
DEPTH=..\..
|
||||||
|
MODULE=embed_base
|
||||||
|
|
||||||
|
XPIDLSRCS= \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
LIBRARY_NAME=baseembed_s
|
||||||
|
|
||||||
|
CPP_OBJS= \
|
||||||
|
.\$(OBJDIR)\nsEmbedAPI.obj \
|
||||||
|
.\$(OBJDIR)\nsSetupRegistry.obj \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
include <$(DEPTH)\config\rules.mak>
|
||||||
|
include <$(DEPTH)\config\config.mak>
|
||||||
|
|
||||||
|
nsDocShell.cpp : nsDocShell.h
|
||||||
|
|
||||||
|
install:: $(LIBRARY)
|
||||||
|
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
|
@ -0,0 +1,125 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public
|
||||||
|
* License Version 1.1 (the "License"); you may not use this file
|
||||||
|
* except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS
|
||||||
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Mozilla browser.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Netscape
|
||||||
|
* Communications, Inc. Portions created by Netscape are
|
||||||
|
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Author:
|
||||||
|
* Adam Lock <adamlock@netscape.com>
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nsIServiceManager.h"
|
||||||
|
#include "nsILocalFile.h"
|
||||||
|
#include "nsIEventQueueService.h"
|
||||||
|
|
||||||
|
static nsIServiceManager *sServiceManager = nsnull;
|
||||||
|
static PRBool sRegistryInitializedFlag = PR_FALSE;
|
||||||
|
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
|
||||||
|
static PRBool sXPCOMInitializedFlag = PR_FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern "C" void NS_SetupRegistry();
|
||||||
|
|
||||||
|
NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||||
|
|
||||||
|
nsresult NS_InitEmbedding(const char *aPath)
|
||||||
|
{
|
||||||
|
// Initialise XPCOM
|
||||||
|
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
|
||||||
|
// Can't call NS_InitXPCom more than once or things go boom!
|
||||||
|
if (!sXPCOMInitializedFlag)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// Create an object to represent the path
|
||||||
|
nsILocalFile *pBinDirPath = nsnull;
|
||||||
|
if (aPath && strlen(aPath) > 0)
|
||||||
|
{
|
||||||
|
NS_NewLocalFile(aPath, &pBinDirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialise XPCOM
|
||||||
|
if (pBinDirPath)
|
||||||
|
{
|
||||||
|
NS_InitXPCOM(&sServiceManager, pBinDirPath);
|
||||||
|
NS_RELEASE(pBinDirPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NS_InitXPCOM(&sServiceManager, nsnull);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
|
||||||
|
sXPCOMInitializedFlag = PR_TRUE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
// Register components
|
||||||
|
if (!sRegistryInitializedFlag)
|
||||||
|
{
|
||||||
|
NS_SetupRegistry();
|
||||||
|
|
||||||
|
rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */);
|
||||||
|
if (NS_OK != rv)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(PR_FALSE, "Could not AutoRegister");
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
sRegistryInitializedFlag = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the Event Queue for the UI thread...
|
||||||
|
//
|
||||||
|
// If an event queue already exists for the thread, then
|
||||||
|
// CreateThreadEventQueue(...) will fail...
|
||||||
|
|
||||||
|
nsIEventQueueService* eventQService = NULL;
|
||||||
|
rv = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||||
|
NS_GET_IID(nsIEventQueueService),
|
||||||
|
(nsISupports **)&eventQService);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
{
|
||||||
|
rv = eventQService->CreateThreadEventQueue();
|
||||||
|
nsServiceManager::ReleaseService(kEventQueueServiceCID, eventQService);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult NS_TermEmbedding()
|
||||||
|
{
|
||||||
|
// Destroy the event queue
|
||||||
|
nsIEventQueueService* eventQService = NULL;
|
||||||
|
nsresult rv = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||||
|
NS_GET_IID(nsIEventQueueService),
|
||||||
|
(nsISupports **)&eventQService);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
{
|
||||||
|
rv = eventQService->DestroyThreadEventQueue();
|
||||||
|
nsServiceManager::ReleaseService(kEventQueueServiceCID, eventQService);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Terminate XPCOM & cleanup
|
||||||
|
#ifndef HACK_AROUND_NONREENTRANT_INITXPCOM
|
||||||
|
NS_ShutdownXPCOM(sServiceManager);
|
||||||
|
#endif
|
||||||
|
sServiceManager = nsnull;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Netscape Public
|
||||||
|
* License Version 1.1 (the "License"); you may not use this file
|
||||||
|
* except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/NPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS
|
||||||
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Mozilla Communicator client code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Netscape Communications
|
||||||
|
* Corporation. Portions created by Netscape are
|
||||||
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||||
|
* Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This evil file will go away when the XPCOM registry can be
|
||||||
|
* externally initialized!
|
||||||
|
*
|
||||||
|
* Until then, include the real file to keep everything in sync.
|
||||||
|
*/
|
||||||
|
#include "../../xpfe/bootstrap/nsSetupRegistry.cpp"
|
Загрузка…
Ссылка в новой задаче