Commit 067ef5e9 authored by Benjamin Smedberg's avatar Benjamin Smedberg
Browse files

Bug 1314378 part B - port TestStartupCache to gtest, r=froydnj

MozReview-Commit-ID: LTz4slzIkjH

--HG--
extra : rebase_source : 852ca996bd042d9c363b79bf47a037f83f3cf804
extra : source : 4585a7b6f3ce8c8dc7b7e043e0fae86f8e5ee392
parent d3f7e306
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -140,7 +140,6 @@ ALLOWED_XPCOM_GLUE = {
    ('TestTXMgr', 'editor/txmgr/tests'),
    ('test_IHistory', 'toolkit/components/places/tests/cpp'),
    ('testcrasher', 'toolkit/crashreporter/test'),
    ('TestStartupCache', 'startupcache/test'),
    ('jsep_session_unittest', 'media/webrtc/signaling/test'),
    ('jsep_track_unittest', 'media/webrtc/signaling/test'),
    ('mediaconduit_unittests', 'media/webrtc/signaling/test'),
+8 −27
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ StartupCache::Init()
  // This allows to override the startup cache filename
  // which is useful from xpcshell, when there is no ProfLDS directory to keep cache in.
  char *env = PR_GetEnv("MOZ_STARTUP_CACHE");
  if (env) {
  if (env && *env) {
    rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(mFile));
  } else {
    nsCOMPtr<nsIFile> file;
@@ -595,6 +595,13 @@ StartupCache::ResetStartupWriteTimer()
  return NS_OK;
}

bool
StartupCache::StartupWriteComplete()
{
  WaitOnWriteThread();
  return mStartupWriteInitiated && mTable.Count() == 0;
}

// StartupCacheDebugOutputStream implementation
#ifdef DEBUG
NS_IMPL_ISUPPORTS(StartupCacheDebugOutputStream, nsIObjectOutputStream, 
@@ -737,13 +744,6 @@ StartupCacheWrapper::InvalidateCache()
  return NS_OK;
}

nsresult
StartupCacheWrapper::IgnoreDiskCache()
{
  StartupCache::IgnoreDiskCache();
  return NS_OK;
}

nsresult 
StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream,
                                                nsIObjectOutputStream** outStream) 
@@ -755,25 +755,6 @@ StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream,
  return sc->GetDebugObjectOutputStream(stream, outStream);
}

nsresult
StartupCacheWrapper::StartupWriteComplete(bool *complete)
{
  StartupCache* sc = StartupCache::GetSingleton();
  if (!sc) {
    return NS_ERROR_NOT_INITIALIZED;
  }
  sc->WaitOnWriteThread();
  *complete = sc->mStartupWriteInitiated && sc->mTable.Count() == 0;
  return NS_OK;
}

nsresult
StartupCacheWrapper::ResetStartupWriteTimer()
{
  StartupCache* sc = StartupCache::GetSingleton();
  return sc ? sc->ResetStartupWriteTimer() : NS_ERROR_NOT_INITIALIZED;
}

nsresult
StartupCacheWrapper::GetObserver(nsIObserver** obv) {
  StartupCache* sc = StartupCache::GetSingleton();
+3 −1
Original line number Diff line number Diff line
@@ -138,6 +138,9 @@ public:

  size_t SizeOfMapping();

  // FOR TESTING ONLY
  nsresult ResetStartupWriteTimer();
  bool StartupWriteComplete();
private:
  StartupCache();
  virtual ~StartupCache();
@@ -145,7 +148,6 @@ private:
  nsresult LoadArchive();
  nsresult Init();
  void WriteToDisk();
  nsresult ResetStartupWriteTimer();
  void WaitOnWriteThread();

  static nsresult InitSingleton();
+7 −7
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
namespace mozilla {
namespace scache {

NS_EXPORT nsresult
nsresult
NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len,
                               nsIObjectInputStream** stream)
{
@@ -37,7 +37,7 @@ NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len,
  return NS_OK;
}

NS_EXPORT nsresult
nsresult
NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
                                    nsIStorageStream** stream,
                                    bool wantDebugStream)
@@ -74,7 +74,7 @@ NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
  return NS_OK;
}

NS_EXPORT nsresult
nsresult
NewBufferFromStorageStream(nsIStorageStream *storageStream,
                           UniquePtr<char[]>* buffer, uint32_t* len)
{
@@ -170,7 +170,7 @@ canonicalizeBase(nsAutoCString &spec,
 *  jar:file://$PROFILE_DIR/extensions/some.xpi!/components/component.js becomes
 *     jsloader/$PROFILE_DIR/extensions/some.xpi/components/component.js
 */
NS_EXPORT nsresult
nsresult
PathifyURI(nsIURI *in, nsACString &out)
{
    bool equals;
+7 −4
Original line number Diff line number Diff line
@@ -5,15 +5,18 @@
#ifndef nsStartupCacheUtils_h_
#define nsStartupCacheUtils_h_

#include "nsString.h"
#include "nsIStorageStream.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "mozilla/UniquePtr.h"

class nsIURI;

namespace mozilla {
namespace scache {

NS_EXPORT nsresult
nsresult
NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len, 
                               nsIObjectInputStream** stream);

@@ -23,7 +26,7 @@ NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len,
// non-singleton objects are written out multiple times during a serialization.
// This could cause them to be deserialized incorrectly (as multiple copies
// instead of references).
NS_EXPORT nsresult
nsresult
NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
                                    nsIStorageStream** stream,
                                    bool wantDebugStream);
@@ -31,11 +34,11 @@ 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.
NS_EXPORT nsresult
nsresult
NewBufferFromStorageStream(nsIStorageStream *storageStream, 
                           UniquePtr<char[]>* buffer, uint32_t* len);

NS_EXPORT nsresult
nsresult
PathifyURI(nsIURI *in, nsACString &out);
} // namespace scache
} // namespace mozilla
Loading