Allows registry buffer size to be modified.  Increases buffer size during
initial start up, then decreases size.

r=rayw
This commit is contained in:
kandrot%netscape.com 2000-09-08 01:51:45 +00:00
parent 4262a79a1f
commit e89ce829b0
6 changed files with 169 additions and 9 deletions

View File

@ -20,7 +20,7 @@
* Contributor(s):
*/
#include "nsIRegistry.h"
#include "nsRegistry.h"
#include "nsIEnumerator.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
@ -71,7 +71,8 @@ PRUnichar widestrFormat[] = { PRUnichar('%'),PRUnichar('s'),PRUnichar(0)};
#include "nsRegistry.h"
/*
struct nsRegistry : public nsIRegistry {
// This class implements the nsISupports interface functions.
NS_DECL_ISUPPORTS
@ -93,7 +94,7 @@ protected:
NS_IMETHOD Close();
}; // nsRegistry
*/
#include "nsIFactory.h"
/*----------------------------- nsRegistryFactory ------------------------------
@ -1538,6 +1539,21 @@ NS_IMETHODIMP nsRegistry::UnescapeKey(PRUint8* escaped, PRUint32 termination, PR
return rv;
}
/*-------------- nsRegistry::SetBufferSize-------------------------------------
| Sets the size of the file used for the registry's buffer size. |
------------------------------------------------------------------------------*/
int nsRegistry::SetBufferSize( int bufsize )
{
int newSize;
// set the file buffer size
PR_Lock(mregLock);
newSize = NR_RegSetBufferSize( mReg, bufsize );
PR_Unlock(mregLock);
return newSize;
}
/*-------------- nsRegSubtreeEnumerator::nsRegSubtreeEnumerator ----------------
| The ctor simply stashes all the information that will be needed to enumerate |
| the subkeys. |

View File

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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.org 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):
* Edward Kandrot <kandrot@netscape.com>
*/
#ifndef nsRegistry_h__
#define nsRegistry_h__
#include "nsIRegistry.h"
#include "NSReg.h"
struct nsRegistry : public nsIRegistry {
// This class implements the nsISupports interface functions.
NS_DECL_ISUPPORTS
// This class implements the nsIRegistry interface functions.
NS_DECL_NSIREGISTRY
// ctor/dtor
nsRegistry();
virtual ~nsRegistry();
int SetBufferSize( int bufsize ); // changes the file buffer size for this registry
protected:
HREG mReg; // Registry handle.
#ifdef EXTRA_THREADSAFE
PRLock *mregLock; // libreg isn't threadsafe. Use locks to synchronize.
#endif
char *mCurRegFile; // these are to prevent open from opening the registry again
nsWellKnownRegistry mCurRegID;
NS_IMETHOD Close();
}; // nsRegistry
#endif

View File

@ -79,6 +79,8 @@
#include <Path.h>
#endif
#include "nsRegistry.h"
// Logging of debug output
#define FORCE_PR_LOG /* Allow logging in the release build */
#include "prlog.h"
@ -803,6 +805,9 @@ nsresult nsComponentManagerImpl::PlatformPrePopulateRegistry()
if (mPrePopulationDone)
return NS_OK;
(void)mRegistry->SetBufferSize( 500*1024 );
// Read in all CID entries and populate the mFactories
nsCOMPtr<nsIEnumerator> cidEnum;
rv = mRegistry->EnumerateSubtrees( mCLSIDKey, getter_AddRefs(cidEnum));
@ -899,6 +904,8 @@ nsresult nsComponentManagerImpl::PlatformPrePopulateRegistry()
// printf("Populating [ %s, %s ]\n", cidString, progidString);
}
(void)mRegistry->SetBufferSize( 10*1024 );
mPrePopulationDone = PR_TRUE;
return NS_OK;
}
@ -1936,6 +1943,14 @@ RegisterDeferred_enumerate(nsHashKey *key, void *aData, void *aClosure)
nsresult
nsComponentManagerImpl::AutoRegister(PRInt32 when, nsIFile *inDirSpec)
{
mRegistry->SetBufferSize( 500*1024 );
AutoRegisterImpl(when, inDirSpec);
mRegistry->SetBufferSize( 10*1024 );
}
nsresult
nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec)
{
nsCOMPtr<nsIFile> dir;
nsresult rv;
@ -2056,7 +2071,7 @@ nsComponentManagerImpl::AutoRegister(PRInt32 when, nsIFile *inDirSpec)
NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).GetUnicode(),
NS_ConvertASCIItoUCS2("Component registration finished").GetUnicode());
}
return rv;
}

