Bug 1265584 [wpt PR 11167] - [Gecko Bug 1265584] Move wptrunner marionette usage...
[gecko.git] / startupcache / StartupCacheUtils.h
blob6aaaadc1b6beee988f7a159db9060fecfa9f718a
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_
8 #include "nsString.h"
9 #include "nsIStorageStream.h"
10 #include "nsIObjectInputStream.h"
11 #include "nsIObjectOutputStream.h"
12 #include "mozilla/UniquePtr.h"
14 class nsIURI;
16 namespace mozilla {
17 namespace scache {
19 nsresult
20 NewObjectInputStreamFromBuffer(UniquePtr<char[]> buffer, uint32_t len,
21 nsIObjectInputStream** stream);
23 // We can't retrieve the wrapped stream from the objectOutputStream later,
24 // so we return it here. We give callers in debug builds the option
25 // to wrap the outputstream in a debug stream, which will detect if
26 // non-singleton objects are written out multiple times during a serialization.
27 // This could cause them to be deserialized incorrectly (as multiple copies
28 // instead of references).
29 nsresult
30 NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
31 nsIStorageStream** stream,
32 bool wantDebugStream);
34 // Creates a buffer for storing the stream into the cache. The buffer is
35 // allocated with 'new []'. After calling this function, the caller would
36 // typically call StartupCache::PutBuffer with the returned buffer.
37 nsresult
38 NewBufferFromStorageStream(nsIStorageStream *storageStream,
39 UniquePtr<char[]>* buffer, uint32_t* len);
41 nsresult
42 ResolveURI(nsIURI *in, nsIURI **out);
44 nsresult
45 PathifyURI(nsIURI *in, nsACString &out);
46 } // namespace scache
47 } // namespace mozilla
49 #endif //nsStartupCacheUtils_h_