Line data Source code
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 :
6 : #ifndef mozilla_dom_ChromeUtils__
7 : #define mozilla_dom_ChromeUtils__
8 :
9 : #include "mozilla/AlreadyAddRefed.h"
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/ChromeUtilsBinding.h"
12 : #include "mozilla/dom/ThreadSafeChromeUtilsBinding.h"
13 : #include "mozilla/ErrorResult.h"
14 :
15 : namespace mozilla {
16 :
17 : namespace devtools {
18 : class HeapSnapshot;
19 : } // namespace devtools
20 :
21 : namespace dom {
22 :
23 : class ArrayBufferViewOrArrayBuffer;
24 : class PrecompiledScript;
25 : class Promise;
26 :
27 : class ThreadSafeChromeUtils
28 : {
29 : private:
30 : // Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
31 : static void SaveHeapSnapshotShared(GlobalObject& global,
32 : const HeapSnapshotBoundaries& boundaries,
33 : nsAString& filePath,
34 : nsAString& snapshotId,
35 : ErrorResult& rv);
36 :
37 : public:
38 : // Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
39 : static void SaveHeapSnapshot(GlobalObject& global,
40 : const HeapSnapshotBoundaries& boundaries,
41 : nsAString& filePath,
42 : ErrorResult& rv);
43 :
44 : // Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
45 : static void SaveHeapSnapshotGetId(GlobalObject& global,
46 : const HeapSnapshotBoundaries& boundaries,
47 : nsAString& snapshotId,
48 : ErrorResult& rv);
49 :
50 : // Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
51 : static already_AddRefed<devtools::HeapSnapshot> ReadHeapSnapshot(GlobalObject& global,
52 : const nsAString& filePath,
53 : ErrorResult& rv);
54 :
55 : static void NondeterministicGetWeakMapKeys(GlobalObject& aGlobal,
56 : JS::Handle<JS::Value> aMap,
57 : JS::MutableHandle<JS::Value> aRetval,
58 : ErrorResult& aRv);
59 :
60 : static void NondeterministicGetWeakSetKeys(GlobalObject& aGlobal,
61 : JS::Handle<JS::Value> aSet,
62 : JS::MutableHandle<JS::Value> aRetval,
63 : ErrorResult& aRv);
64 :
65 : static void Base64URLEncode(GlobalObject& aGlobal,
66 : const ArrayBufferViewOrArrayBuffer& aSource,
67 : const Base64URLEncodeOptions& aOptions,
68 : nsACString& aResult,
69 : ErrorResult& aRv);
70 :
71 : static void Base64URLDecode(GlobalObject& aGlobal,
72 : const nsACString& aString,
73 : const Base64URLDecodeOptions& aOptions,
74 : JS::MutableHandle<JSObject*> aRetval,
75 : ErrorResult& aRv);
76 : };
77 :
78 : class ChromeUtils : public ThreadSafeChromeUtils
79 : {
80 : public:
81 : static void
82 : OriginAttributesToSuffix(GlobalObject& aGlobal,
83 : const dom::OriginAttributesDictionary& aAttrs,
84 : nsCString& aSuffix);
85 :
86 : static bool
87 : OriginAttributesMatchPattern(dom::GlobalObject& aGlobal,
88 : const dom::OriginAttributesDictionary& aAttrs,
89 : const dom::OriginAttributesPatternDictionary& aPattern);
90 :
91 : static void
92 : CreateOriginAttributesFromOrigin(dom::GlobalObject& aGlobal,
93 : const nsAString& aOrigin,
94 : dom::OriginAttributesDictionary& aAttrs,
95 : ErrorResult& aRv);
96 :
97 : static void
98 : FillNonDefaultOriginAttributes(dom::GlobalObject& aGlobal,
99 : const dom::OriginAttributesDictionary& aAttrs,
100 : dom::OriginAttributesDictionary& aNewAttrs);
101 :
102 : static bool
103 : IsOriginAttributesEqual(dom::GlobalObject& aGlobal,
104 : const dom::OriginAttributesDictionary& aA,
105 : const dom::OriginAttributesDictionary& aB);
106 :
107 : static bool
108 : IsOriginAttributesEqual(const dom::OriginAttributesDictionary& aA,
109 : const dom::OriginAttributesDictionary& aB);
110 :
111 : static bool
112 0 : IsOriginAttributesEqualIgnoringFPD(const dom::OriginAttributesDictionary& aA,
113 : const dom::OriginAttributesDictionary& aB)
114 : {
115 0 : return aA.mAppId == aB.mAppId &&
116 0 : aA.mInIsolatedMozBrowser == aB.mInIsolatedMozBrowser &&
117 0 : aA.mUserContextId == aB.mUserContextId &&
118 0 : aA.mPrivateBrowsingId == aB.mPrivateBrowsingId;
119 : }
120 :
121 : // Implemented in js/xpconnect/loader/ChromeScriptLoader.cpp
122 : static already_AddRefed<Promise>
123 : CompileScript(GlobalObject& aGlobal,
124 : const nsAString& aUrl,
125 : const dom::CompileScriptOptionsDictionary& aOptions,
126 : ErrorResult& aRv);
127 : };
128 :
129 : } // namespace dom
130 : } // namespace mozilla
131 :
132 : #endif // mozilla_dom_ChromeUtils__
|