forked from mirrors/gecko-dev
Bug 1626815 - Expose startup cache info to about:support. r=froydnj,fluent-reviewers
Adds a new startup cache info service to expose some of the internal state of the startup cache. Differential Revision: https://phabricator.services.mozilla.com/D69298 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b55f9bcbf6
commit
6f5ed38db3
12 changed files with 222 additions and 0 deletions
|
|
@ -137,6 +137,7 @@ nsresult StartupCache::InitSingleton() {
|
||||||
StaticRefPtr<StartupCache> StartupCache::gStartupCache;
|
StaticRefPtr<StartupCache> StartupCache::gStartupCache;
|
||||||
bool StartupCache::gShutdownInitiated;
|
bool StartupCache::gShutdownInitiated;
|
||||||
bool StartupCache::gIgnoreDiskCache;
|
bool StartupCache::gIgnoreDiskCache;
|
||||||
|
bool StartupCache::gFoundDiskCacheOnInit;
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(StartupCache, nsIMemoryReporter)
|
NS_IMPL_ISUPPORTS(StartupCache, nsIMemoryReporter)
|
||||||
|
|
||||||
|
|
@ -211,6 +212,8 @@ nsresult StartupCache::Init() {
|
||||||
auto result = LoadArchive();
|
auto result = LoadArchive();
|
||||||
rv = result.isErr() ? result.unwrapErr() : NS_OK;
|
rv = result.isErr() ? result.unwrapErr() : NS_OK;
|
||||||
|
|
||||||
|
gFoundDiskCacheOnInit = rv != NS_ERROR_FILE_NOT_FOUND;
|
||||||
|
|
||||||
// Sometimes we don't have a cache yet, that's ok.
|
// Sometimes we don't have a cache yet, that's ok.
|
||||||
// If it's corrupted, just remove it and start over.
|
// If it's corrupted, just remove it and start over.
|
||||||
if (gIgnoreDiskCache || (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND)) {
|
if (gIgnoreDiskCache || (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND)) {
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,8 @@ class StartupCache : public nsIMemoryReporter {
|
||||||
StartupCache();
|
StartupCache();
|
||||||
virtual ~StartupCache();
|
virtual ~StartupCache();
|
||||||
|
|
||||||
|
friend class StartupCacheInfo;
|
||||||
|
|
||||||
Result<Ok, nsresult> LoadArchive();
|
Result<Ok, nsresult> LoadArchive();
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
||||||
|
|
@ -238,6 +240,7 @@ class StartupCache : public nsIMemoryReporter {
|
||||||
static StaticRefPtr<StartupCache> gStartupCache;
|
static StaticRefPtr<StartupCache> gStartupCache;
|
||||||
static bool gShutdownInitiated;
|
static bool gShutdownInitiated;
|
||||||
static bool gIgnoreDiskCache;
|
static bool gIgnoreDiskCache;
|
||||||
|
static bool gFoundDiskCacheOnInit;
|
||||||
PRThread* mWriteThread;
|
PRThread* mWriteThread;
|
||||||
PRThread* mPrefetchThread;
|
PRThread* mPrefetchThread;
|
||||||
UniquePtr<Compression::LZ4FrameDecompressionContext> mDecompressionContext;
|
UniquePtr<Compression::LZ4FrameDecompressionContext> mDecompressionContext;
|
||||||
|
|
|
||||||
47
startupcache/StartupCacheInfo.cpp
Normal file
47
startupcache/StartupCacheInfo.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
#include "StartupCacheInfo.h"
|
||||||
|
|
||||||
|
#include "mozilla/Components.h"
|
||||||
|
#include "mozilla/RefPtr.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
using namespace mozilla::scache;
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS(StartupCacheInfo, nsIStartupCacheInfo)
|
||||||
|
|
||||||
|
nsresult StartupCacheInfo::GetIgnoreDiskCache(bool* aIgnore) {
|
||||||
|
*aIgnore = StartupCache::gIgnoreDiskCache;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult StartupCacheInfo::GetFoundDiskCacheOnInit(bool* aFound) {
|
||||||
|
*aFound = StartupCache::gFoundDiskCacheOnInit;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult StartupCacheInfo::GetWroteToDiskCache(bool* aWrote) {
|
||||||
|
if (!StartupCache::gStartupCache) {
|
||||||
|
*aWrote = false;
|
||||||
|
} else {
|
||||||
|
*aWrote = StartupCache::gStartupCache->mWrittenOnce;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult StartupCacheInfo::GetDiskCachePath(nsAString& aResult) {
|
||||||
|
if (!StartupCache::gStartupCache || !StartupCache::gStartupCache->mFile) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
nsAutoString path;
|
||||||
|
StartupCache::gStartupCache->mFile->GetPath(path);
|
||||||
|
aResult.Assign(path);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMPL_COMPONENT_FACTORY(nsIStartupCacheInfo) {
|
||||||
|
return MakeAndAddRef<StartupCacheInfo>().downcast<nsISupports>();
|
||||||
|
}
|
||||||
28
startupcache/StartupCacheInfo.h
Normal file
28
startupcache/StartupCacheInfo.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
#ifndef StartupCacheInfo_h_
|
||||||
|
#define StartupCacheInfo_h_
|
||||||
|
|
||||||
|
#include "nsIStartupCacheInfo.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace scache {
|
||||||
|
|
||||||
|
class StartupCacheInfo final : public nsIStartupCacheInfo {
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSISTARTUPCACHEINFO
|
||||||
|
|
||||||
|
StartupCacheInfo() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
~StartupCacheInfo() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace scache
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // StartupCache_h_
|
||||||
13
startupcache/components.conf
Normal file
13
startupcache/components.conf
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||||
|
# vim: set filetype=python:
|
||||||
|
# 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/.
|
||||||
|
|
||||||
|
Classes = [
|
||||||
|
{
|
||||||
|
'cid': '{a6b2f8b0-7438-11ea-bc55-0242ac130003}',
|
||||||
|
'contract_ids': ['@mozilla.org/startupcacheinfo;1'],
|
||||||
|
'type': 'nsIStartupCacheInfo',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
@ -17,7 +17,18 @@ EXPORTS.mozilla.scache += [
|
||||||
|
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
'StartupCache.cpp',
|
'StartupCache.cpp',
|
||||||
|
'StartupCacheInfo.cpp',
|
||||||
'StartupCacheUtils.cpp',
|
'StartupCacheUtils.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
XPCOM_MANIFESTS += [
|
||||||
|
'components.conf',
|
||||||
|
]
|
||||||
|
|
||||||
|
XPIDL_MODULE = 'startupcache'
|
||||||
|
|
||||||
|
XPIDL_SOURCES += [
|
||||||
|
'nsIStartupCacheInfo.idl',
|
||||||
|
]
|
||||||
|
|
||||||
FINAL_LIBRARY = 'xul'
|
FINAL_LIBRARY = 'xul'
|
||||||
|
|
|
||||||
38
startupcache/nsIStartupCacheInfo.idl
Normal file
38
startupcache/nsIStartupCacheInfo.idl
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
|
/* NOTE: this interface is completely undesigned, not stable and likely to change */
|
||||||
|
[scriptable, builtinclass, uuid(a6b2f8b0-7438-11ea-bc55-0242ac130003)]
|
||||||
|
interface nsIStartupCacheInfo : nsISupports
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns true if the startup cache will not load from the cache from disk.
|
||||||
|
* This can happen if the cache file is corrupt or has been invalidated.
|
||||||
|
*/
|
||||||
|
readonly attribute boolean IgnoreDiskCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if during initialization of the startup cache an existing
|
||||||
|
* cache file was found on disk. This does NOT indicate if the file loaded
|
||||||
|
* successfully.
|
||||||
|
*/
|
||||||
|
readonly attribute boolean FoundDiskCacheOnInit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true once the current cache file as been written to disk at least
|
||||||
|
* once. If the cache was loaded from disk and never changed this may never
|
||||||
|
* be set to true.
|
||||||
|
*/
|
||||||
|
readonly attribute boolean WroteToDiskCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full path and filename of the startup cache file that will be stored on
|
||||||
|
* disk.
|
||||||
|
*/
|
||||||
|
readonly attribute AString DiskCachePath;
|
||||||
|
};
|
||||||
|
|
@ -959,6 +959,14 @@ var snapshotFormatters = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startupCache(data) {
|
||||||
|
$("startup-cache-disk-cache-path").textContent = data.DiskCachePath;
|
||||||
|
$("startup-cache-ignore-disk-cache").textContent = data.IgnoreDiskCache;
|
||||||
|
$("startup-cache-found-disk-cache-on-init").textContent =
|
||||||
|
data.FoundDiskCacheOnInit;
|
||||||
|
$("startup-cache-wrote-to-disk-cache").textContent = data.WroteToDiskCache;
|
||||||
|
},
|
||||||
|
|
||||||
libraryVersions(data) {
|
libraryVersions(data) {
|
||||||
let trs = [
|
let trs = [
|
||||||
$.new("tr", [
|
$.new("tr", [
|
||||||
|
|
|
||||||
|
|
@ -608,6 +608,37 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
<h2 class="major-section" data-l10n-id="startup-cache-title"/>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th class="column" data-l10n-id="startup-cache-disk-cache-path"/>
|
||||||
|
|
||||||
|
<td id="startup-cache-disk-cache-path">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="column" data-l10n-id="startup-cache-ignore-disk-cache"/>
|
||||||
|
|
||||||
|
<td id="startup-cache-ignore-disk-cache">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="column" data-l10n-id="startup-cache-found-disk-cache-on-init"/>
|
||||||
|
|
||||||
|
<td id="startup-cache-found-disk-cache-on-init">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="column" data-l10n-id="startup-cache-wrote-to-disk-cache"/>
|
||||||
|
|
||||||
|
<td id="startup-cache-wrote-to-disk-cache">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<h2 class="major-section" data-l10n-id="intl-title"/>
|
<h2 class="major-section" data-l10n-id="intl-title"/>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,12 @@ sandbox-proc-type-file = file content
|
||||||
sandbox-proc-type-media-plugin = media plugin
|
sandbox-proc-type-media-plugin = media plugin
|
||||||
sandbox-proc-type-data-decoder = data decoder
|
sandbox-proc-type-data-decoder = data decoder
|
||||||
|
|
||||||
|
startup-cache-title = Startup Cache
|
||||||
|
startup-cache-disk-cache-path = Disk Cache Path
|
||||||
|
startup-cache-ignore-disk-cache = Ignore Disk Cache
|
||||||
|
startup-cache-found-disk-cache-on-init = Found Disk Cache on Init
|
||||||
|
startup-cache-wrote-to-disk-cache = Wrote to Disk Cache
|
||||||
|
|
||||||
launcher-process-status-0 = Enabled
|
launcher-process-status-0 = Enabled
|
||||||
launcher-process-status-1 = Disabled due to failure
|
launcher-process-status-1 = Disabled due to failure
|
||||||
launcher-process-status-2 = Disabled forcibly
|
launcher-process-status-2 = Disabled forcibly
|
||||||
|
|
|
||||||
|
|
@ -714,6 +714,18 @@ var dataProviders = {
|
||||||
done(data);
|
done(data);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startupCache: function startupCache(done) {
|
||||||
|
const startupInfo = Cc["@mozilla.org/startupcacheinfo;1"].getService(
|
||||||
|
Ci.nsIStartupCacheInfo
|
||||||
|
);
|
||||||
|
done({
|
||||||
|
DiskCachePath: startupInfo.DiskCachePath,
|
||||||
|
IgnoreDiskCache: startupInfo.IgnoreDiskCache,
|
||||||
|
FoundDiskCacheOnInit: startupInfo.FoundDiskCacheOnInit,
|
||||||
|
WroteToDiskCache: startupInfo.WroteToDiskCache,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
libraryVersions: function libraryVersions(done) {
|
libraryVersions: function libraryVersions(done) {
|
||||||
let data = {};
|
let data = {};
|
||||||
let verInfo = Cc["@mozilla.org/security/nssversion;1"].getService(
|
let verInfo = Cc["@mozilla.org/security/nssversion;1"].getService(
|
||||||
|
|
|
||||||
|
|
@ -829,6 +829,28 @@ const SNAPSHOT_SCHEMA = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
startupCache: {
|
||||||
|
required: false,
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
DiskCachePath: {
|
||||||
|
required: true,
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
IgnoreDiskCache: {
|
||||||
|
required: true,
|
||||||
|
type: "boolean",
|
||||||
|
},
|
||||||
|
FoundDiskCacheOnInit: {
|
||||||
|
required: true,
|
||||||
|
type: "boolean",
|
||||||
|
},
|
||||||
|
WroteToDiskCache: {
|
||||||
|
required: true,
|
||||||
|
type: "boolean",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
intl: {
|
intl: {
|
||||||
required: true,
|
required: true,
|
||||||
type: "object",
|
type: "object",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue