Bug 1410471 - Remove StartupCacheWrapper and friends. r=froydnj

This class was needed for testing, but no longer.

MozReview-Commit-ID: AIk0kKlbScs

--HG--
extra : rebase_source : 35eed188e44dc4c9899479b35882461dd2cf4624
This commit is contained in:
Andrew McCreight 2017-10-20 10:40:50 -07:00
Родитель 5bbcc8eb3d
Коммит 09ab49e463
6 изменённых файлов: 2 добавлений и 201 удалений

Просмотреть файл

@ -19,7 +19,6 @@
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIOutputStream.h"
#include "nsIStartupCache.h"
#include "nsIStorageStream.h"
#include "nsIStreamBufferAccess.h"
#include "nsIStringStream.h"
@ -696,78 +695,5 @@ StartupCacheDebugOutputStream::PutBuffer(char* aBuffer, uint32_t aLength)
}
#endif //DEBUG
StartupCacheWrapper* StartupCacheWrapper::gStartupCacheWrapper = nullptr;
NS_IMPL_ISUPPORTS(StartupCacheWrapper, nsIStartupCache)
StartupCacheWrapper::~StartupCacheWrapper()
{
MOZ_ASSERT(gStartupCacheWrapper == this);
gStartupCacheWrapper = nullptr;
}
already_AddRefed<StartupCacheWrapper> StartupCacheWrapper::GetSingleton()
{
if (!gStartupCacheWrapper)
gStartupCacheWrapper = new StartupCacheWrapper();
return do_AddRef(gStartupCacheWrapper);
}
nsresult
StartupCacheWrapper::GetBuffer(const char* id, char** outbuf, uint32_t* length)
{
StartupCache* sc = StartupCache::GetSingleton();
if (!sc) {
return NS_ERROR_NOT_INITIALIZED;
}
UniquePtr<char[]> buf;
nsresult rv = sc->GetBuffer(id, &buf, length);
*outbuf = buf.release();
return rv;
}
nsresult
StartupCacheWrapper::PutBuffer(const char* id, const char* inbuf, uint32_t length)
{
StartupCache* sc = StartupCache::GetSingleton();
if (!sc) {
return NS_ERROR_NOT_INITIALIZED;
}
return sc->PutBuffer(id, inbuf, length);
}
nsresult
StartupCacheWrapper::InvalidateCache()
{
StartupCache* sc = StartupCache::GetSingleton();
if (!sc) {
return NS_ERROR_NOT_INITIALIZED;
}
sc->InvalidateCache();
return NS_OK;
}
nsresult
StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream,
nsIObjectOutputStream** outStream)
{
StartupCache* sc = StartupCache::GetSingleton();
if (!sc) {
return NS_ERROR_NOT_INITIALIZED;
}
return sc->GetDebugObjectOutputStream(stream, outStream);
}
nsresult
StartupCacheWrapper::GetObserver(nsIObserver** obv) {
StartupCache* sc = StartupCache::GetSingleton();
if (!sc) {
return NS_ERROR_NOT_INITIALIZED;
}
NS_ADDREF(*obv = sc->mListener);
return NS_OK;
}
} // namespace scache
} // namespace mozilla

Просмотреть файл

@ -10,16 +10,15 @@
#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 "nsIObjectOutputStream.h"
#include "nsIOutputStream.h"
#include "nsIFile.h"
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/UniquePtr.h"
/**
@ -104,7 +103,6 @@ class StartupCache : public nsIMemoryReporter
{
friend class StartupCacheListener;
friend class StartupCacheWrapper;
public:
NS_DECL_THREADSAFE_ISUPPORTS
@ -200,24 +198,6 @@ class StartupCacheDebugOutputStream final
};
#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 already_AddRefed<StartupCacheWrapper> GetSingleton();
static StartupCacheWrapper *gStartupCacheWrapper;
};
} // namespace scache
} // namespace mozilla

Просмотреть файл

@ -1,45 +0,0 @@
/* -*- 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 <string.h>
#include "nscore.h"
#include "nsID.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsIModule.h"
#include "mozilla/ModuleUtils.h"
#include "mozilla/scache/StartupCache.h"
using namespace mozilla::scache;
// XXX Need help with guard for ENABLE_TEST
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(StartupCacheWrapper,
StartupCacheWrapper::GetSingleton)
NS_DEFINE_NAMED_CID(NS_STARTUPCACHE_CID);
static const mozilla::Module::CIDEntry kStartupCacheCIDs[] = {
{ &kNS_STARTUPCACHE_CID, false, nullptr, StartupCacheWrapperConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kStartupCacheContracts[] = {
{ "@mozilla.org/startupcache/cache;1", &kNS_STARTUPCACHE_CID },
{ nullptr }
};
static const mozilla::Module kStartupCacheModule = {
mozilla::Module::kVersion,
kStartupCacheCIDs,
kStartupCacheContracts,
nullptr,
nullptr,
nullptr,
nullptr
};
NSMODULE_DEFN(StartupCacheModule) = &kStartupCacheModule;

Просмотреть файл

@ -33,7 +33,7 @@ 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.
// typically call StartupCache::PutBuffer with the returned buffer.
nsresult
NewBufferFromStorageStream(nsIStorageStream *storageStream,
UniquePtr<char[]>* buffer, uint32_t* len);

Просмотреть файл

@ -9,12 +9,6 @@ with Files("**"):
TEST_DIRS += ['test']
XPIDL_SOURCES += [
'nsIStartupCache.idl',
]
XPIDL_MODULE = 'startupcache'
EXPORTS.mozilla.scache += [
'StartupCache.h',
'StartupCacheUtils.h',
@ -22,7 +16,6 @@ EXPORTS.mozilla.scache += [
UNIFIED_SOURCES += [
'StartupCache.cpp',
'StartupCacheModule.cpp',
'StartupCacheUtils.cpp',
]

Просмотреть файл

@ -1,53 +0,0 @@
/* -*- 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 "nsIInputStream.idl"
#include "nsISupports.idl"
#include "nsIObserver.idl"
#include "nsIObjectOutputStream.idl"
%{C++
#include "mozilla/UniquePtr.h"
%}
[uuid(25957820-90a1-428c-8739-b0845d3cc534)]
interface nsIStartupCache : nsISupports
{
/** This interface is provided for testing purposes only, basically
* just to solve link vagaries. See docs in StartupCache.h
* GetBuffer, PutBuffer, and InvalidateCache act as described
* in that file. */
uint32_t getBuffer(in string aID, out charPtr aBuffer);
%{C++
/* A more convenient interface for using from C++. */
nsresult GetBuffer(const char* id, mozilla::UniquePtr<char[]>* outbuf, uint32_t* length)
{
char* buf;
nsresult rv = GetBuffer(id, &buf, length);
NS_ENSURE_SUCCESS(rv, rv);
outbuf->reset(buf);
return rv;
}
%}
void putBuffer(in string aID, in string aBuffer,
in uint32_t aLength);
void invalidateCache();
/** 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
* during serialization. In non-debug, returns an add-ref'd pointer to
* original stream, unwrapped. */
nsIObjectOutputStream getDebugObjectOutputStream(in nsIObjectOutputStream aStream);
/* Allows clients to simulate the behavior of ObserverService. */
readonly attribute nsIObserver observer;
};