From 8d3adbc69bdb313b420d8cc20dfdf1aa4facfd4f Mon Sep 17 00:00:00 2001 From: "dprice%netscape.com" Date: Wed, 2 May 2001 22:11:51 +0000 Subject: [PATCH] merging in rick's changes, sliders hooked up properly, new option to load the awt.dll and a new UI to tell where the preloader is finding .dlls. git-svn-id: svn://10.0.0.236/trunk@93676 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/tools/preloader/preloader.cpp | 388 +++++++++++++++++++------- mozilla/tools/preloader/resrc1.h | 9 +- 2 files changed, 291 insertions(+), 106 deletions(-) diff --git a/mozilla/tools/preloader/preloader.cpp b/mozilla/tools/preloader/preloader.cpp index 517ae393859..30c03b3e6d3 100644 --- a/mozilla/tools/preloader/preloader.cpp +++ b/mozilla/tools/preloader/preloader.cpp @@ -54,9 +54,9 @@ rickg 04.24.01 added code to get/set "tuning" settings from registry rickg 04.24.01 added accelerators to menu, and changed tooltip rickg 04.24.01 moved more strings to resource file - rickg 04.24.01 hooked up "tuning" config settings for modulepercent and gFrequencyPercent - - NOTE: I've not hooked up the gEntryPercent setting. + rickg 04.24.01 hooked up "tuning" config settings for gModulePercent and gFrequencyPercent + rickg 04.27.01 hooked up "tuning" config settings for gEntryPercent + rickg 04.27.01 added a new config setting that specifies which browser instance to preload ****************************************************************************/ @@ -145,12 +145,14 @@ static bool gUseFullModuleList = false; //this enum distinguishes version of netscape (and mozilla). -enum eAppVersion {eNetscape65, eNetscape60, eMozilla, eNetscapePre60, eUserPath,eUnknown}; +enum eAppVersion {eNetscape65, eNetscape60, eMozilla, eNetscapePre60, eUserPath,eUnknownVersion,eAutoDetect}; +static eAppVersion gAppVersion=eNetscape65; //Constants for my DLL loader to use... static char gMozPath[2048]= {0}; static char gUserPath[2048]= {0}; +static int gPreloadJava = 1; static char gMozModuleList[4096] = {0}; static char* gModuleCP = gMozModuleList; @@ -289,6 +291,7 @@ int Get65ModuleList(char *&aModuleList) { "components\\gkplugin;" \ "components\\gkview;" \ "gkwidget;" \ + "gfx2;" \ "components\\jar50;" \ "components\\lwbrk;" \ "components\\necko;" \ @@ -403,7 +406,7 @@ void GetPathFromRegistry(eAppVersion aVersion, const char *&aKey, const char *&a break; - case eUnknown: + case eUnknownVersion: break; } } @@ -411,21 +414,21 @@ void GetPathFromRegistry(eAppVersion aVersion, const char *&aKey, const char *&a /********************************************************* Get the path to the netscape6 browser via the registry... *********************************************************/ -void GetMozillaRegistryInfo(eAppVersion aVersion) { +bool GetMozillaRegistryInfo(eAppVersion &aVersion) { //first we try to get the registry info based on the command line settings. //if that fails, we try others. + bool found=false; LONG theOpenResult = 1; //any non-zero will do to initialize this... - while(ERROR_SUCCESS!=theOpenResult) { + while((ERROR_SUCCESS!=theOpenResult) && (aVersiongMaxEntryIndex) + gMaxEntryIndex=theEntryCount; //we track the highest index we find. + } + + return theInstance; +} /**************************************************************** Call this once for each module you want to preload. + We use gEntryPercent to determine what percentage of entry + p oints to acquire (we will always get at least 1, and we'll + skip at most 20 entry points at a time). ****************************************************************/ HINSTANCE LoadModule(const char* aName) { - //gModulePercent - //we operate on gMozPath directly to avoid an unnecessary string copy. //when we're done with this method, we reset gMozpath to it's original value for reuse. strcat(gMozPath,aName); strcat(gMozPath,".dll"); - gFuncTable[gDLLCount][0]=0; //make sure the table looks empty by default. - - HINSTANCE theInstance=gInstances[gDLLCount++]=LoadLibrary(gMozPath); - - int theEntryCount=0; - - if(theInstance) { - //let's get addresses throughout the module, skipping over every 20. - for(int theEntryPoint=0;theEntryPoint<64;theEntryPoint++){ - long *entry=(long*)::GetProcAddress(theInstance,MAKEINTRESOURCE(1+(20*theEntryPoint))); - if(entry) { - gFuncTable[gDLLCount-1][theEntryCount++]=entry; - gFuncTable[gDLLCount][theEntryCount]=0; //always add a null to the end - } - } - } + HINSTANCE theInstance = LoadModuleFromPath(gMozPath); gMozPath[gMozPathLen]=0; return theInstance; @@ -555,17 +578,28 @@ BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam ) { /**************************************************************** Call this to detect whether the browser is running. + We cache the result to speed up this function (by preventing + subsuquent searches of top level windows). ****************************************************************/ bool BrowserIsRunning() { - if(!EnumWindows(EnumWindowsProc,0)) { - return true; + static bool gBrowserIsRunning=false; + + if(!gBrowserIsRunning) { + if(!EnumWindows(EnumWindowsProc,0)) { + gBrowserIsRunning=true; + } } - return false; + + return gBrowserIsRunning; } /**************************************************************** This function get's called repeatedly to call on a timer, and it calls GetProcAddr() to keep modules from paging. + + NOTE: This method uses gFrequencyPercent to determine how much + work to do each time it gets called. + ****************************************************************/ VOID CALLBACK KeepAliveTimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime ) { @@ -583,27 +617,51 @@ VOID CALLBACK KeepAliveTimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTim if(!theTimerIsRunning) { //ignore other timer calls till we're done. theTimerIsRunning=true; - const int modulesPerStep=40; //how many modules to "touch" each time... + //constrain the step to 1..gDLLCount + static const double kPercent=gFrequencyPercent/100.0; + static const int kMaxSteps=1+int(3*gDLLCount*kPercent); - int theCount=0; + int count=0; - for(int theSteps=0;theSteps=gDLLCount) { - theCurrentModule=0; //loop back around to top of module list... - theCurrentProc++; - if(theCurrentProc>=gMaxProcIndex){ - theCurrentProc=0; //reset this too! + int x=10; } } +#define _DEPTH_FIRST +#ifdef _DEPTH_FIRST + + if(theCurrentModule >= gDLLCount) { + theCurrentModule = 0; + theCurrentProc = (theCurrentProc>=gMaxEntryIndex) ? 0 : theCurrentProc+1; + } + else { + theCurrentModule++; + } + +#else //breadth first... + + if(theCurrentProc >= gMaxEntryIndex) { + theCurrentProc=0; + theCurrentModule = (theCurrentModule>=gDLLCount) ? 0 : theCurrentModule+1; + } + else { + theCurrentProc++; + } + +#endif + } theTimerIsRunning=false; @@ -631,38 +689,93 @@ VOID CALLBACK LoadModuleTimerProc(HWND hwnd, UINT uMsg, UINT idEvent,DWORD dwTim //gModuleCount is the total number of modules we know about //gModulePercent is the total % of modules we're being asked to load (config setting) - if(gDLLCount/gModuleCount