Commit d4c39fd9 authored by Iris Hsiao's avatar Iris Hsiao
Browse files

Backed out changeset 4585a7b6f3ce (bug 1314378)

parent 325956f7
Loading
Loading
Loading
Loading
+27 −8
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 && *env) {
  if (env) {
    rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(mFile));
  } else {
    nsCOMPtr<nsIFile> file;
@@ -595,13 +595,6 @@ StartupCache::ResetStartupWriteTimer()
  return NS_OK;
}

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

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

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

nsresult 
StartupCacheWrapper::GetDebugObjectOutputStream(nsIObjectOutputStream* stream,
                                                nsIObjectOutputStream** outStream) 
@@ -755,6 +755,25 @@ 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();
+1 −3
Original line number Diff line number Diff line
@@ -138,9 +138,6 @@ public:

  size_t SizeOfMapping();

  // FOR TESTING ONLY
  nsresult ResetStartupWriteTimer();
  bool StartupWriteComplete();
private:
  StartupCache();
  virtual ~StartupCache();
@@ -148,6 +145,7 @@ 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 {

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

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

nsresult
NS_EXPORT 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
 */
nsresult
NS_EXPORT nsresult
PathifyURI(nsIURI *in, nsACString &out)
{
    bool equals;
+4 −7
Original line number Diff line number Diff line
@@ -5,18 +5,15 @@
#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 {

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

@@ -26,7 +23,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).
nsresult
NS_EXPORT nsresult
NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
                                    nsIStorageStream** stream,
                                    bool wantDebugStream);
@@ -34,11 +31,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.
nsresult
NS_EXPORT nsresult
NewBufferFromStorageStream(nsIStorageStream *storageStream, 
                           UniquePtr<char[]>* buffer, uint32_t* len);

nsresult
NS_EXPORT nsresult
PathifyURI(nsIURI *in, nsACString &out);
} // namespace scache
} // namespace mozilla
+8 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ interface nsIStartupCache : nsISupports
 
  void invalidateCache();
  
  void ignoreDiskCache();

  /** 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 
@@ -47,6 +48,13 @@ interface nsIStartupCache : nsISupports
   *  original stream, unwrapped. */
  nsIObjectOutputStream getDebugObjectOutputStream(in nsIObjectOutputStream aStream);

  /* Allows clients to check whether the one-time writeout after startup 
   * has finished yet, and also to set this variable as needed (so test
   * code can fire mulitple startup writes if needed).
   */
  boolean startupWriteComplete();
  void resetStartupWriteTimer();

  /* Allows clients to simulate the behavior of ObserverService. */
  readonly attribute nsIObserver observer;
};
Loading