2016-01-28 03:04:59 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
#include "nsXULPrototypeCache.h"
|
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
#include "plstr.h"
|
|
|
|
#include "nsXULPrototypeDocument.h"
|
|
|
|
#include "nsIServiceManager.h"
|
1999-10-29 05:21:15 +04:00
|
|
|
#include "nsIURI.h"
|
|
|
|
|
2003-05-22 08:09:34 +04:00
|
|
|
#include "nsIChromeRegistry.h"
|
2002-05-03 07:04:34 +04:00
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsIObjectInputStream.h"
|
|
|
|
#include "nsIObjectOutputStream.h"
|
2004-03-09 22:59:09 +03:00
|
|
|
#include "nsIObserverService.h"
|
2010-08-12 23:42:36 +04:00
|
|
|
#include "nsIStringStream.h"
|
|
|
|
#include "nsIStorageStream.h"
|
2002-05-03 07:04:34 +04:00
|
|
|
|
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
#include "js/TracingAPI.h"
|
2006-09-06 02:53:47 +04:00
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheetInlines.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2010-08-12 23:42:36 +04:00
|
|
|
#include "mozilla/scache/StartupCache.h"
|
|
|
|
#include "mozilla/scache/StartupCacheUtils.h"
|
2013-04-12 18:41:02 +04:00
|
|
|
#include "mozilla/Telemetry.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2010-08-12 23:42:36 +04:00
|
|
|
using namespace mozilla::scache;
|
2011-05-25 10:31:59 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gDisableXULCache = false; // enabled by default
|
2001-02-22 06:01:34 +03:00
|
|
|
static const char kDisableXULCachePref[] = "nglayout.debug.disable_xul_cache";
|
2010-08-12 23:42:36 +04:00
|
|
|
static const char kXULCacheInfoKey[] = "nsXULPrototypeCache.startupCache";
|
|
|
|
static const char kXULCachePrefix[] = "xulcache";
|
2001-02-22 06:01:34 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-04-12 18:41:02 +04:00
|
|
|
static void
|
|
|
|
UpdategDisableXULCache()
|
2001-02-22 06:01:34 +03:00
|
|
|
{
|
2013-04-12 18:41:02 +04:00
|
|
|
// Get the value of "nglayout.debug.disable_xul_cache" preference
|
2004-04-30 03:34:19 +04:00
|
|
|
gDisableXULCache =
|
2011-05-25 10:31:59 +04:00
|
|
|
Preferences::GetBool(kDisableXULCachePref, gDisableXULCache);
|
2001-02-22 06:01:34 +03:00
|
|
|
|
2013-04-12 18:41:02 +04:00
|
|
|
// Sets the flag if the XUL cache is disabled
|
|
|
|
if (gDisableXULCache) {
|
|
|
|
Telemetry::Accumulate(Telemetry::XUL_CACHE_DISABLED, true);
|
|
|
|
}
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2013-04-12 18:41:02 +04:00
|
|
|
}
|
|
|
|
|
2013-12-11 03:10:01 +04:00
|
|
|
static void
|
2013-04-12 18:41:02 +04:00
|
|
|
DisableXULCacheChangedCallback(const char* aPref, void* aClosure)
|
|
|
|
{
|
2015-06-17 02:45:29 +03:00
|
|
|
bool wasEnabled = !gDisableXULCache;
|
2013-04-12 18:41:02 +04:00
|
|
|
UpdategDisableXULCache();
|
|
|
|
|
2015-06-17 02:45:29 +03:00
|
|
|
if (wasEnabled && gDisableXULCache) {
|
|
|
|
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
|
|
|
if (cache) {
|
|
|
|
// AbortCaching() calls Flush() for us.
|
|
|
|
cache->AbortCaching();
|
|
|
|
}
|
|
|
|
}
|
2001-02-22 06:01:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsXULPrototypeCache* nsXULPrototypeCache::sInstance = nullptr;
|
2007-03-12 08:53:33 +03:00
|
|
|
|
2002-05-03 07:04:34 +04:00
|
|
|
|
1999-10-29 05:21:15 +04:00
|
|
|
nsXULPrototypeCache::nsXULPrototypeCache()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsXULPrototypeCache::~nsXULPrototypeCache()
|
|
|
|
{
|
2001-07-31 23:05:34 +04:00
|
|
|
FlushScripts();
|
1999-10-29 05:21:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsXULPrototypeCache, nsIObserver)
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
/* static */ nsXULPrototypeCache*
|
|
|
|
nsXULPrototypeCache::GetInstance()
|
|
|
|
{
|
|
|
|
if (!sInstance) {
|
2011-08-26 23:50:23 +04:00
|
|
|
NS_ADDREF(sInstance = new nsXULPrototypeCache());
|
|
|
|
|
2013-04-12 18:41:02 +04:00
|
|
|
UpdategDisableXULCache();
|
|
|
|
|
2011-08-26 23:50:23 +04:00
|
|
|
Preferences::RegisterCallback(DisableXULCacheChangedCallback,
|
|
|
|
kDisableXULCachePref);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsSvc) {
|
|
|
|
nsXULPrototypeCache *p = sInstance;
|
2011-10-17 18:59:28 +04:00
|
|
|
obsSvc->AddObserver(p, "chrome-flush-skin-caches", false);
|
|
|
|
obsSvc->AddObserver(p, "chrome-flush-caches", false);
|
2016-02-14 17:59:48 +03:00
|
|
|
obsSvc->AddObserver(p, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
2011-10-17 18:59:28 +04:00
|
|
|
obsSvc->AddObserver(p, "startupcache-invalidate", false);
|
2011-08-26 23:50:23 +04:00
|
|
|
}
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
}
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
1999-11-02 04:14:07 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2004-03-09 22:59:09 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULPrototypeCache::Observe(nsISupports* aSubject,
|
|
|
|
const char *aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aData)
|
2004-03-09 22:59:09 +03:00
|
|
|
{
|
|
|
|
if (!strcmp(aTopic, "chrome-flush-skin-caches")) {
|
|
|
|
FlushSkinFiles();
|
|
|
|
}
|
2016-02-14 17:59:48 +03:00
|
|
|
else if (!strcmp(aTopic, "chrome-flush-caches") ||
|
|
|
|
!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
2004-03-09 22:59:09 +03:00
|
|
|
Flush();
|
|
|
|
}
|
2010-09-15 04:39:07 +04:00
|
|
|
else if (!strcmp(aTopic, "startupcache-invalidate")) {
|
2010-08-12 23:42:36 +04:00
|
|
|
AbortCaching();
|
2010-09-15 04:39:07 +04:00
|
|
|
}
|
2004-03-09 22:59:09 +03:00
|
|
|
else {
|
|
|
|
NS_WARNING("Unexpected observer topic.");
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsXULPrototypeDocument*
|
2006-12-22 19:11:16 +03:00
|
|
|
nsXULPrototypeCache::GetPrototype(nsIURI* aURI)
|
|
|
|
{
|
2014-09-16 16:57:45 +04:00
|
|
|
if (!aURI)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uriWithoutRef;
|
|
|
|
aURI->CloneIgnoringRef(getter_AddRefs(uriWithoutRef));
|
|
|
|
|
|
|
|
nsXULPrototypeDocument* protoDoc = mPrototypeTable.GetWeak(uriWithoutRef);
|
2010-08-12 23:42:36 +04:00
|
|
|
if (protoDoc)
|
|
|
|
return protoDoc;
|
1999-11-02 04:14:07 +03:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsresult rv = BeginCaching(aURI);
|
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-08-12 23:42:36 +04:00
|
|
|
|
|
|
|
// No prototype in XUL memory cache. Spin up the cache Service.
|
|
|
|
nsCOMPtr<nsIObjectInputStream> ois;
|
|
|
|
rv = GetInputStream(aURI, getter_AddRefs(ois));
|
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsXULPrototypeDocument> newProto;
|
2010-08-12 23:42:36 +04:00
|
|
|
rv = NS_NewXULPrototypeDocument(getter_AddRefs(newProto));
|
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
rv = newProto->Read(ois);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = PutPrototype(newProto);
|
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
newProto = nullptr;
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
mInputStreamTable.Remove(aURI);
|
|
|
|
return newProto;
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
1999-11-02 04:14:07 +03:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsresult
|
2006-12-22 19:11:16 +03:00
|
|
|
nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument)
|
1999-11-02 04:14:07 +03:00
|
|
|
{
|
2014-09-16 16:57:45 +04:00
|
|
|
if (!aDocument->GetURI()) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
aDocument->GetURI()->CloneIgnoringRef(getter_AddRefs(uri));
|
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
// Put() releases any old value and addrefs the new one
|
2012-05-18 21:30:49 +04:00
|
|
|
mPrototypeTable.Put(uri, aDocument);
|
2001-07-31 23:05:34 +04:00
|
|
|
|
1999-11-25 01:44:52 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsresult
|
2014-06-20 14:32:49 +04:00
|
|
|
nsXULPrototypeCache::PutStyleSheet(CSSStyleSheet* aStyleSheet)
|
1999-10-29 05:21:15 +04:00
|
|
|
{
|
2010-05-18 08:00:40 +04:00
|
|
|
nsIURI* uri = aStyleSheet->GetSheetURI();
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2012-05-18 21:30:49 +04:00
|
|
|
mStyleSheetTable.Put(uri, aStyleSheet);
|
2001-07-31 23:05:34 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-05-28 11:30:48 +04:00
|
|
|
}
|
|
|
|
|
2001-07-31 23:05:34 +04:00
|
|
|
|
2011-10-30 00:13:55 +04:00
|
|
|
JSScript*
|
2012-04-25 02:31:28 +04:00
|
|
|
nsXULPrototypeCache::GetScript(nsIURI* aURI)
|
2000-05-28 11:30:48 +04:00
|
|
|
{
|
2013-07-23 13:58:28 +04:00
|
|
|
return mScriptTable.Get(aURI);
|
2001-07-31 23:05:34 +04:00
|
|
|
}
|
2000-05-28 11:30:48 +04:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsresult
|
2013-05-20 16:40:06 +04:00
|
|
|
nsXULPrototypeCache::PutScript(nsIURI* aURI,
|
|
|
|
JS::Handle<JSScript*> aScriptObject)
|
2001-07-31 23:05:34 +04:00
|
|
|
{
|
2013-08-16 01:14:43 +04:00
|
|
|
MOZ_ASSERT(aScriptObject, "Need a non-NULL script");
|
|
|
|
|
2016-02-05 07:43:17 +03:00
|
|
|
#ifdef DEBUG_BUG_392650
|
2013-07-29 21:21:33 +04:00
|
|
|
if (mScriptTable.Get(aURI)) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString scriptName;
|
2012-03-26 23:40:52 +04:00
|
|
|
aURI->GetSpec(scriptName);
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString message("Loaded script ");
|
2012-03-26 23:40:52 +04:00
|
|
|
message += scriptName;
|
|
|
|
message += " twice (bug 392650)";
|
|
|
|
NS_WARNING(message.get());
|
2007-08-21 20:47:48 +04:00
|
|
|
}
|
2013-06-19 02:58:05 +04:00
|
|
|
#endif
|
2007-08-21 20:47:48 +04:00
|
|
|
|
2013-06-19 02:58:05 +04:00
|
|
|
mScriptTable.Put(aURI, aScriptObject);
|
2002-05-04 13:15:04 +04:00
|
|
|
|
2013-03-19 21:20:21 +04:00
|
|
|
return NS_OK;
|
2000-05-28 11:30:48 +04:00
|
|
|
}
|
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsresult
|
2010-07-15 05:53:11 +04:00
|
|
|
nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
|
2001-07-31 23:05:34 +04:00
|
|
|
{
|
2003-11-18 00:03:32 +03:00
|
|
|
nsIURI* uri = aDocumentInfo->DocumentURI();
|
2003-05-22 08:09:34 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsXBLDocumentInfo> info;
|
2003-11-18 00:03:32 +03:00
|
|
|
mXBLDocTable.Get(uri, getter_AddRefs(info));
|
2007-03-12 08:53:33 +03:00
|
|
|
if (!info) {
|
2012-05-18 21:30:49 +04:00
|
|
|
mXBLDocTable.Put(uri, aDocumentInfo);
|
2007-03-12 08:53:33 +03:00
|
|
|
}
|
2000-05-28 11:30:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-03-09 22:59:09 +03:00
|
|
|
void
|
2001-12-18 01:51:39 +03:00
|
|
|
nsXULPrototypeCache::FlushSkinFiles()
|
|
|
|
{
|
|
|
|
// Flush out skin XBL files from the cache.
|
2016-01-28 03:04:59 +03:00
|
|
|
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
nsAutoCString str;
|
|
|
|
iter.Key()->GetPath(str);
|
|
|
|
if (strncmp(str.get(), "/skin", 5) == 0) {
|
|
|
|
iter.Remove();
|
|
|
|
}
|
|
|
|
}
|
2001-12-18 01:51:39 +03:00
|
|
|
|
|
|
|
// Now flush out our skin stylesheets from the cache.
|
2016-01-28 03:04:59 +03:00
|
|
|
for (auto iter = mStyleSheetTable.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
nsAutoCString str;
|
|
|
|
iter.Data()->GetSheetURI()->GetPath(str);
|
|
|
|
if (strncmp(str.get(), "/skin", 5) == 0) {
|
|
|
|
iter.Remove();
|
|
|
|
}
|
|
|
|
}
|
2001-12-18 01:51:39 +03:00
|
|
|
|
2003-05-22 08:09:34 +04:00
|
|
|
// Iterate over all the remaining XBL and make sure cached
|
2001-12-18 01:51:39 +03:00
|
|
|
// scoped skin stylesheets are flushed and refetched by the
|
|
|
|
// prototype bindings.
|
2016-01-28 03:04:59 +03:00
|
|
|
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
iter.Data()->FlushSkinStylesheets();
|
|
|
|
}
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
|
|
|
|
2013-03-19 21:20:21 +04:00
|
|
|
void
|
|
|
|
nsXULPrototypeCache::FlushScripts()
|
|
|
|
{
|
|
|
|
mScriptTable.Clear();
|
|
|
|
}
|
2001-07-31 23:05:34 +04:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
void
|
1999-11-25 01:44:52 +03:00
|
|
|
nsXULPrototypeCache::Flush()
|
|
|
|
{
|
2007-03-12 08:53:33 +03:00
|
|
|
mPrototypeTable.Clear();
|
2013-03-19 21:20:21 +04:00
|
|
|
mScriptTable.Clear();
|
2007-03-12 08:53:33 +03:00
|
|
|
mStyleSheetTable.Clear();
|
|
|
|
mXBLDocTable.Clear();
|
2001-02-22 06:01:34 +03:00
|
|
|
}
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-03-12 08:53:33 +03:00
|
|
|
nsXULPrototypeCache::IsEnabled()
|
2002-05-03 07:04:34 +04:00
|
|
|
{
|
2007-03-12 08:53:33 +03:00
|
|
|
return !gDisableXULCache;
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
void
|
2010-08-12 23:42:36 +04:00
|
|
|
nsXULPrototypeCache::AbortCaching()
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
{
|
2002-05-03 07:04:34 +04:00
|
|
|
#ifdef DEBUG_brendan
|
|
|
|
NS_BREAK();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Flush the XUL cache for good measure, in case we cached a bogus/downrev
|
|
|
|
// script, somehow.
|
|
|
|
Flush();
|
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
// Clear the cache set
|
2015-06-17 02:45:29 +03:00
|
|
|
mStartupCacheURITable.Clear();
|
2011-05-28 11:15:25 +04:00
|
|
|
}
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsresult
|
2006-12-22 19:11:16 +03:00
|
|
|
nsXULPrototypeCache::WritePrototype(nsXULPrototypeDocument* aPrototypeDocument)
|
2002-05-03 07:04:34 +04:00
|
|
|
{
|
2007-03-12 08:53:33 +03:00
|
|
|
nsresult rv = NS_OK, rv2 = NS_OK;
|
2013-04-11 22:32:12 +04:00
|
|
|
|
|
|
|
if (!StartupCache::GetSingleton())
|
|
|
|
return NS_OK;
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
nsCOMPtr<nsIURI> protoURI = aPrototypeDocument->GetURI();
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIObjectOutputStream> oos;
|
|
|
|
rv = GetOutputStream(protoURI, getter_AddRefs(oos));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
rv = aPrototypeDocument->Write(oos);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
FinishOutputStream(protoURI);
|
|
|
|
return NS_FAILED(rv) ? rv : rv2;
|
|
|
|
}
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsresult
|
2015-08-04 23:06:14 +03:00
|
|
|
nsXULPrototypeCache::GetInputStream(nsIURI* uri, nsIObjectInputStream** stream)
|
2010-08-12 23:42:36 +04:00
|
|
|
{
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec(kXULCachePrefix);
|
2011-07-20 11:39:09 +04:00
|
|
|
nsresult rv = PathifyURI(uri, spec);
|
2015-08-04 23:06:14 +03:00
|
|
|
if (NS_FAILED(rv))
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2016-02-18 20:26:28 +03:00
|
|
|
UniquePtr<char[]> buf;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len;
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIObjectInputStream> ois;
|
2013-01-04 01:38:08 +04:00
|
|
|
StartupCache* sc = StartupCache::GetSingleton();
|
|
|
|
if (!sc)
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2013-01-04 01:38:08 +04:00
|
|
|
|
2016-02-18 20:26:28 +03:00
|
|
|
rv = sc->GetBuffer(spec.get(), &buf, &len);
|
2013-01-04 01:38:08 +04:00
|
|
|
if (NS_FAILED(rv))
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2016-02-18 20:26:28 +03:00
|
|
|
rv = NewObjectInputStreamFromBuffer(Move(buf), len, getter_AddRefs(ois));
|
2010-08-12 23:42:36 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
mInputStreamTable.Put(uri, ois);
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2015-03-31 17:03:49 +03:00
|
|
|
ois.forget(stream);
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_OK;
|
2010-08-12 23:42:36 +04:00
|
|
|
}
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsresult
|
|
|
|
nsXULPrototypeCache::FinishInputStream(nsIURI* uri) {
|
|
|
|
mInputStreamTable.Remove(uri);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-05-28 11:15:25 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsresult
|
2010-08-12 23:42:36 +04:00
|
|
|
nsXULPrototypeCache::GetOutputStream(nsIURI* uri, nsIObjectOutputStream** stream)
|
2010-08-12 23:42:36 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIObjectOutputStream> objectOutput;
|
|
|
|
nsCOMPtr<nsIStorageStream> storageStream;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool found = mOutputStreamTable.Get(uri, getter_AddRefs(storageStream));
|
2010-08-12 23:42:36 +04:00
|
|
|
if (found) {
|
|
|
|
objectOutput = do_CreateInstance("mozilla.org/binaryoutputstream;1");
|
|
|
|
if (!objectOutput) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
nsCOMPtr<nsIOutputStream> outputStream
|
|
|
|
= do_QueryInterface(storageStream);
|
|
|
|
objectOutput->SetOutputStream(outputStream);
|
|
|
|
} else {
|
2015-08-04 23:06:14 +03:00
|
|
|
rv = NewObjectOutputWrappedStorageStream(getter_AddRefs(objectOutput),
|
2011-07-20 11:39:09 +04:00
|
|
|
getter_AddRefs(storageStream),
|
|
|
|
false);
|
2010-08-12 23:42:36 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mOutputStreamTable.Put(uri, storageStream);
|
|
|
|
}
|
2015-03-31 17:03:49 +03:00
|
|
|
objectOutput.forget(stream);
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_OK;
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
2003-05-22 08:09:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsresult
|
2015-08-04 23:06:14 +03:00
|
|
|
nsXULPrototypeCache::FinishOutputStream(nsIURI* uri)
|
2002-05-03 07:04:34 +04:00
|
|
|
{
|
2010-08-12 23:42:36 +04:00
|
|
|
nsresult rv;
|
2013-01-04 01:38:08 +04:00
|
|
|
StartupCache* sc = StartupCache::GetSingleton();
|
|
|
|
if (!sc)
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2013-01-04 01:38:08 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIStorageStream> storageStream;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool found = mOutputStreamTable.Get(uri, getter_AddRefs(storageStream));
|
2010-08-12 23:42:36 +04:00
|
|
|
if (!found)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
nsCOMPtr<nsIOutputStream> outputStream
|
|
|
|
= do_QueryInterface(storageStream);
|
|
|
|
outputStream->Close();
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2016-02-18 20:04:40 +03:00
|
|
|
UniquePtr<char[]> buf;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len;
|
2016-02-18 20:04:40 +03:00
|
|
|
rv = NewBufferFromStorageStream(storageStream, &buf, &len);
|
2010-08-12 23:42:36 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2015-06-17 02:45:29 +03:00
|
|
|
if (!mStartupCacheURITable.GetEntry(uri)) {
|
2013-01-04 02:32:11 +04:00
|
|
|
nsAutoCString spec(kXULCachePrefix);
|
|
|
|
rv = PathifyURI(uri, spec);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2016-02-18 20:04:40 +03:00
|
|
|
rv = sc->PutBuffer(spec.get(), buf.get(), len);
|
2013-01-04 02:32:11 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mOutputStreamTable.Remove(uri);
|
2015-06-17 02:45:29 +03:00
|
|
|
mStartupCacheURITable.PutEntry(uri);
|
2013-01-04 02:32:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
return rv;
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
// We have data if we're in the middle of writing it or we already
|
|
|
|
// have it in the cache.
|
|
|
|
nsresult
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXULPrototypeCache::HasData(nsIURI* uri, bool* exists)
|
2011-05-28 11:15:25 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
if (mOutputStreamTable.Get(uri, nullptr)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*exists = true;
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_OK;
|
2011-05-28 11:15:25 +04:00
|
|
|
}
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec(kXULCachePrefix);
|
2011-07-20 11:39:09 +04:00
|
|
|
nsresult rv = PathifyURI(uri, spec);
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*exists = false;
|
2010-08-12 23:42:36 +04:00
|
|
|
return NS_OK;
|
2011-05-28 11:15:25 +04:00
|
|
|
}
|
2016-02-18 20:26:28 +03:00
|
|
|
UniquePtr<char[]> buf;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len;
|
2013-01-04 01:38:08 +04:00
|
|
|
StartupCache* sc = StartupCache::GetSingleton();
|
2016-02-18 20:26:28 +03:00
|
|
|
if (sc) {
|
|
|
|
rv = sc->GetBuffer(spec.get(), &buf, &len);
|
|
|
|
} else {
|
2013-01-04 01:38:08 +04:00
|
|
|
*exists = false;
|
|
|
|
return NS_OK;
|
2011-05-28 11:15:25 +04:00
|
|
|
}
|
2010-08-12 23:42:36 +04:00
|
|
|
*exists = NS_SUCCEEDED(rv);
|
2011-05-28 11:15:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-05-03 07:04:34 +04:00
|
|
|
nsresult
|
2010-08-12 23:42:36 +04:00
|
|
|
nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
|
2002-05-03 07:04:34 +04:00
|
|
|
{
|
2012-07-27 18:03:08 +04:00
|
|
|
nsresult rv, tmp;
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString path;
|
2002-05-03 07:04:34 +04:00
|
|
|
aURI->GetPath(path);
|
2003-07-14 11:37:39 +04:00
|
|
|
if (!StringEndsWith(path, NS_LITERAL_CSTRING(".xul")))
|
2002-05-03 07:04:34 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
StartupCache* startupCache = StartupCache::GetSingleton();
|
|
|
|
if (!startupCache)
|
2002-05-03 07:04:34 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2015-06-17 02:45:29 +03:00
|
|
|
if (gDisableXULCache)
|
2004-04-30 03:34:19 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2002-05-03 07:04:34 +04:00
|
|
|
|
|
|
|
// Get the chrome directory to validate against the one stored in the
|
2010-08-12 23:42:36 +04:00
|
|
|
// cache file, or to store there if we're generating a new file.
|
2002-05-03 07:04:34 +04:00
|
|
|
nsCOMPtr<nsIFile> chromeDir;
|
|
|
|
rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR, getter_AddRefs(chromeDir));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString chromePath;
|
2002-05-08 03:07:19 +04:00
|
|
|
rv = chromeDir->GetNativePath(chromePath);
|
2002-05-03 07:04:34 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2003-05-22 08:09:34 +04:00
|
|
|
// XXXbe we assume the first package's locale is the same as the locale of
|
2010-08-12 23:42:36 +04:00
|
|
|
// all subsequent packages of cached chrome URIs....
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString package;
|
2003-05-22 08:09:34 +04:00
|
|
|
rv = aURI->GetHost(package);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIXULChromeRegistry> chromeReg
|
|
|
|
= do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString locale;
|
2016-10-28 14:04:06 +03:00
|
|
|
rv = chromeReg->GetSelectedLocale(package, false, locale);
|
2003-05-22 08:09:34 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString fileChromePath, fileLocale;
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2016-02-18 20:26:28 +03:00
|
|
|
UniquePtr<char[]> buf;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len, amtRead;
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIObjectInputStream> objectInput;
|
2002-05-03 07:04:34 +04:00
|
|
|
|
2016-02-18 20:26:28 +03:00
|
|
|
rv = startupCache->GetBuffer(kXULCacheInfoKey, &buf, &len);
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_SUCCEEDED(rv))
|
2016-02-18 20:26:28 +03:00
|
|
|
rv = NewObjectInputStreamFromBuffer(Move(buf), len,
|
|
|
|
getter_AddRefs(objectInput));
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = objectInput->ReadCString(fileLocale);
|
2012-07-27 18:03:08 +04:00
|
|
|
tmp = objectInput->ReadCString(fileChromePath);
|
|
|
|
if (NS_FAILED(tmp)) {
|
|
|
|
rv = tmp;
|
|
|
|
}
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_FAILED(rv) ||
|
|
|
|
(!fileChromePath.Equals(chromePath) ||
|
|
|
|
!fileLocale.Equals(locale))) {
|
|
|
|
// Our cache won't be valid in this case, we'll need to rewrite.
|
|
|
|
// XXX This blows away work that other consumers (like
|
|
|
|
// mozJSComponentLoader) have done, need more fine-grained control.
|
|
|
|
startupCache->InvalidateCache();
|
2015-06-17 02:45:29 +03:00
|
|
|
mStartupCacheURITable.Clear();
|
2010-08-12 23:42:36 +04:00
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
2010-08-12 23:42:36 +04:00
|
|
|
}
|
2010-08-12 23:42:36 +04:00
|
|
|
} else if (rv != NS_ERROR_NOT_AVAILABLE)
|
|
|
|
// NS_ERROR_NOT_AVAILABLE is normal, usually if there's no cachefile.
|
|
|
|
return rv;
|
2011-05-28 11:15:25 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Either the cache entry was invalid or it didn't exist, so write it now.
|
2011-05-28 11:15:25 +04:00
|
|
|
nsCOMPtr<nsIObjectOutputStream> objectOutput;
|
2010-08-12 23:42:36 +04:00
|
|
|
nsCOMPtr<nsIInputStream> inputStream;
|
|
|
|
nsCOMPtr<nsIStorageStream> storageStream;
|
2011-07-20 11:39:09 +04:00
|
|
|
rv = NewObjectOutputWrappedStorageStream(getter_AddRefs(objectOutput),
|
|
|
|
getter_AddRefs(storageStream),
|
|
|
|
false);
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2010-08-12 23:42:36 +04:00
|
|
|
rv = objectOutput->WriteStringZ(locale.get());
|
2012-07-27 18:03:08 +04:00
|
|
|
tmp = objectOutput->WriteStringZ(chromePath.get());
|
|
|
|
if (NS_FAILED(tmp)) {
|
|
|
|
rv = tmp;
|
|
|
|
}
|
|
|
|
tmp = objectOutput->Close();
|
|
|
|
if (NS_FAILED(tmp)) {
|
|
|
|
rv = tmp;
|
|
|
|
}
|
|
|
|
tmp = storageStream->NewInputStream(0, getter_AddRefs(inputStream));
|
|
|
|
if (NS_FAILED(tmp)) {
|
|
|
|
rv = tmp;
|
|
|
|
}
|
2010-08-12 23:42:36 +04:00
|
|
|
}
|
2012-08-11 06:44:11 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t len64;
|
2012-08-11 06:44:11 +04:00
|
|
|
rv = inputStream->Available(&len64);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-09-28 10:57:33 +04:00
|
|
|
if (len64 <= UINT32_MAX)
|
2012-08-22 19:56:38 +04:00
|
|
|
len = (uint32_t)len64;
|
2012-08-11 06:44:11 +04:00
|
|
|
else
|
|
|
|
rv = NS_ERROR_FILE_TOO_BIG;
|
|
|
|
}
|
|
|
|
}
|
2015-08-04 23:06:14 +03:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2016-02-18 20:26:28 +03:00
|
|
|
buf = MakeUnique<char[]>(len);
|
|
|
|
rv = inputStream->Read(buf.get(), len, &amtRead);
|
2010-08-12 23:42:36 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && len == amtRead)
|
2016-02-18 20:26:28 +03:00
|
|
|
rv = startupCache->PutBuffer(kXULCacheInfoKey, buf.get(), len);
|
2010-08-12 23:42:36 +04:00
|
|
|
else {
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
// Failed again, just bail.
|
2002-05-03 07:04:34 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 23:42:36 +04:00
|
|
|
startupCache->InvalidateCache();
|
2015-06-17 02:45:29 +03:00
|
|
|
mStartupCacheURITable.Clear();
|
2003-05-22 08:09:34 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-05-03 07:04:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-12-29 18:34:05 +04:00
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsXULPrototypeCache::MarkInCCGeneration(uint32_t aGeneration)
|
2011-12-29 18:34:05 +04:00
|
|
|
{
|
2016-01-28 03:04:59 +03:00
|
|
|
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
iter.Data()->MarkInCCGeneration(aGeneration);
|
|
|
|
}
|
|
|
|
for (auto iter = mPrototypeTable.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
iter.Data()->MarkInCCGeneration(aGeneration);
|
|
|
|
}
|
2013-03-19 21:20:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXULPrototypeCache::MarkInGC(JSTracer* aTrc)
|
|
|
|
{
|
2016-01-28 03:04:59 +03:00
|
|
|
for (auto iter = mScriptTable.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
JS::Heap<JSScript*>& script = iter.Data();
|
|
|
|
JS::TraceEdge(aTrc, &script, "nsXULPrototypeCache script");
|
|
|
|
}
|
2013-03-19 21:20:21 +04:00
|
|
|
}
|