Loading startupcache/StartupCache.cpp +27 −8 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ StartupCache::Init() // This allows to override the startup cache filename // which is useful from xpcshell, when there is no ProfLDS directory to keep cache in. char *env = PR_GetEnv("MOZ_STARTUP_CACHE"); if (env && *env) { if (env) { rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(mFile)); } else { nsCOMPtr<nsIFile> file; Loading Loading @@ -595,13 +595,6 @@ StartupCache::ResetStartupWriteTimer() return NS_OK; } bool StartupCache::StartupWriteComplete() { WaitOnWriteThread(); return mStartupWriteInitiated && mTable.Count() == 0; } // StartupCacheDebugOutputStream implementation #ifdef DEBUG NS_IMPL_ISUPPORTS(StartupCacheDebugOutputStream, nsIObjectOutputStream, Loading Loading @@ -744,6 +737,13 @@ StartupCacheWrapper::InvalidateCache() return NS_OK; } nsresult StartupCacheWrapper::IgnoreDiskCache() { StartupCache::IgnoreDiskCache(); return NS_OK; } nsresult StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream, nsIObjectOutputStream** outStream) Loading @@ -755,6 +755,25 @@ StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream, return sc->GetDebugObjectOutputStream(stream, outStream); } nsresult StartupCacheWrapper::StartupWriteComplete(bool *complete) { StartupCache* sc = StartupCache::GetSingleton(); if (!sc) { return NS_ERROR_NOT_INITIALIZED; } sc->WaitOnWriteThread(); *complete = sc->mStartupWriteInitiated && sc->mTable.Count() == 0; return NS_OK; } nsresult StartupCacheWrapper::ResetStartupWriteTimer() { StartupCache* sc = StartupCache::GetSingleton(); return sc ? sc->ResetStartupWriteTimer() : NS_ERROR_NOT_INITIALIZED; } nsresult StartupCacheWrapper::GetObserver(nsIObserver** obv) { StartupCache* sc = StartupCache::GetSingleton(); Loading startupcache/StartupCache.h +1 −3 Original line number Diff line number Diff line Loading @@ -138,9 +138,6 @@ public: size_t SizeOfMapping(); // FOR TESTING ONLY nsresult ResetStartupWriteTimer(); bool StartupWriteComplete(); private: StartupCache(); virtual ~StartupCache(); Loading @@ -148,6 +145,7 @@ private: nsresult LoadArchive(); nsresult Init(); void WriteToDisk(); nsresult ResetStartupWriteTimer(); void WaitOnWriteThread(); static nsresult InitSingleton(); Loading startupcache/StartupCacheUtils.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ namespace mozilla { namespace scache { nsresult NS_EXPORT nsresult NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, nsIObjectInputStream** stream) { Loading @@ -37,7 +37,7 @@ NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, return NS_OK; } nsresult NS_EXPORT nsresult NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, nsIStorageStream** stream, bool wantDebugStream) Loading Loading @@ -74,7 +74,7 @@ NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, return NS_OK; } nsresult NS_EXPORT nsresult NewBufferFromStorageStream(nsIStorageStream *storageStream, UniquePtr<char[]>* buffer, uint32_t* len) { Loading Loading @@ -170,7 +170,7 @@ canonicalizeBase(nsAutoCString &spec, * jar:file://$PROFILE_DIR/extensions/some.xpi!/components/component.js becomes * jsloader/$PROFILE_DIR/extensions/some.xpi/components/component.js */ nsresult NS_EXPORT nsresult PathifyURI(nsIURI *in, nsACString &out) { bool equals; Loading startupcache/StartupCacheUtils.h +4 −7 Original line number Diff line number Diff line Loading @@ -5,18 +5,15 @@ #ifndef nsStartupCacheUtils_h_ #define nsStartupCacheUtils_h_ #include "nsString.h" #include "nsIStorageStream.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" #include "mozilla/UniquePtr.h" class nsIURI; namespace mozilla { namespace scache { nsresult NS_EXPORT nsresult NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, nsIObjectInputStream** stream); Loading @@ -26,7 +23,7 @@ NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, // non-singleton objects are written out multiple times during a serialization. // This could cause them to be deserialized incorrectly (as multiple copies // instead of references). nsresult NS_EXPORT nsresult NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, nsIStorageStream** stream, bool wantDebugStream); Loading @@ -34,11 +31,11 @@ NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, // Creates a buffer for storing the stream into the cache. The buffer is // allocated with 'new []'. After calling this function, the caller would // typically call nsIStartupCache::PutBuffer with the returned buffer. nsresult NS_EXPORT nsresult NewBufferFromStorageStream(nsIStorageStream *storageStream, UniquePtr<char[]>* buffer, uint32_t* len); nsresult NS_EXPORT nsresult PathifyURI(nsIURI *in, nsACString &out); } // namespace scache } // namespace mozilla Loading startupcache/nsIStartupCache.idl +8 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ interface nsIStartupCache : nsISupports void invalidateCache(); void ignoreDiskCache(); /** In debug builds, wraps this object output stream with a stream that will * detect and prevent the write of a multiply-referenced non-singleton object Loading @@ -47,6 +48,13 @@ interface nsIStartupCache : nsISupports * original stream, unwrapped. */ nsIObjectOutputStream getDebugObjectOutputStream(in nsIObjectOutputStream aStream); /* Allows clients to check whether the one-time writeout after startup * has finished yet, and also to set this variable as needed (so test * code can fire mulitple startup writes if needed). */ boolean startupWriteComplete(); void resetStartupWriteTimer(); /* Allows clients to simulate the behavior of ObserverService. */ readonly attribute nsIObserver observer; }; Loading Loading
startupcache/StartupCache.cpp +27 −8 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ StartupCache::Init() // This allows to override the startup cache filename // which is useful from xpcshell, when there is no ProfLDS directory to keep cache in. char *env = PR_GetEnv("MOZ_STARTUP_CACHE"); if (env && *env) { if (env) { rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(mFile)); } else { nsCOMPtr<nsIFile> file; Loading Loading @@ -595,13 +595,6 @@ StartupCache::ResetStartupWriteTimer() return NS_OK; } bool StartupCache::StartupWriteComplete() { WaitOnWriteThread(); return mStartupWriteInitiated && mTable.Count() == 0; } // StartupCacheDebugOutputStream implementation #ifdef DEBUG NS_IMPL_ISUPPORTS(StartupCacheDebugOutputStream, nsIObjectOutputStream, Loading Loading @@ -744,6 +737,13 @@ StartupCacheWrapper::InvalidateCache() return NS_OK; } nsresult StartupCacheWrapper::IgnoreDiskCache() { StartupCache::IgnoreDiskCache(); return NS_OK; } nsresult StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream, nsIObjectOutputStream** outStream) Loading @@ -755,6 +755,25 @@ StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream, return sc->GetDebugObjectOutputStream(stream, outStream); } nsresult StartupCacheWrapper::StartupWriteComplete(bool *complete) { StartupCache* sc = StartupCache::GetSingleton(); if (!sc) { return NS_ERROR_NOT_INITIALIZED; } sc->WaitOnWriteThread(); *complete = sc->mStartupWriteInitiated && sc->mTable.Count() == 0; return NS_OK; } nsresult StartupCacheWrapper::ResetStartupWriteTimer() { StartupCache* sc = StartupCache::GetSingleton(); return sc ? sc->ResetStartupWriteTimer() : NS_ERROR_NOT_INITIALIZED; } nsresult StartupCacheWrapper::GetObserver(nsIObserver** obv) { StartupCache* sc = StartupCache::GetSingleton(); Loading
startupcache/StartupCache.h +1 −3 Original line number Diff line number Diff line Loading @@ -138,9 +138,6 @@ public: size_t SizeOfMapping(); // FOR TESTING ONLY nsresult ResetStartupWriteTimer(); bool StartupWriteComplete(); private: StartupCache(); virtual ~StartupCache(); Loading @@ -148,6 +145,7 @@ private: nsresult LoadArchive(); nsresult Init(); void WriteToDisk(); nsresult ResetStartupWriteTimer(); void WaitOnWriteThread(); static nsresult InitSingleton(); Loading
startupcache/StartupCacheUtils.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ namespace mozilla { namespace scache { nsresult NS_EXPORT nsresult NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, nsIObjectInputStream** stream) { Loading @@ -37,7 +37,7 @@ NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, return NS_OK; } nsresult NS_EXPORT nsresult NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, nsIStorageStream** stream, bool wantDebugStream) Loading Loading @@ -74,7 +74,7 @@ NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, return NS_OK; } nsresult NS_EXPORT nsresult NewBufferFromStorageStream(nsIStorageStream *storageStream, UniquePtr<char[]>* buffer, uint32_t* len) { Loading Loading @@ -170,7 +170,7 @@ canonicalizeBase(nsAutoCString &spec, * jar:file://$PROFILE_DIR/extensions/some.xpi!/components/component.js becomes * jsloader/$PROFILE_DIR/extensions/some.xpi/components/component.js */ nsresult NS_EXPORT nsresult PathifyURI(nsIURI *in, nsACString &out) { bool equals; Loading
startupcache/StartupCacheUtils.h +4 −7 Original line number Diff line number Diff line Loading @@ -5,18 +5,15 @@ #ifndef nsStartupCacheUtils_h_ #define nsStartupCacheUtils_h_ #include "nsString.h" #include "nsIStorageStream.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" #include "mozilla/UniquePtr.h" class nsIURI; namespace mozilla { namespace scache { nsresult NS_EXPORT nsresult NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, nsIObjectInputStream** stream); Loading @@ -26,7 +23,7 @@ NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, // non-singleton objects are written out multiple times during a serialization. // This could cause them to be deserialized incorrectly (as multiple copies // instead of references). nsresult NS_EXPORT nsresult NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, nsIStorageStream** stream, bool wantDebugStream); Loading @@ -34,11 +31,11 @@ NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, // Creates a buffer for storing the stream into the cache. The buffer is // allocated with 'new []'. After calling this function, the caller would // typically call nsIStartupCache::PutBuffer with the returned buffer. nsresult NS_EXPORT nsresult NewBufferFromStorageStream(nsIStorageStream *storageStream, UniquePtr<char[]>* buffer, uint32_t* len); nsresult NS_EXPORT nsresult PathifyURI(nsIURI *in, nsACString &out); } // namespace scache } // namespace mozilla Loading
startupcache/nsIStartupCache.idl +8 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ interface nsIStartupCache : nsISupports void invalidateCache(); void ignoreDiskCache(); /** In debug builds, wraps this object output stream with a stream that will * detect and prevent the write of a multiply-referenced non-singleton object Loading @@ -47,6 +48,13 @@ interface nsIStartupCache : nsISupports * original stream, unwrapped. */ nsIObjectOutputStream getDebugObjectOutputStream(in nsIObjectOutputStream aStream); /* Allows clients to check whether the one-time writeout after startup * has finished yet, and also to set this variable as needed (so test * code can fire mulitple startup writes if needed). */ boolean startupWriteComplete(); void resetStartupWriteTimer(); /* Allows clients to simulate the behavior of ObserverService. */ readonly attribute nsIObserver observer; }; Loading