View File

@ -27,7 +27,7 @@
#include "nsNativeComponentLoader.h"
#include "nsIComponentManager.h"
#include "nsIFactory.h"
#include "nsIRegistry.h"
#include "nsRegistry.h"
#include "nsIInterfaceRequestor.h"
#include "nsHashtable.h"
#include "prtime.h"
@ -104,12 +104,15 @@ protected:
nsresult PlatformProgIDToCLSID(const char *aProgID, nsCID *aClass);
nsresult PlatformCLSIDToProgID(const nsCID *aClass, char* *aClassName, char* *aProgID);
private:
nsresult AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec);
protected:
nsObjectHashtable* mFactories;
nsObjectHashtable* mProgIDs;
nsSupportsHashtable* mLoaders;
PRMonitor* mMon;
nsIRegistry* mRegistry;
nsRegistry* mRegistry;
nsRegistryKey mXPCOMKey;
nsRegistryKey mClassesKey;
nsRegistryKey mCLSIDKey;

View File

@ -20,7 +20,7 @@
* Contributor(s):
*/
#include "nsIRegistry.h"
#include "nsRegistry.h"
#include "nsIEnumerator.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
@ -71,7 +71,8 @@ PRUnichar widestrFormat[] = { PRUnichar('%'),PRUnichar('s'),PRUnichar(0)};
#include "nsRegistry.h"
/*
struct nsRegistry : public nsIRegistry {
// This class implements the nsISupports interface functions.
NS_DECL_ISUPPORTS
@ -93,7 +94,7 @@ protected:
NS_IMETHOD Close();
}; // nsRegistry
*/
#include "nsIFactory.h"
/*----------------------------- nsRegistryFactory ------------------------------
@ -1538,6 +1539,21 @@ NS_IMETHODIMP nsRegistry::UnescapeKey(PRUint8* escaped, PRUint32 termination, PR
return rv;
}
/*-------------- nsRegistry::SetBufferSize-------------------------------------
| Sets the size of the file used for the registry's buffer size. |
------------------------------------------------------------------------------*/
int nsRegistry::SetBufferSize( int bufsize )
{
int newSize;
// set the file buffer size
PR_Lock(mregLock);
newSize = NR_RegSetBufferSize( mReg, bufsize );
PR_Unlock(mregLock);
return newSize;
}
/*-------------- nsRegSubtreeEnumerator::nsRegSubtreeEnumerator ----------------
| The ctor simply stashes all the information that will be needed to enumerate |
| the subkeys. |

View File

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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.org 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):
* Edward Kandrot <kandrot@netscape.com>
*/
#ifndef nsRegistry_h__
#define nsRegistry_h__
#include "nsIRegistry.h"
#include "NSReg.h"
struct nsRegistry : public nsIRegistry {
// This class implements the nsISupports interface functions.
NS_DECL_ISUPPORTS
// This class implements the nsIRegistry interface functions.
NS_DECL_NSIREGISTRY
// ctor/dtor
nsRegistry();
virtual ~nsRegistry();
int SetBufferSize( int bufsize ); // changes the file buffer size for this registry
protected:
HREG mReg; // Registry handle.
#ifdef EXTRA_THREADSAFE
PRLock *mregLock; // libreg isn't threadsafe. Use locks to synchronize.
#endif
char *mCurRegFile; // these are to prevent open from opening the registry again
nsWellKnownRegistry mCurRegID;
NS_IMETHOD Close();
}; // nsRegistry
#endif