michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsStartupCacheUtils_h_ michael@0: #define nsStartupCacheUtils_h_ michael@0: michael@0: #include "nsIStorageStream.h" michael@0: #include "nsIObjectInputStream.h" michael@0: #include "nsIObjectOutputStream.h" michael@0: michael@0: namespace mozilla { michael@0: namespace scache { michael@0: michael@0: NS_EXPORT nsresult michael@0: NewObjectInputStreamFromBuffer(char* buffer, uint32_t len, michael@0: nsIObjectInputStream** stream); michael@0: michael@0: // We can't retrieve the wrapped stream from the objectOutputStream later, michael@0: // so we return it here. We give callers in debug builds the option michael@0: // to wrap the outputstream in a debug stream, which will detect if michael@0: // non-singleton objects are written out multiple times during a serialization. michael@0: // This could cause them to be deserialized incorrectly (as multiple copies michael@0: // instead of references). michael@0: NS_EXPORT nsresult michael@0: NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream, michael@0: nsIStorageStream** stream, michael@0: bool wantDebugStream); michael@0: michael@0: // Creates a buffer for storing the stream into the cache. The buffer is michael@0: // allocated with 'new []'. Typically, the caller would store the buffer in michael@0: // an nsAutoArrayPtr and then call nsIStartupCache::PutBuffer with it. michael@0: NS_EXPORT nsresult michael@0: NewBufferFromStorageStream(nsIStorageStream *storageStream, michael@0: char** buffer, uint32_t* len); michael@0: michael@0: NS_EXPORT nsresult michael@0: PathifyURI(nsIURI *in, nsACString &out); michael@0: } michael@0: } michael@0: #endif //nsStartupCacheUtils_h_