Backed out changeset 3fe07c50c854 (bug 946316) for bustage. a=backout
[gecko.git] / dom / asmjscache / AsmJSCache.h
blobcd40fce74e452df2d322d6285c6bba0c621d9f45
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_asmjscache_asmjscache_h
8 #define mozilla_dom_asmjscache_asmjscache_h
10 #include "ipc/IPCMessageUtils.h"
11 #include "js/TypeDecls.h"
12 #include "js/Vector.h"
14 class nsIPrincipal;
16 namespace mozilla {
17 namespace dom {
19 namespace quota {
20 class Client;
23 namespace asmjscache {
25 class PAsmJSCacheEntryChild;
26 class PAsmJSCacheEntryParent;
28 enum OpenMode
30 eOpenForRead,
31 eOpenForWrite,
32 NUM_OPEN_MODES
35 // Implementation of AsmJSCacheOps, installed by nsJSEnvironment:
37 bool
38 OpenEntryForRead(JS::Handle<JSObject*> aGlobal,
39 const jschar* aBegin,
40 const jschar* aLimit,
41 size_t* aSize,
42 const uint8_t** aMemory,
43 intptr_t *aHandle);
44 void
45 CloseEntryForRead(JS::Handle<JSObject*> aGlobal,
46 size_t aSize,
47 const uint8_t* aMemory,
48 intptr_t aHandle);
49 bool
50 OpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
51 const jschar* aBegin,
52 const jschar* aEnd,
53 size_t aSize,
54 uint8_t** aMemory,
55 intptr_t* aHandle);
56 void
57 CloseEntryForWrite(JS::Handle<JSObject*> aGlobal,
58 size_t aSize,
59 uint8_t* aMemory,
60 intptr_t aHandle);
61 bool
62 GetBuildId(js::Vector<char>* aBuildId);
64 // Called from QuotaManager.cpp:
66 quota::Client*
67 CreateClient();
69 // Called from ipc/ContentParent.cpp:
71 PAsmJSCacheEntryParent*
72 AllocEntryParent(OpenMode aOpenMode, uint32_t aSizeToWrite,
73 nsIPrincipal* aPrincipal);
75 void
76 DeallocEntryParent(PAsmJSCacheEntryParent* aActor);
78 // Called from ipc/ContentChild.cpp:
80 void
81 DeallocEntryChild(PAsmJSCacheEntryChild* aActor);
83 } // namespace asmjscache
84 } // namespace dom
85 } // namespace mozilla
87 namespace IPC {
89 template <>
90 struct ParamTraits<mozilla::dom::asmjscache::OpenMode> :
91 public EnumSerializer<mozilla::dom::asmjscache::OpenMode,
92 mozilla::dom::asmjscache::eOpenForRead,
93 mozilla::dom::asmjscache::NUM_OPEN_MODES>
94 { };
96 } // namespace IPC
98 #endif // mozilla_dom_asmjscache_asmjscache_h