Bug 1410471 - Remove StartupCacheWrapper and friends. r=froydnj
authorAndrew McCreight <continuation@gmail.com>
Fri, 20 Oct 2017 10:40:50 -0700
changeset 389176 ab03b4c381d4e1768d4a2af7cec65003d89a4b12
parent 389175 fdebaa9caba4a36fd24fa5a3d5ae1daa0d0ed029
child 389177 9f9c7289c55b64d0faba947f16162e178eab1a19
push id32779
push userebalazs@mozilla.com
push dateTue, 31 Oct 2017 10:45:04 +0000
treeherdermozilla-central@a16cc603d061 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1410471
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1410471 - Remove StartupCacheWrapper and friends. r=froydnj This class was needed for testing, but no longer. MozReview-Commit-ID: AIk0kKlbScs
startupcache/StartupCache.cpp
startupcache/StartupCache.h
startupcache/StartupCacheModule.cpp
startupcache/StartupCacheUtils.h
startupcache/moz.build
startupcache/nsIStartupCache.idl
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -14,17 +14,16 @@
 #include "nsClassHashtable.h"
 #include "nsComponentManagerUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsIClassInfo.h"
 #include "nsIFile.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIOutputStream.h"
-#include "nsIStartupCache.h"
 #include "nsIStorageStream.h"
 #include "nsIStreamBufferAccess.h"
 #include "nsIStringStream.h"
 #include "nsISupports.h"
 #include "nsITimer.h"
 #include "nsIZipWriter.h"
 #include "nsIZipReader.h"
 #include "nsWeakReference.h"
@@ -691,83 +690,10 @@ StartupCacheDebugOutputStream::GetBuffer
 
 void
 StartupCacheDebugOutputStream::PutBuffer(char* aBuffer, uint32_t aLength)
 {
   mBinaryStream->PutBuffer(aBuffer, 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
--- a/startupcache/StartupCache.h
+++ b/startupcache/StartupCache.h
@@ -5,26 +5,25 @@
 
 #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 "nsIObjectOutputStream.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
@@ -99,17 +98,16 @@ class StartupCacheListener final : publi
   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.
@@ -195,30 +193,12 @@ class StartupCacheDebugOutputStream fina
 
   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 already_AddRefed<StartupCacheWrapper> GetSingleton();
-  static StartupCacheWrapper *gStartupCacheWrapper;
-};
-
 } // namespace scache
 } // namespace mozilla
 
 #endif //StartupCache_h_
deleted file mode 100644
--- a/startupcache/StartupCacheModule.cpp
+++ /dev/null
@@ -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;
--- a/startupcache/StartupCacheUtils.h
+++ b/startupcache/StartupCacheUtils.h
@@ -28,17 +28,17 @@ NewObjectInputStreamFromBuffer(UniquePtr
 // instead of references).
 nsresult
 NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
                                     nsIStorageStream** stream,
                                     bool wantDebugStream);
 
 // 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);
 
 nsresult
 ResolveURI(nsIURI *in, nsIURI **out);
 
 nsresult
--- a/startupcache/moz.build
+++ b/startupcache/moz.build
@@ -4,26 +4,19 @@
 # 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/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "XPCOM")
 
 TEST_DIRS += ['test']
 
-XPIDL_SOURCES += [
-    'nsIStartupCache.idl',
-]
-
-XPIDL_MODULE = 'startupcache'
-
 EXPORTS.mozilla.scache += [
     'StartupCache.h',
     'StartupCacheUtils.h',
 ]
 
 UNIFIED_SOURCES += [
     'StartupCache.cpp',
-    'StartupCacheModule.cpp',
     'StartupCacheUtils.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/startupcache/nsIStartupCache.idl
+++ /dev/null
@@ -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;
-};
-