StartupCacheUtils.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsStartupCacheUtils_h_
  6. #define nsStartupCacheUtils_h_
  7. #include "nsIStorageStream.h"
  8. #include "nsIObjectInputStream.h"
  9. #include "nsIObjectOutputStream.h"
  10. #include "mozilla/UniquePtr.h"
  11. namespace mozilla {
  12. namespace scache {
  13. NS_EXPORT nsresult
  14. NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len,
  15. nsIObjectInputStream** stream);
  16. // We can't retrieve the wrapped stream from the objectOutputStream later,
  17. // so we return it here. We give callers in debug builds the option
  18. // to wrap the outputstream in a debug stream, which will detect if
  19. // non-singleton objects are written out multiple times during a serialization.
  20. // This could cause them to be deserialized incorrectly (as multiple copies
  21. // instead of references).
  22. NS_EXPORT nsresult
  23. NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
  24. nsIStorageStream** stream,
  25. bool wantDebugStream);
  26. // Creates a buffer for storing the stream into the cache. The buffer is
  27. // allocated with 'new []'. After calling this function, the caller would
  28. // typically call nsIStartupCache::PutBuffer with the returned buffer.
  29. NS_EXPORT nsresult
  30. NewBufferFromStorageStream(nsIStorageStream *storageStream,
  31. UniquePtr<char[]>* buffer, uint32_t* len);
  32. NS_EXPORT nsresult
  33. PathifyURI(nsIURI *in, nsACString &out);
  34. } // namespace scache
  35. } // namespace mozilla
  36. #endif //nsStartupCacheUtils_h_