mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
e333860065
- Bug 1251090 - Shell functions should check whether an off main thread compilation is for a script or a module r=shu (41b89b1232) - Bug 1222420 - Make AutoFinishGC into a function r=terrence (a8f535528c) - Bug 1253094, part 4 - Stop using DebugOnly for class/struct members in js/. r=billm (2c790aa526) - Bug 1080968 - Don't use constexpr on clang-cl when emulating MSVC 2013 (e9cc2d7c7c) - Bug 1257496 - Add information about cycle count and GC state to our GC stats r=sfink (6c2250bfba) - Bug 1256178 - Drop the moz prefix from the MozCSSKeyframeRule and MozCSSKeyframesRule interfaces; r=bzbarsky (894855bce1) - Bug 1249896 - Part 1: Remove unused AndOrLeft, AndOrRight, RelationalLeft, and RelationalRight. r=jwalden (c4db9dfecf) - Bug 1249896 - Part 2: Remove unused type member from SIMD Int8x16Defnetc. r=bbouvier (7d3d7a4db1) - Bug 1249896 - Part 3: Add JS namespace for GenericNaN. r=luke (69acc1f3ec) - Bug 1249896 - Part 4: Avoid declaring variable between cases in switch. r=luke (28e5f94c24) - Bug 1249896 - Part 5: Remove unused ReportInvalidTrapResult. r=efaust (caa948acac) - Bug 1249896 - Part 7: Remove unnecessary static from my_ErrorReporter. r=sfink (7f723e079d) - Bug 1249896 - Part 8: Remove unreachable code from GetLine. r=jwalden (108c857a1a) - Bug 1249896 - Part 9: Include shell/jsshell.h in js.cpp. r=sfink (638bfc13c4) - Bug 1253094, part 3 - Stop using DebugOnly for class/struct members in ipc/. r=billm (ab9e014158) - Bug 1259737 - Make sure BackgroundImpl.cpp's mBoundThread is not used in release builds. r=froydnj (5c278ab398) - Bug 1254515 - GonkCameraImage.cpp:16:5: error: class 'mozilla::GonkCameraImage' does not have any field named 'mThread' r=reuben (e5cac8cf5b) - Bug 1250952: Create a join block in case we're in dead code after the condition; r=luke (1d6b706ae5) - Bug 1249601 - Implement wasm i64 comparisons. r=sunfish (4927f709db) - Bug 1250165 - Implement wasm i64 bitwise ops. r=luke (5c25322772) - Bug 1251225 - Implement wasm i64 binary arithmetic operators. r=sunfish (f478fa8b4b) - Bug 1251392 - Baldr: Implement PopcntI. r=sunfish (79556e947f) - Bug 1229985 - remove nsAutoArrayPtr; r=erahm (91c49451ca) - Bug 1251541: Replace |nsAutoArrayPtr<>| with |UniquePtr<[]>| in Bluetooth managers, r=shuang (2c1dc7ca89) - Bug 1251541: Pass arguments to AVRCP passthrough command as uint8_t, r=shuang (73a094bd26) - Bug 1251541: Replace |nsAutoArrayPtr<>| with |UniquePtr<[]>| in Bluetooth interfaces, r=shuang (371041f093) - Bug 1249424 - Remove use of nsAutoArrayPtr from librlz. r=gerald (7cbcfea1b0) - Bug 1249389 - part 0 - use getter_Transfers in TestStartupCache.cpp; r=erahm (ecb8818959) - Bug 1249389 - part 1 - change NewObjectInputStreamFromBuffer to take a UniquePtr argument; r=erahm (0bdafa20ae) - Bug 1249389 - part 2 - change NewBufferFromStorageStream's outparam into a UniquePtr; r=erahm (b27a70ce2d) - Bug 1249389 - part 3 - assert the size of nsZipItemPtr's storage type; r=erahm (7c55da9ea7) - Bug 1249389 - part 4 - make StartupCache::GetBuffer take a UniquePtr outparam; r=erahm (84b722479b) - Bug 1249389 - part 5 - use UniquePtr instead of nsAutoArrayPtr in mozilla::scache::CacheEntry; r=erahm (0fd492ea95) - Bug 1249389 - part 6 - provide UniquePtr overload for nsIStartupCache::GetBuffer; r=erahm (c27231d945) - Bug 1249389 - followup - fix compilation bustage in gfxFT2FontList.cpp; r=me (a86a1b0399) - Bug 1249389 - part 7 - clean up calls to GetBuffer in TestStartupCache; r=erahm (98939334b6) - Bug 1249369 - use UniquePtr instead of nsAutoArrayPtr in MediaPipeline.cpp; r=jesup (7402a75a8a) - Bug 1238842 - Add error codes to Gecko by following W3C spec. r=brsun (0dd283f6ba) - Bug 1253217 - Change filename from BluetoothUuid to BluetoothUuidHelper. r=jocelyn (1946bcac26) - Bug 1241382 - Revise default value of BluetoothAdapter.address and BluetoothDevice.address to empty string, f=wiwang, r=shuang (d9fdb97743) - Bug 1223722: Transfer arrays of Bluetooth UUIDs in |BluetoothValue|, r=brsun (344af40591) - Bug 1222956: Use |BluetoothUuid| in |BluetoothDiscoveryHandle|, r=tzimmermann (40512de386) - Bug 1250694: Use functions to return static const BluetoothAddress and BluetoothUuid; r=tzimmermann (0c4b20066f) - Bug 1236561 - part 1 - convert easy cases of nsAutoArrayPtr<T> to UniquePtr<T[]> in dom/bluetooth/; r=btian (31ef8b7b50) - Bug 1236561 - part 2 - remove ObexHeaderSet::GetAuthChallenge; r=btian (f70daddd53) - Bug 1236561 - part 3 - make BluetoothConfigurationParameter.mValue a UniquePtr; r=btian (a5a0ac988a) - Bug 1239979: Add |BluetoothSocket::Accept| method, r=btian (ca92a0ab7c) - Bug 1239979: Store pointer to Bluetooth socket interface in |BluetoothSocket|, r=btian (7c15e75133) - Bug 1239979: Cleanup |BluetoothSocket|'s internals when connections close, r=btian (b6ac677d2e) - Bug 1252841: Convert Bluetooth module to |UniquePtr<>|, r=btian (76d9759afd) - Bug 1232687: Start bluetoothd with HAL service interface, r=shuang (379a68064f) - Bug 1223729 - HID Connection Implementation, r=jocelyn, sr=mrbkap (0eeddf875e) - Bug 1232670: Prepare Bluetooth PDU for sending after checking connection status, r=shuang (699ff14d9b) - Bug 1252841: Convert Bluetooth daemon interfaces to |UniquePtr<>|, r=brsun (797260c6dc)
231 lines
7.8 KiB
C++
231 lines
7.8 KiB
C++
/* -*- 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 StartupCache_h_
|
|
#define StartupCache_h_
|
|
|
|
#include "nsClassHashtable.h"
|
|
#include "nsComponentManagerUtils.h"
|
|
#include "nsTArray.h"
|
|
#include "nsZipArchive.h"
|
|
#include "nsIStartupCache.h"
|
|
#include "nsITimer.h"
|
|
#include "nsIMemoryReporter.h"
|
|
#include "nsIObserverService.h"
|
|
#include "nsIObserver.h"
|
|
#include "nsIOutputStream.h"
|
|
#include "nsIFile.h"
|
|
#include "mozilla/Attributes.h"
|
|
#include "mozilla/MemoryReporting.h"
|
|
#include "mozilla/StaticPtr.h"
|
|
#include "mozilla/UniquePtr.h"
|
|
|
|
/**
|
|
* The StartupCache is a persistent cache of simple key-value pairs,
|
|
* where the keys are null-terminated c-strings and the values are
|
|
* arbitrary data, passed as a (char*, size) tuple.
|
|
*
|
|
* Clients should use the GetSingleton() static method to access the cache. It
|
|
* will be available from the end of XPCOM init (NS_InitXPCOM3 in XPCOMInit.cpp),
|
|
* until XPCOM shutdown begins. The GetSingleton() method will return null if the cache
|
|
* is unavailable. The cache is only provided for libxul builds --
|
|
* it will fail to link in non-libxul builds. The XPCOM interface is provided
|
|
* only to allow compiled-code tests; clients should avoid using it.
|
|
*
|
|
* The API provided is very simple: GetBuffer() returns a buffer that was previously
|
|
* stored in the cache (if any), and PutBuffer() inserts a buffer into the cache.
|
|
* GetBuffer returns a new buffer, and the caller must take ownership of it.
|
|
* PutBuffer will assert if the client attempts to insert a buffer with the same name as
|
|
* an existing entry. The cache makes a copy of the passed-in buffer, so client
|
|
* retains ownership.
|
|
*
|
|
* InvalidateCache() may be called if a client suspects data corruption
|
|
* or wishes to invalidate for any other reason. This will remove all existing cache data.
|
|
* Additionally, the static method IgnoreDiskCache() can be called if it is
|
|
* believed that the on-disk cache file is itself corrupt. This call implicitly
|
|
* calls InvalidateCache (if the singleton has been initialized) to ensure any
|
|
* data already read from disk is discarded. The cache will not load data from
|
|
* the disk file until a successful write occurs.
|
|
*
|
|
* Finally, getDebugObjectOutputStream() allows debug code to wrap an objectstream
|
|
* with a debug objectstream, to check for multiply-referenced objects. These will
|
|
* generally fail to deserialize correctly, unless they are stateless singletons or the
|
|
* client maintains their own object data map for deserialization.
|
|
*
|
|
* Writes before the final-ui-startup notification are placed in an intermediate
|
|
* cache in memory, then written out to disk at a later time, to get writes off the
|
|
* startup path. In any case, clients should not rely on being able to GetBuffer()
|
|
* data that is written to the cache, since it may not have been written to disk or
|
|
* another client may have invalidated the cache. In other words, it should be used as
|
|
* a cache only, and not a reliable persistent store.
|
|
*
|
|
* Some utility functions are provided in StartupCacheUtils. These functions wrap the
|
|
* buffers into object streams, which may be useful for serializing objects. Note
|
|
* the above caution about multiply-referenced objects, though -- the streams are just
|
|
* as 'dumb' as the underlying buffers about multiply-referenced objects. They just
|
|
* provide some convenience in writing out data.
|
|
*/
|
|
|
|
namespace mozilla {
|
|
|
|
namespace scache {
|
|
|
|
struct CacheEntry
|
|
{
|
|
UniquePtr<char[]> data;
|
|
uint32_t size;
|
|
|
|
CacheEntry() : size(0) { }
|
|
|
|
// Takes possession of buf
|
|
CacheEntry(UniquePtr<char[]> buf, uint32_t len) : data(Move(buf)), size(len) { }
|
|
|
|
~CacheEntry()
|
|
{
|
|
}
|
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) {
|
|
return mallocSizeOf(this) + mallocSizeOf(data.get());
|
|
}
|
|
};
|
|
|
|
// We don't want to refcount StartupCache, and ObserverService wants to
|
|
// refcount its listeners, so we'll let it refcount this instead.
|
|
class StartupCacheListener final : public nsIObserver
|
|
{
|
|
~StartupCacheListener() {}
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
NS_DECL_NSIOBSERVER
|
|
};
|
|
|
|
class StartupCache : public nsIMemoryReporter
|
|
{
|
|
|
|
friend class StartupCacheListener;
|
|
friend class StartupCacheWrapper;
|
|
|
|
public:
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
NS_DECL_NSIMEMORYREPORTER
|
|
|
|
// StartupCache methods. See above comments for a more detailed description.
|
|
|
|
// Returns a buffer that was previously stored, caller takes ownership.
|
|
nsresult GetBuffer(const char* id, UniquePtr<char[]>* outbuf, uint32_t* length);
|
|
|
|
// Stores a buffer. Caller keeps ownership, we make a copy.
|
|
nsresult PutBuffer(const char* id, const char* inbuf, uint32_t length);
|
|
|
|
// Removes the cache file.
|
|
void InvalidateCache();
|
|
|
|
// Signal that data should not be loaded from the cache file
|
|
static void IgnoreDiskCache();
|
|
|
|
// In DEBUG builds, returns a stream that will attempt to check for
|
|
// and disallow multiple writes of the same object.
|
|
nsresult GetDebugObjectOutputStream(nsIObjectOutputStream* aStream,
|
|
nsIObjectOutputStream** outStream);
|
|
|
|
nsresult RecordAgesAlways();
|
|
|
|
static StartupCache* GetSingleton();
|
|
static void DeleteSingleton();
|
|
|
|
// This measures all the heap memory used by the StartupCache, i.e. it
|
|
// excludes the mapping.
|
|
size_t HeapSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
|
|
|
|
size_t SizeOfMapping();
|
|
|
|
private:
|
|
StartupCache();
|
|
virtual ~StartupCache();
|
|
|
|
enum TelemetrifyAge {
|
|
IGNORE_AGE = 0,
|
|
RECORD_AGE = 1
|
|
};
|
|
static enum TelemetrifyAge gPostFlushAgeAction;
|
|
|
|
nsresult LoadArchive(enum TelemetrifyAge flag);
|
|
nsresult Init();
|
|
void WriteToDisk();
|
|
nsresult ResetStartupWriteTimer();
|
|
void WaitOnWriteThread();
|
|
|
|
static nsresult InitSingleton();
|
|
static void WriteTimeout(nsITimer *aTimer, void *aClosure);
|
|
static void ThreadedWrite(void *aClosure);
|
|
|
|
nsClassHashtable<nsCStringHashKey, CacheEntry> mTable;
|
|
nsTArray<nsCString> mPendingWrites;
|
|
RefPtr<nsZipArchive> mArchive;
|
|
nsCOMPtr<nsIFile> mFile;
|
|
|
|
nsCOMPtr<nsIObserverService> mObserverService;
|
|
RefPtr<StartupCacheListener> mListener;
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
bool mStartupWriteInitiated;
|
|
|
|
static StaticRefPtr<StartupCache> gStartupCache;
|
|
static bool gShutdownInitiated;
|
|
static bool gIgnoreDiskCache;
|
|
PRThread *mWriteThread;
|
|
#ifdef DEBUG
|
|
nsTHashtable<nsISupportsHashKey> mWriteObjectMap;
|
|
#endif
|
|
};
|
|
|
|
// This debug outputstream attempts to detect if clients are writing multiple
|
|
// references to the same object. We only support that if that object
|
|
// is a singleton.
|
|
#ifdef DEBUG
|
|
class StartupCacheDebugOutputStream final
|
|
: public nsIObjectOutputStream
|
|
{
|
|
~StartupCacheDebugOutputStream() {}
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIOBJECTOUTPUTSTREAM
|
|
|
|
StartupCacheDebugOutputStream (nsIObjectOutputStream* binaryStream,
|
|
nsTHashtable<nsISupportsHashKey>* objectMap)
|
|
: mBinaryStream(binaryStream), mObjectMap(objectMap) { }
|
|
|
|
NS_FORWARD_SAFE_NSIBINARYOUTPUTSTREAM(mBinaryStream)
|
|
NS_FORWARD_SAFE_NSIOUTPUTSTREAM(mBinaryStream)
|
|
|
|
bool CheckReferences(nsISupports* aObject);
|
|
|
|
nsCOMPtr<nsIObjectOutputStream> mBinaryStream;
|
|
nsTHashtable<nsISupportsHashKey> *mObjectMap;
|
|
};
|
|
#endif // DEBUG
|
|
|
|
// XPCOM wrapper interface provided for tests only.
|
|
#define NS_STARTUPCACHE_CID \
|
|
{0xae4505a9, 0x87ab, 0x477c, \
|
|
{0xb5, 0x77, 0xf9, 0x23, 0x57, 0xed, 0xa8, 0x84}}
|
|
// contract id: "@mozilla.org/startupcache/cache;1"
|
|
|
|
class StartupCacheWrapper final
|
|
: public nsIStartupCache
|
|
{
|
|
~StartupCacheWrapper();
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
NS_DECL_NSISTARTUPCACHE
|
|
|
|
static StartupCacheWrapper* GetSingleton();
|
|
static StartupCacheWrapper *gStartupCacheWrapper;
|
|
};
|
|
|
|
} // namespace scache
|
|
} // namespace mozilla
|
|
|
|
#endif //StartupCache_h_
|