File: | var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp |
Warning: | line 1011, column 14 Value stored to 'rv' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | /* vim: set ts=8 sts=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 |
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | |
7 | #include "ServiceWorkerScriptCache.h" |
8 | |
9 | #include "js/Array.h" // JS::GetArrayLength |
10 | #include "js/PropertyAndElement.h" // JS_GetElement |
11 | #include "js/Utility.h" // JS::FreePolicy |
12 | #include "mozilla/TaskQueue.h" |
13 | #include "mozilla/Unused.h" |
14 | #include "mozilla/UniquePtr.h" |
15 | #include "mozilla/dom/CacheBinding.h" |
16 | #include "mozilla/dom/cache/CacheStorage.h" |
17 | #include "mozilla/dom/cache/Cache.h" |
18 | #include "mozilla/dom/Promise.h" |
19 | #include "mozilla/dom/PromiseWorkerProxy.h" |
20 | #include "mozilla/dom/ScriptLoader.h" |
21 | #include "mozilla/dom/WorkerCommon.h" |
22 | #include "mozilla/ipc/BackgroundUtils.h" |
23 | #include "mozilla/ipc/PBackgroundSharedTypes.h" |
24 | #include "mozilla/net/CookieJarSettings.h" |
25 | #include "mozilla/ScopeExit.h" |
26 | #include "mozilla/StaticPrefs_extensions.h" |
27 | #include "nsICacheInfoChannel.h" |
28 | #include "nsIHttpChannel.h" |
29 | #include "nsIStreamLoader.h" |
30 | #include "nsIThreadRetargetableRequest.h" |
31 | #include "nsIUUIDGenerator.h" |
32 | #include "nsIXPConnect.h" |
33 | |
34 | #include "nsIInputStreamPump.h" |
35 | #include "nsIPrincipal.h" |
36 | #include "nsIScriptSecurityManager.h" |
37 | #include "nsContentUtils.h" |
38 | #include "nsNetUtil.h" |
39 | #include "ServiceWorkerManager.h" |
40 | #include "nsStringStream.h" |
41 | |
42 | using mozilla::dom::cache::Cache; |
43 | using mozilla::dom::cache::CacheStorage; |
44 | using mozilla::ipc::PrincipalInfo; |
45 | |
46 | namespace mozilla::dom::serviceWorkerScriptCache { |
47 | |
48 | namespace { |
49 | |
50 | already_AddRefed<CacheStorage> CreateCacheStorage(JSContext* aCx, |
51 | nsIPrincipal* aPrincipal, |
52 | ErrorResult& aRv) { |
53 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 53); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 53; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
54 | MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipal)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipal", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 54); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")" ); do { *((volatile int*)__null) = 54; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
55 | |
56 | nsIXPConnect* xpc = nsContentUtils::XPConnect(); |
57 | MOZ_ASSERT(xpc, "This should never be null!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(xpc)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(xpc))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("xpc" " (" "This should never be null!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 57); AnnotateMozCrashReason("MOZ_ASSERT" "(" "xpc" ") (" "This should never be null!" ")"); do { *((volatile int*)__null) = 57; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
58 | JS::Rooted<JSObject*> sandbox(aCx); |
59 | aRv = xpc->CreateSandbox(aCx, aPrincipal, sandbox.address()); |
60 | if (NS_WARN_IF(aRv.Failed())NS_warn_if_impl(aRv.Failed(), "aRv.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 60)) { |
61 | return nullptr; |
62 | } |
63 | |
64 | // This is called when the JSContext is not in a realm, so CreateSandbox |
65 | // returned an unwrapped global. |
66 | MOZ_ASSERT(JS_IsGlobalObject(sandbox))do { static_assert( mozilla::detail::AssertionConditionType< decltype(JS_IsGlobalObject(sandbox))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(JS_IsGlobalObject(sandbox))) ), 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsGlobalObject(sandbox)" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 66); AnnotateMozCrashReason("MOZ_ASSERT" "(" "JS_IsGlobalObject(sandbox)" ")"); do { *((volatile int*)__null) = 66; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
67 | |
68 | nsCOMPtr<nsIGlobalObject> sandboxGlobalObject = xpc::NativeGlobal(sandbox); |
69 | if (!sandboxGlobalObject) { |
70 | aRv.Throw(NS_ERROR_FAILURE); |
71 | return nullptr; |
72 | } |
73 | |
74 | // We assume private browsing is not enabled here. The ScriptLoader |
75 | // explicitly fails for private browsing so there should never be |
76 | // a service worker running in private browsing mode. Therefore if |
77 | // we are purging scripts or running a comparison algorithm we cannot |
78 | // be in private browsing. |
79 | // |
80 | // Also, bypass the CacheStorage trusted origin checks. The ServiceWorker |
81 | // has validated the origin prior to this point. All the information |
82 | // to revalidate is not available now. |
83 | return CacheStorage::CreateOnMainThread(cache::CHROME_ONLY_NAMESPACE, |
84 | sandboxGlobalObject, aPrincipal, |
85 | true /* force trusted origin */, aRv); |
86 | } |
87 | |
88 | class CompareManager; |
89 | class CompareCache; |
90 | |
91 | // This class downloads a URL from the network, compare the downloaded script |
92 | // with an existing cache if provided, and report to CompareManager via calling |
93 | // ComparisonFinished(). |
94 | class CompareNetwork final : public nsIStreamLoaderObserver, |
95 | public nsIRequestObserver { |
96 | public: |
97 | NS_DECL_ISUPPORTSpublic: virtual nsresult QueryInterface(const nsIID& aIID , void** aInstancePtr) override; virtual MozExternalRefCountType AddRef(void) override; virtual MozExternalRefCountType Release (void) override; using HasThreadSafeRefCnt = std::false_type; protected: nsAutoRefCnt mRefCnt; nsAutoOwningThread _mOwningThread ; public: |
98 | NS_DECL_NSISTREAMLOADEROBSERVERvirtual nsresult OnStreamComplete(nsIStreamLoader *loader, nsISupports *ctxt, nsresult status, uint32_t resultLength, const uint8_t *result) override; |
99 | NS_DECL_NSIREQUESTOBSERVERvirtual nsresult OnStartRequest(nsIRequest *aRequest) override ; virtual nsresult OnStopRequest(nsIRequest *aRequest, nsresult aStatusCode) override; |
100 | |
101 | CompareNetwork(CompareManager* aManager, |
102 | ServiceWorkerRegistrationInfo* aRegistration, |
103 | bool aIsMainScript) |
104 | : mManager(aManager), |
105 | mRegistration(aRegistration), |
106 | mInternalHeaders(new InternalHeaders()), |
107 | mLoadFlags(nsIChannel::LOAD_BYPASS_SERVICE_WORKER), |
108 | mState(WaitingForInitialization), |
109 | mNetworkResult(NS_OK), |
110 | mCacheResult(NS_OK), |
111 | mIsMainScript(aIsMainScript), |
112 | mIsFromCache(false) { |
113 | MOZ_ASSERT(aManager)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aManager)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aManager))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aManager", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 113); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aManager" ")" ); do { *((volatile int*)__null) = 113; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
114 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 114); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 114; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
115 | } |
116 | |
117 | nsresult Initialize(nsIPrincipal* aPrincipal, const nsACString& aURL, |
118 | Cache* const aCache); |
119 | |
120 | void Abort(); |
121 | |
122 | void NetworkFinish(nsresult aRv); |
123 | |
124 | void CacheFinish(nsresult aRv); |
125 | |
126 | const nsCString& URL() const { |
127 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 127); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 127; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
128 | return mURL; |
129 | } |
130 | |
131 | const nsString& Buffer() const { |
132 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 132); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 132; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
133 | return mBuffer; |
134 | } |
135 | |
136 | const ChannelInfo& GetChannelInfo() const { return mChannelInfo; } |
137 | |
138 | already_AddRefed<InternalHeaders> GetInternalHeaders() const { |
139 | RefPtr<InternalHeaders> internalHeaders = mInternalHeaders; |
140 | return internalHeaders.forget(); |
141 | } |
142 | |
143 | UniquePtr<PrincipalInfo> TakePrincipalInfo() { |
144 | return std::move(mPrincipalInfo); |
145 | } |
146 | |
147 | bool Succeeded() const { return NS_SUCCEEDED(mNetworkResult)((bool)(__builtin_expect(!!(!NS_FAILED_impl(mNetworkResult)), 1))); } |
148 | |
149 | const nsTArray<nsCString>& URLList() const { return mURLList; } |
150 | |
151 | private: |
152 | ~CompareNetwork() { |
153 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 153); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 153; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
154 | MOZ_ASSERT(!mCC)do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mCC)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(!mCC))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("!mCC", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 154); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mCC" ")"); do { *((volatile int*)__null) = 154; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
155 | } |
156 | |
157 | void Finish(); |
158 | |
159 | nsresult SetPrincipalInfo(nsIChannel* aChannel); |
160 | |
161 | RefPtr<CompareManager> mManager; |
162 | RefPtr<CompareCache> mCC; |
163 | RefPtr<ServiceWorkerRegistrationInfo> mRegistration; |
164 | |
165 | nsCOMPtr<nsIChannel> mChannel; |
166 | nsString mBuffer; |
167 | nsCString mURL; |
168 | ChannelInfo mChannelInfo; |
169 | RefPtr<InternalHeaders> mInternalHeaders; |
170 | UniquePtr<PrincipalInfo> mPrincipalInfo; |
171 | nsTArray<nsCString> mURLList; |
172 | |
173 | nsCString mMaxScope; |
174 | nsLoadFlags mLoadFlags; |
175 | |
176 | enum { |
177 | WaitingForInitialization, |
178 | WaitingForBothFinished, |
179 | WaitingForNetworkFinished, |
180 | WaitingForCacheFinished, |
181 | Finished |
182 | } mState; |
183 | |
184 | nsresult mNetworkResult; |
185 | nsresult mCacheResult; |
186 | |
187 | const bool mIsMainScript; |
188 | bool mIsFromCache; |
189 | }; |
190 | |
191 | NS_IMPL_ISUPPORTS(CompareNetwork, nsIStreamLoaderObserver, nsIRequestObserver)MozExternalRefCountType CompareNetwork::AddRef(void) { static_assert (!std::is_destructible_v<CompareNetwork>, "Reference-counted class " "CompareNetwork" " should not have a public destructor. " "Make this class's destructor non-public" ); do { static_assert( mozilla::detail::AssertionConditionType <decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0" " (" "illegal refcnt" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 191); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { *((volatile int*)__null) = 191; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); do { static_assert( mozilla::detail::AssertionConditionType <decltype("CompareNetwork" != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!("CompareNetwork" != nullptr) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"CompareNetwork\" != nullptr" " (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 191); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"CompareNetwork\" != nullptr" ") (" "Must specify a name" ")"); do { *((volatile int*)__null ) = 191; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread .AssertOwnership("CompareNetwork" " not thread-safe"); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this), (count), ("CompareNetwork" ), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType CompareNetwork::Release(void) { do { static_assert( mozilla:: detail::AssertionConditionType<decltype(int32_t(mRefCnt) > 0)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 191); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { *((volatile int*)__null) = 191 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); do { static_assert( mozilla::detail::AssertionConditionType <decltype("CompareNetwork" != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!("CompareNetwork" != nullptr) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"CompareNetwork\" != nullptr" " (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 191); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"CompareNetwork\" != nullptr" ") (" "Must specify a name" ")"); do { *((volatile int*)__null ) = 191; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread .AssertOwnership("CompareNetwork" " not thread-safe"); const char * const nametmp = "CompareNetwork"; nsrefcnt count = --mRefCnt ; NS_LogRelease((this), (count), (nametmp)); if (count == 0) { mRefCnt = 1; delete (this); return 0; } return count; } nsresult CompareNetwork::QueryInterface(const nsIID& aIID, void** aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "QueryInterface requires a non-NULL destination!", "aInstancePtr" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 191); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE ; static_assert(2 > 0, "Need more arguments to NS_INTERFACE_TABLE" ); static const QITableEntry table[] = { {&mozilla::detail ::kImplementedIID<CompareNetwork, nsIStreamLoaderObserver> , int32_t( reinterpret_cast<char*>(static_cast<nsIStreamLoaderObserver *>((CompareNetwork*)0x1000)) - reinterpret_cast<char*> ((CompareNetwork*)0x1000))}, {&mozilla::detail::kImplementedIID <CompareNetwork, nsIRequestObserver>, int32_t( reinterpret_cast <char*>(static_cast<nsIRequestObserver*>((CompareNetwork *)0x1000)) - reinterpret_cast<char*>((CompareNetwork*)0x1000 ))}, {&mozilla::detail::kImplementedIID<CompareNetwork , nsISupports>, int32_t(reinterpret_cast<char*>(static_cast <nsISupports*>( static_cast<nsIStreamLoaderObserver* >((CompareNetwork*)0x1000))) - reinterpret_cast<char*> ((CompareNetwork*)0x1000))}, { nullptr, 0 } } ; static_assert ((sizeof(table) / sizeof(table[0])) > 1, "need at least 1 interface" ); rv = NS_TableDrivenQI(static_cast<void*>(this), aIID , aInstancePtr, table); return rv; } |
192 | |
193 | // This class gets a cached Response from the CacheStorage and then it calls |
194 | // CacheFinish() in the CompareNetwork. |
195 | class CompareCache final : public PromiseNativeHandler, |
196 | public nsIStreamLoaderObserver { |
197 | public: |
198 | NS_DECL_ISUPPORTSpublic: virtual nsresult QueryInterface(const nsIID& aIID , void** aInstancePtr) override; virtual MozExternalRefCountType AddRef(void) override; virtual MozExternalRefCountType Release (void) override; using HasThreadSafeRefCnt = std::false_type; protected: nsAutoRefCnt mRefCnt; nsAutoOwningThread _mOwningThread ; public: |
199 | NS_DECL_NSISTREAMLOADEROBSERVERvirtual nsresult OnStreamComplete(nsIStreamLoader *loader, nsISupports *ctxt, nsresult status, uint32_t resultLength, const uint8_t *result) override; |
200 | |
201 | explicit CompareCache(CompareNetwork* aCN) |
202 | : mCN(aCN), mState(WaitingForInitialization), mInCache(false) { |
203 | MOZ_ASSERT(aCN)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCN)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(aCN))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("aCN", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 203); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCN" ")"); do { *((volatile int*)__null) = 203; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
204 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 204); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 204; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
205 | } |
206 | |
207 | nsresult Initialize(Cache* const aCache, const nsACString& aURL); |
208 | |
209 | void Finish(nsresult aStatus, bool aInCache); |
210 | |
211 | void Abort(); |
212 | |
213 | virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, |
214 | ErrorResult& aRv) override; |
215 | |
216 | virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, |
217 | ErrorResult& aRv) override; |
218 | |
219 | const nsString& Buffer() const { |
220 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 220); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 220; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
221 | return mBuffer; |
222 | } |
223 | |
224 | bool InCache() { return mInCache; } |
225 | |
226 | private: |
227 | ~CompareCache() { MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 227); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 227; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } |
228 | |
229 | void ManageValueResult(JSContext* aCx, JS::Handle<JS::Value> aValue); |
230 | |
231 | RefPtr<CompareNetwork> mCN; |
232 | nsCOMPtr<nsIInputStreamPump> mPump; |
233 | |
234 | nsCString mURL; |
235 | nsString mBuffer; |
236 | |
237 | enum { |
238 | WaitingForInitialization, |
239 | WaitingForScript, |
240 | Finished, |
241 | } mState; |
242 | |
243 | bool mInCache; |
244 | }; |
245 | |
246 | NS_IMPL_ISUPPORTS(CompareCache, nsIStreamLoaderObserver)MozExternalRefCountType CompareCache::AddRef(void) { static_assert (!std::is_destructible_v<CompareCache>, "Reference-counted class " "CompareCache" " should not have a public destructor. " "Make this class's destructor non-public" ); do { static_assert( mozilla::detail::AssertionConditionType <decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0" " (" "illegal refcnt" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 246); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { *((volatile int*)__null) = 246; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); do { static_assert( mozilla::detail::AssertionConditionType <decltype("CompareCache" != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!("CompareCache" != nullptr))) , 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"CompareCache\" != nullptr" " (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 246); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"CompareCache\" != nullptr" ") (" "Must specify a name" ")"); do { *((volatile int*)__null ) = 246; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread .AssertOwnership("CompareCache" " not thread-safe"); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this), (count), ("CompareCache" ), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType CompareCache::Release(void) { do { static_assert( mozilla::detail ::AssertionConditionType<decltype(int32_t(mRefCnt) > 0) >::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 246); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { *((volatile int*)__null) = 246 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); do { static_assert( mozilla::detail::AssertionConditionType <decltype("CompareCache" != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!("CompareCache" != nullptr))) , 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"CompareCache\" != nullptr" " (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 246); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"CompareCache\" != nullptr" ") (" "Must specify a name" ")"); do { *((volatile int*)__null ) = 246; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread .AssertOwnership("CompareCache" " not thread-safe"); const char * const nametmp = "CompareCache"; nsrefcnt count = --mRefCnt; NS_LogRelease((this), (count), (nametmp)); if (count == 0) { mRefCnt = 1; delete (this); return 0; } return count; } nsresult CompareCache::QueryInterface(const nsIID& aIID, void** aInstancePtr ) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "QueryInterface requires a non-NULL destination!", "aInstancePtr" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 246); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE ; static_assert(1 > 0, "Need more arguments to NS_INTERFACE_TABLE" ); static const QITableEntry table[] = { {&mozilla::detail ::kImplementedIID<CompareCache, nsIStreamLoaderObserver> , int32_t( reinterpret_cast<char*>(static_cast<nsIStreamLoaderObserver *>((CompareCache*)0x1000)) - reinterpret_cast<char*> ((CompareCache*)0x1000))}, {&mozilla::detail::kImplementedIID <CompareCache, nsISupports>, int32_t(reinterpret_cast< char*>(static_cast<nsISupports*>( static_cast<nsIStreamLoaderObserver *>((CompareCache*)0x1000))) - reinterpret_cast<char*> ((CompareCache*)0x1000))}, { nullptr, 0 } } ; static_assert(( sizeof(table) / sizeof(table[0])) > 1, "need at least 1 interface" ); rv = NS_TableDrivenQI(static_cast<void*>(this), aIID , aInstancePtr, table); return rv; } |
247 | |
248 | class CompareManager final : public PromiseNativeHandler { |
249 | public: |
250 | NS_DECL_ISUPPORTSpublic: virtual nsresult QueryInterface(const nsIID& aIID , void** aInstancePtr) override; virtual MozExternalRefCountType AddRef(void) override; virtual MozExternalRefCountType Release (void) override; using HasThreadSafeRefCnt = std::false_type; protected: nsAutoRefCnt mRefCnt; nsAutoOwningThread _mOwningThread ; public: |
251 | |
252 | explicit CompareManager(ServiceWorkerRegistrationInfo* aRegistration, |
253 | CompareCallback* aCallback) |
254 | : mRegistration(aRegistration), |
255 | mCallback(aCallback), |
256 | mLoadFlags(nsIChannel::LOAD_BYPASS_SERVICE_WORKER), |
257 | mState(WaitingForInitialization), |
258 | mPendingCount(0), |
259 | mOnFailure(OnFailure::DoNothing), |
260 | mAreScriptsEqual(true) { |
261 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 261); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 261; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
262 | MOZ_ASSERT(aRegistration)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aRegistration)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aRegistration))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aRegistration", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 262); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRegistration" ")"); do { *((volatile int*)__null) = 262; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
263 | } |
264 | |
265 | nsresult Initialize(nsIPrincipal* aPrincipal, const nsACString& aURL, |
266 | const nsAString& aCacheName); |
267 | |
268 | void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, |
269 | ErrorResult& aRv) override; |
270 | |
271 | void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, |
272 | ErrorResult& aRv) override; |
273 | |
274 | CacheStorage* CacheStorage_() { |
275 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 275); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 275; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
276 | MOZ_ASSERT(mCacheStorage)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCacheStorage)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCacheStorage))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mCacheStorage", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 276); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCacheStorage" ")"); do { *((volatile int*)__null) = 276; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
277 | return mCacheStorage; |
278 | } |
279 | |
280 | void ComparisonFinished(nsresult aStatus, bool aIsMainScript, bool aIsEqual, |
281 | const nsACString& aMaxScope, nsLoadFlags aLoadFlags) { |
282 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 282); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 282; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
283 | if (mState == Finished) { |
284 | return; |
285 | } |
286 | |
287 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForScriptOrComparisonResult)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForScriptOrComparisonResult)>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(mState == WaitingForScriptOrComparisonResult))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mState == WaitingForScriptOrComparisonResult" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 287); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForScriptOrComparisonResult" ")"); do { *((volatile int*)__null) = 287; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
288 | |
289 | if (NS_WARN_IF(NS_FAILED(aStatus))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aStatus )), 0))), "NS_FAILED(aStatus)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 289)) { |
290 | Fail(aStatus); |
291 | return; |
292 | } |
293 | |
294 | mAreScriptsEqual = mAreScriptsEqual && aIsEqual; |
295 | |
296 | if (aIsMainScript) { |
297 | mMaxScope = aMaxScope; |
298 | mLoadFlags = aLoadFlags; |
299 | } |
300 | |
301 | // Check whether all CompareNetworks finished their jobs. |
302 | MOZ_DIAGNOSTIC_ASSERT(mPendingCount > 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPendingCount > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPendingCount > 0))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("mPendingCount > 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 302); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mPendingCount > 0" ")"); do { *((volatile int*)__null) = 302; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
303 | if (--mPendingCount) { |
304 | return; |
305 | } |
306 | |
307 | if (mAreScriptsEqual) { |
308 | MOZ_ASSERT(mCallback)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCallback)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCallback))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mCallback", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 308); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCallback" ")" ); do { *((volatile int*)__null) = 308; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
309 | mCallback->ComparisonResult(aStatus, true /* aSameScripts */, mOnFailure, |
310 | u""_ns, mMaxScope, mLoadFlags); |
311 | Cleanup(); |
312 | return; |
313 | } |
314 | |
315 | // Write to Cache so ScriptLoader reads succeed. |
316 | WriteNetworkBufferToNewCache(); |
317 | } |
318 | |
319 | private: |
320 | ~CompareManager() { |
321 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 321); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 321; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
322 | MOZ_ASSERT(mCNList.Length() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCNList.Length() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCNList.Length() == 0))), 0) )) { do { } while (false); MOZ_ReportAssertionFailure("mCNList.Length() == 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 322); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCNList.Length() == 0" ")"); do { *((volatile int*)__null) = 322; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
323 | } |
324 | |
325 | void Fail(nsresult aStatus); |
326 | |
327 | void Cleanup(); |
328 | |
329 | nsresult FetchScript(const nsACString& aURL, bool aIsMainScript, |
330 | Cache* const aCache = nullptr) { |
331 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 331); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 331; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
332 | |
333 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForInitialization ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 334); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult" ")"); do { *((volatile int*)__null) = 334; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
334 | mState == WaitingForScriptOrComparisonResult)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 334); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForInitialization || mState == WaitingForScriptOrComparisonResult" ")"); do { *((volatile int*)__null) = 334; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
335 | |
336 | RefPtr<CompareNetwork> cn = |
337 | new CompareNetwork(this, mRegistration, aIsMainScript); |
338 | mCNList.AppendElement(cn); |
339 | mPendingCount += 1; |
340 | |
341 | nsresult rv = cn->Initialize(mPrincipal, aURL, aCache); |
342 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 342)) { |
343 | return rv; |
344 | } |
345 | |
346 | return NS_OK; |
347 | } |
348 | |
349 | void ManageOldCache(JSContext* aCx, JS::Handle<JS::Value> aValue) { |
350 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForExistingOpen)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForExistingOpen)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mState == WaitingForExistingOpen ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForExistingOpen", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 350); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForExistingOpen" ")"); do { *((volatile int*)__null) = 350; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
351 | |
352 | // RAII Cleanup when fails. |
353 | nsresult rv = NS_ERROR_FAILURE; |
354 | auto guard = MakeScopeExit([&] { Fail(rv); }); |
355 | |
356 | if (NS_WARN_IF(!aValue.isObject())NS_warn_if_impl(!aValue.isObject(), "!aValue.isObject()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 356)) { |
357 | return; |
358 | } |
359 | |
360 | MOZ_ASSERT(!mOldCache)do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mOldCache)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mOldCache))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mOldCache", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 360); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mOldCache" ")" ); do { *((volatile int*)__null) = 360; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
361 | JS::Rooted<JSObject*> obj(aCx, &aValue.toObject()); |
362 | if (NS_WARN_IF(!obj)NS_warn_if_impl(!obj, "!obj", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 362) || |
363 | NS_WARN_IF(NS_FAILED(UNWRAP_OBJECT(Cache, obj, mOldCache)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(mozilla ::dom::binding_detail::UnwrapObjectWithCrossOriginAsserts< mozilla::dom::prototypes::id::Cache, mozilla::dom::Cache_Binding ::NativeType>(obj, mOldCache))), 0))), "NS_FAILED(UNWRAP_OBJECT(Cache, obj, mOldCache))" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 363)) { |
364 | return; |
365 | } |
366 | |
367 | Optional<RequestOrUTF8String> request; |
368 | CacheQueryOptions options; |
369 | ErrorResult error; |
370 | RefPtr<Promise> promise = mOldCache->Keys(aCx, request, options, error); |
371 | if (NS_WARN_IF(error.Failed())NS_warn_if_impl(error.Failed(), "error.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 371)) { |
372 | // No exception here because there are no ReadableStreams involved here. |
373 | MOZ_ASSERT(!error.IsJSException())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!error.IsJSException())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!error.IsJSException()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!error.IsJSException()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 373); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!error.IsJSException()" ")"); do { *((volatile int*)__null) = 373; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
374 | rv = error.StealNSResult(); |
375 | return; |
376 | } |
377 | |
378 | mState = WaitingForExistingKeys; |
379 | promise->AppendNativeHandler(this); |
380 | guard.release(); |
381 | } |
382 | |
383 | void ManageOldKeys(JSContext* aCx, JS::Handle<JS::Value> aValue) { |
384 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForExistingKeys)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForExistingKeys)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mState == WaitingForExistingKeys ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForExistingKeys", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 384); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForExistingKeys" ")"); do { *((volatile int*)__null) = 384; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
385 | |
386 | // RAII Cleanup when fails. |
387 | nsresult rv = NS_ERROR_FAILURE; |
388 | auto guard = MakeScopeExit([&] { Fail(rv); }); |
389 | |
390 | if (NS_WARN_IF(!aValue.isObject())NS_warn_if_impl(!aValue.isObject(), "!aValue.isObject()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 390)) { |
391 | return; |
392 | } |
393 | |
394 | JS::Rooted<JSObject*> obj(aCx, &aValue.toObject()); |
395 | if (NS_WARN_IF(!obj)NS_warn_if_impl(!obj, "!obj", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 395)) { |
396 | return; |
397 | } |
398 | |
399 | uint32_t len = 0; |
400 | if (!JS::GetArrayLength(aCx, obj, &len)) { |
401 | return; |
402 | } |
403 | |
404 | // Fetch and compare the source scripts. |
405 | MOZ_ASSERT(mPendingCount == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPendingCount == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPendingCount == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mPendingCount == 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 405); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPendingCount == 0" ")"); do { *((volatile int*)__null) = 405; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
406 | |
407 | mState = WaitingForScriptOrComparisonResult; |
408 | |
409 | bool hasMainScript = false; |
410 | AutoTArray<nsCString, 8> urlList; |
411 | |
412 | // Extract the list of URLs in the old cache. |
413 | for (uint32_t i = 0; i < len; ++i) { |
414 | JS::Rooted<JS::Value> val(aCx); |
415 | if (NS_WARN_IF(!JS_GetElement(aCx, obj, i, &val))NS_warn_if_impl(!JS_GetElement(aCx, obj, i, &val), "!JS_GetElement(aCx, obj, i, &val)" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 415) || |
416 | NS_WARN_IF(!val.isObject())NS_warn_if_impl(!val.isObject(), "!val.isObject()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 416)) { |
417 | return; |
418 | } |
419 | |
420 | Request* request; |
421 | JS::Rooted<JSObject*> requestObj(aCx, &val.toObject()); |
422 | if (NS_WARN_IF(NS_FAILED(UNWRAP_OBJECT(Request, &requestObj, request)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(mozilla ::dom::binding_detail::UnwrapObjectWithCrossOriginAsserts< mozilla::dom::prototypes::id::Request, mozilla::dom::Request_Binding ::NativeType>(&requestObj, request))), 0))), "NS_FAILED(UNWRAP_OBJECT(Request, &requestObj, request))" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 422)) { |
423 | return; |
424 | }; |
425 | |
426 | nsCString url; |
427 | request->GetUrl(url); |
428 | |
429 | if (!hasMainScript && url == mURL) { |
430 | hasMainScript = true; |
431 | } |
432 | |
433 | urlList.AppendElement(std::move(url)); |
434 | } |
435 | |
436 | // If the main script is missing, then something has gone wrong. We |
437 | // will try to continue with the update process to trigger a new |
438 | // installation. If that fails, however, then uninstall the registration |
439 | // because it is broken in a way that cannot be fixed. |
440 | if (!hasMainScript) { |
441 | mOnFailure = OnFailure::Uninstall; |
442 | } |
443 | |
444 | // Always make sure to fetch the main script. If the old cache has |
445 | // no entries or the main script entry is missing, then the loop below |
446 | // may not trigger it. This should not really happen, but we handle it |
447 | // gracefully if it does occur. Its possible the bad cache state is due |
448 | // to a crash or shutdown during an update, etc. |
449 | rv = FetchScript(mURL, true /* aIsMainScript */, mOldCache); |
450 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 450)) { |
451 | return; |
452 | } |
453 | |
454 | for (const auto& url : urlList) { |
455 | // We explicitly start the fetch for the main script above. |
456 | if (mURL == url) { |
457 | continue; |
458 | } |
459 | |
460 | rv = FetchScript(url, false /* aIsMainScript */, mOldCache); |
461 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 461)) { |
462 | return; |
463 | } |
464 | } |
465 | |
466 | guard.release(); |
467 | } |
468 | |
469 | void ManageNewCache(JSContext* aCx, JS::Handle<JS::Value> aValue) { |
470 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForOpen)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForOpen)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mState == WaitingForOpen))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mState == WaitingForOpen" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 470); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForOpen" ")"); do { *((volatile int*)__null) = 470; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
471 | |
472 | // RAII Cleanup when fails. |
473 | nsresult rv = NS_ERROR_FAILURE; |
474 | auto guard = MakeScopeExit([&] { Fail(rv); }); |
475 | |
476 | if (NS_WARN_IF(!aValue.isObject())NS_warn_if_impl(!aValue.isObject(), "!aValue.isObject()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 476)) { |
477 | return; |
478 | } |
479 | |
480 | JS::Rooted<JSObject*> obj(aCx, &aValue.toObject()); |
481 | if (NS_WARN_IF(!obj)NS_warn_if_impl(!obj, "!obj", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 481)) { |
482 | return; |
483 | } |
484 | |
485 | Cache* cache = nullptr; |
486 | rv = UNWRAP_OBJECT(Cache, &obj, cache)mozilla::dom::binding_detail::UnwrapObjectWithCrossOriginAsserts < mozilla::dom::prototypes::id::Cache, mozilla::dom::Cache_Binding ::NativeType>(&obj, cache); |
487 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 487)) { |
488 | return; |
489 | } |
490 | |
491 | // Just to be safe. |
492 | RefPtr<Cache> kungfuDeathGrip = cache; |
493 | |
494 | MOZ_ASSERT(mPendingCount == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPendingCount == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPendingCount == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mPendingCount == 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 494); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPendingCount == 0" ")"); do { *((volatile int*)__null) = 494; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
495 | for (uint32_t i = 0; i < mCNList.Length(); ++i) { |
496 | // We bail out immediately when something goes wrong. |
497 | rv = WriteToCache(aCx, cache, mCNList[i]); |
498 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 498)) { |
499 | return; |
500 | } |
501 | } |
502 | |
503 | mState = WaitingForPut; |
504 | guard.release(); |
505 | } |
506 | |
507 | void WriteNetworkBufferToNewCache() { |
508 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 508); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 508; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
509 | MOZ_ASSERT(mCNList.Length() != 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCNList.Length() != 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCNList.Length() != 0))), 0) )) { do { } while (false); MOZ_ReportAssertionFailure("mCNList.Length() != 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 509); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCNList.Length() != 0" ")"); do { *((volatile int*)__null) = 509; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
510 | MOZ_ASSERT(mCacheStorage)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCacheStorage)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCacheStorage))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mCacheStorage", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 510); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCacheStorage" ")"); do { *((volatile int*)__null) = 510; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
511 | MOZ_ASSERT(mNewCacheName.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(mNewCacheName.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mNewCacheName.IsEmpty()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("mNewCacheName.IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 511); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mNewCacheName.IsEmpty()" ")"); do { *((volatile int*)__null) = 511; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
512 | |
513 | ErrorResult result; |
514 | result = serviceWorkerScriptCache::GenerateCacheName(mNewCacheName); |
515 | if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 515)) { |
516 | MOZ_ASSERT(!result.IsErrorWithMessage())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!result.IsErrorWithMessage())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!result.IsErrorWithMessage() ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!result.IsErrorWithMessage()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 516); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!result.IsErrorWithMessage()" ")"); do { *((volatile int*)__null) = 516; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
517 | Fail(result.StealNSResult()); |
518 | return; |
519 | } |
520 | |
521 | RefPtr<Promise> cacheOpenPromise = |
522 | mCacheStorage->Open(mNewCacheName, result); |
523 | if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 523)) { |
524 | MOZ_ASSERT(!result.IsErrorWithMessage())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!result.IsErrorWithMessage())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!result.IsErrorWithMessage() ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!result.IsErrorWithMessage()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 524); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!result.IsErrorWithMessage()" ")"); do { *((volatile int*)__null) = 524; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
525 | Fail(result.StealNSResult()); |
526 | return; |
527 | } |
528 | |
529 | mState = WaitingForOpen; |
530 | cacheOpenPromise->AppendNativeHandler(this); |
531 | } |
532 | |
533 | nsresult WriteToCache(JSContext* aCx, Cache* aCache, CompareNetwork* aCN) { |
534 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 534); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 534; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
535 | MOZ_ASSERT(aCache)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCache)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(aCache))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aCache", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 535); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCache" ")") ; do { *((volatile int*)__null) = 535; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
536 | MOZ_ASSERT(aCN)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCN)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(aCN))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("aCN", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 536); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCN" ")"); do { *((volatile int*)__null) = 536; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
537 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForOpen)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForOpen)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mState == WaitingForOpen))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mState == WaitingForOpen" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 537); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForOpen" ")"); do { *((volatile int*)__null) = 537; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
538 | |
539 | // We don't have to save any information from a failed CompareNetwork. |
540 | if (!aCN->Succeeded()) { |
541 | return NS_OK; |
542 | } |
543 | |
544 | nsCOMPtr<nsIInputStream> body; |
545 | nsresult rv = NS_NewCStringInputStream( |
546 | getter_AddRefs(body), NS_ConvertUTF16toUTF8(aCN->Buffer())); |
547 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 547)) { |
548 | return rv; |
549 | } |
550 | |
551 | SafeRefPtr<InternalResponse> ir = |
552 | MakeSafeRefPtr<InternalResponse>(200, "OK"_ns); |
553 | ir->SetBody(body, aCN->Buffer().Length()); |
554 | ir->SetURLList(aCN->URLList()); |
555 | |
556 | ir->InitChannelInfo(aCN->GetChannelInfo()); |
557 | UniquePtr<PrincipalInfo> principalInfo = aCN->TakePrincipalInfo(); |
558 | if (principalInfo) { |
559 | ir->SetPrincipalInfo(std::move(principalInfo)); |
560 | } |
561 | |
562 | RefPtr<InternalHeaders> internalHeaders = aCN->GetInternalHeaders(); |
563 | ir->Headers()->Fill(*(internalHeaders.get()), IgnoreErrors()); |
564 | |
565 | RefPtr<Response> response = |
566 | new Response(aCache->GetGlobalObject(), std::move(ir), nullptr); |
567 | |
568 | RequestOrUTF8String request; |
569 | request.SetAsUTF8String().ShareOrDependUpon(aCN->URL()); |
570 | |
571 | // For now we have to wait until the Put Promise is fulfilled before we can |
572 | // continue since Cache does not yet support starting a read that is being |
573 | // written to. |
574 | ErrorResult result; |
575 | RefPtr<Promise> cachePromise = aCache->Put(aCx, request, *response, result); |
576 | result.WouldReportJSException(); |
577 | if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 577)) { |
578 | // No exception here because there are no ReadableStreams involved here. |
579 | MOZ_ASSERT(!result.IsJSException())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!result.IsJSException())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!result.IsJSException()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!result.IsJSException()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 579); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!result.IsJSException()" ")"); do { *((volatile int*)__null) = 579; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
580 | MOZ_ASSERT(!result.IsErrorWithMessage())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!result.IsErrorWithMessage())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!result.IsErrorWithMessage() ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!result.IsErrorWithMessage()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 580); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!result.IsErrorWithMessage()" ")"); do { *((volatile int*)__null) = 580; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
581 | return result.StealNSResult(); |
582 | } |
583 | |
584 | mPendingCount += 1; |
585 | cachePromise->AppendNativeHandler(this); |
586 | return NS_OK; |
587 | } |
588 | |
589 | RefPtr<ServiceWorkerRegistrationInfo> mRegistration; |
590 | RefPtr<CompareCallback> mCallback; |
591 | RefPtr<CacheStorage> mCacheStorage; |
592 | |
593 | nsTArray<RefPtr<CompareNetwork>> mCNList; |
594 | |
595 | nsCString mURL; |
596 | RefPtr<nsIPrincipal> mPrincipal; |
597 | |
598 | // Used for the old cache where saves the old source scripts. |
599 | RefPtr<Cache> mOldCache; |
600 | |
601 | // Only used if the network script has changed and needs to be cached. |
602 | nsString mNewCacheName; |
603 | |
604 | nsCString mMaxScope; |
605 | nsLoadFlags mLoadFlags; |
606 | |
607 | enum { |
608 | WaitingForInitialization, |
609 | WaitingForExistingOpen, |
610 | WaitingForExistingKeys, |
611 | WaitingForScriptOrComparisonResult, |
612 | WaitingForOpen, |
613 | WaitingForPut, |
614 | Finished |
615 | } mState; |
616 | |
617 | uint32_t mPendingCount; |
618 | OnFailure mOnFailure; |
619 | bool mAreScriptsEqual; |
620 | }; |
621 | |
622 | NS_IMPL_ISUPPORTS0(CompareManager)MozExternalRefCountType CompareManager::AddRef(void) { static_assert (!std::is_destructible_v<CompareManager>, "Reference-counted class " "CompareManager" " should not have a public destructor. " "Make this class's destructor non-public" ); do { static_assert( mozilla::detail::AssertionConditionType <decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0" " (" "illegal refcnt" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 622); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { *((volatile int*)__null) = 622; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); do { static_assert( mozilla::detail::AssertionConditionType <decltype("CompareManager" != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!("CompareManager" != nullptr) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"CompareManager\" != nullptr" " (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 622); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"CompareManager\" != nullptr" ") (" "Must specify a name" ")"); do { *((volatile int*)__null ) = 622; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread .AssertOwnership("CompareManager" " not thread-safe"); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this), (count), ("CompareManager" ), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType CompareManager::Release(void) { do { static_assert( mozilla:: detail::AssertionConditionType<decltype(int32_t(mRefCnt) > 0)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 622); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { *((volatile int*)__null) = 622 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); do { static_assert( mozilla::detail::AssertionConditionType <decltype("CompareManager" != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!("CompareManager" != nullptr) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"CompareManager\" != nullptr" " (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 622); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"CompareManager\" != nullptr" ") (" "Must specify a name" ")"); do { *((volatile int*)__null ) = 622; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread .AssertOwnership("CompareManager" " not thread-safe"); const char * const nametmp = "CompareManager"; nsrefcnt count = --mRefCnt ; NS_LogRelease((this), (count), (nametmp)); if (count == 0) { mRefCnt = 1; delete (this); return 0; } return count; } nsresult CompareManager::QueryInterface(const nsIID& aIID, void** aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "QueryInterface requires a non-NULL destination!", "aInstancePtr" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 622); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE ; static const QITableEntry table[] = { {&mozilla::detail ::kImplementedIID<CompareManager, nsISupports>, int32_t ( reinterpret_cast<char*>(static_cast<nsISupports*> ((CompareManager*)0x1000)) - reinterpret_cast<char*>((CompareManager *)0x1000))}, { nullptr, 0 } } ; static_assert((sizeof(table) / sizeof(table[0])) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI(static_cast<void*>(this), aIID, aInstancePtr , table); return rv; } |
623 | |
624 | nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal, |
625 | const nsACString& aURL, |
626 | Cache* const aCache) { |
627 | MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipal)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipal", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 627); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")" ); do { *((volatile int*)__null) = 627; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
628 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 628); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 628; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
629 | |
630 | nsCOMPtr<nsIURI> uri; |
631 | nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL); |
632 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 632)) { |
633 | return rv; |
634 | } |
635 | |
636 | mURL = aURL; |
637 | mURLList.AppendElement(mURL); |
638 | |
639 | nsCOMPtr<nsILoadGroup> loadGroup; |
640 | rv = NS_NewLoadGroup(getter_AddRefs(loadGroup), aPrincipal); |
641 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 641)) { |
642 | return rv; |
643 | } |
644 | |
645 | // Update LoadFlags for propagating to ServiceWorkerInfo. |
646 | mLoadFlags = nsIChannel::LOAD_BYPASS_SERVICE_WORKER; |
647 | |
648 | ServiceWorkerUpdateViaCache uvc = mRegistration->GetUpdateViaCache(); |
649 | if (uvc == ServiceWorkerUpdateViaCache::None || |
650 | (uvc == ServiceWorkerUpdateViaCache::Imports && mIsMainScript)) { |
651 | mLoadFlags |= nsIRequest::VALIDATE_ALWAYS; |
652 | } |
653 | |
654 | if (mRegistration->IsLastUpdateCheckTimeOverOneDay()) { |
655 | mLoadFlags |= nsIRequest::LOAD_BYPASS_CACHE; |
656 | } |
657 | |
658 | // Different settings are needed for fetching imported scripts, since they |
659 | // might be cross-origin scripts. |
660 | uint32_t secFlags = |
661 | mIsMainScript ? nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED |
662 | : nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_INHERITS_SEC_CONTEXT; |
663 | |
664 | nsContentPolicyType contentPolicyType = |
665 | mIsMainScript ? nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER |
666 | : nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS; |
667 | |
668 | // Create a new cookieJarSettings. |
669 | nsCOMPtr<nsICookieJarSettings> cookieJarSettings = |
670 | mozilla::net::CookieJarSettings::Create(aPrincipal); |
671 | |
672 | // Populate the partitionKey by using the given prinicpal. The ServiceWorkers |
673 | // are using the foreign partitioned principal, so we can get the partitionKey |
674 | // from it and the partitionKey will only exist if it's in the third-party |
675 | // context. In first-party context, we can still use the uri to set the |
676 | // partitionKey. |
677 | if (!aPrincipal->OriginAttributesRef().mPartitionKey.IsEmpty()) { |
678 | net::CookieJarSettings::Cast(cookieJarSettings) |
679 | ->SetPartitionKey(aPrincipal->OriginAttributesRef().mPartitionKey); |
680 | } else { |
681 | net::CookieJarSettings::Cast(cookieJarSettings) |
682 | ->SetPartitionKey(uri, false); |
683 | } |
684 | |
685 | // Note that because there is no "serviceworker" RequestContext type, we can |
686 | // use the TYPE_INTERNAL_SCRIPT content policy types when loading a service |
687 | // worker. |
688 | rv = NS_NewChannel(getter_AddRefs(mChannel), uri, aPrincipal, secFlags, |
689 | contentPolicyType, cookieJarSettings, |
690 | nullptr /* aPerformanceStorage */, loadGroup, |
691 | nullptr /* aCallbacks */, mLoadFlags); |
692 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 692)) { |
693 | return rv; |
694 | } |
695 | |
696 | // Set the IsInThirdPartyContext for the channel's loadInfo according to the |
697 | // partitionKey of the principal. The worker is foreign if it's using |
698 | // partitioned principal, i.e. the partitionKey is not empty. In this case, |
699 | // we need to set the bit to the channel's loadInfo. |
700 | if (!aPrincipal->OriginAttributesRef().mPartitionKey.IsEmpty()) { |
701 | nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo(); |
702 | rv = loadInfo->SetIsInThirdPartyContext(true); |
703 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 703); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 703; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
704 | } |
705 | |
706 | nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel); |
707 | if (httpChannel) { |
708 | // Spec says no redirects allowed for top-level SW scripts. |
709 | if (mIsMainScript) { |
710 | rv = httpChannel->SetRedirectionLimit(0); |
711 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 711); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 711; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
712 | } |
713 | |
714 | rv = httpChannel->SetRequestHeader("Service-Worker"_ns, "script"_ns, |
715 | /* merge */ false); |
716 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 716); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 716; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
717 | } |
718 | |
719 | nsCOMPtr<nsIStreamLoader> loader; |
720 | rv = NS_NewStreamLoader(getter_AddRefs(loader), this, this); |
721 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 721)) { |
722 | return rv; |
723 | } |
724 | |
725 | rv = mChannel->AsyncOpen(loader); |
726 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 726)) { |
727 | return rv; |
728 | } |
729 | |
730 | // If we do have an existing cache to compare with. |
731 | if (aCache) { |
732 | mCC = new CompareCache(this); |
733 | rv = mCC->Initialize(aCache, aURL); |
734 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 734)) { |
735 | Abort(); |
736 | return rv; |
737 | } |
738 | |
739 | mState = WaitingForBothFinished; |
740 | return NS_OK; |
741 | } |
742 | |
743 | mState = WaitingForNetworkFinished; |
744 | return NS_OK; |
745 | } |
746 | |
747 | void CompareNetwork::Finish() { |
748 | if (mState == Finished) { |
749 | return; |
750 | } |
751 | |
752 | bool same = true; |
753 | nsresult rv = NS_OK; |
754 | |
755 | // mNetworkResult is prior to mCacheResult, since it's needed for reporting |
756 | // various errors to web content. |
757 | if (NS_FAILED(mNetworkResult)((bool)(__builtin_expect(!!(NS_FAILED_impl(mNetworkResult)), 0 )))) { |
758 | // An imported script could become offline, since it might no longer be |
759 | // needed by the new importing script. In that case, the importing script |
760 | // must be different, and thus, it's okay to report same script found here. |
761 | rv = mIsMainScript ? mNetworkResult : NS_OK; |
762 | same = true; |
763 | } else if (mCC && NS_FAILED(mCacheResult)((bool)(__builtin_expect(!!(NS_FAILED_impl(mCacheResult)), 0) ))) { |
764 | rv = mCacheResult; |
765 | } else { // Both passed. |
766 | same = mCC && mCC->InCache() && mCC->Buffer().Equals(mBuffer); |
767 | } |
768 | |
769 | mManager->ComparisonFinished(rv, mIsMainScript, same, mMaxScope, mLoadFlags); |
770 | |
771 | // We have done with the CompareCache. |
772 | mCC = nullptr; |
773 | } |
774 | |
775 | void CompareNetwork::NetworkFinish(nsresult aRv) { |
776 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForBothFinished ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForBothFinished || mState == WaitingForNetworkFinished )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mState == WaitingForBothFinished || mState == WaitingForNetworkFinished ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForBothFinished || mState == WaitingForNetworkFinished" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 777); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForBothFinished || mState == WaitingForNetworkFinished" ")"); do { *((volatile int*)__null) = 777; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
777 | mState == WaitingForNetworkFinished)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForBothFinished || mState == WaitingForNetworkFinished )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mState == WaitingForBothFinished || mState == WaitingForNetworkFinished ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForBothFinished || mState == WaitingForNetworkFinished" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 777); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForBothFinished || mState == WaitingForNetworkFinished" ")"); do { *((volatile int*)__null) = 777; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
778 | |
779 | mNetworkResult = aRv; |
780 | |
781 | if (mState == WaitingForBothFinished) { |
782 | mState = WaitingForCacheFinished; |
783 | return; |
784 | } |
785 | |
786 | if (mState == WaitingForNetworkFinished) { |
787 | Finish(); |
788 | return; |
789 | } |
790 | } |
791 | |
792 | void CompareNetwork::CacheFinish(nsresult aRv) { |
793 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForBothFinished ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForBothFinished || mState == WaitingForCacheFinished )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mState == WaitingForBothFinished || mState == WaitingForCacheFinished ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForBothFinished || mState == WaitingForCacheFinished" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 794); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForBothFinished || mState == WaitingForCacheFinished" ")"); do { *((volatile int*)__null) = 794; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
794 | mState == WaitingForCacheFinished)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForBothFinished || mState == WaitingForCacheFinished )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mState == WaitingForBothFinished || mState == WaitingForCacheFinished ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForBothFinished || mState == WaitingForCacheFinished" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 794); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForBothFinished || mState == WaitingForCacheFinished" ")"); do { *((volatile int*)__null) = 794; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
795 | |
796 | mCacheResult = aRv; |
797 | |
798 | if (mState == WaitingForBothFinished) { |
799 | mState = WaitingForNetworkFinished; |
800 | return; |
801 | } |
802 | |
803 | if (mState == WaitingForCacheFinished) { |
804 | Finish(); |
805 | return; |
806 | } |
807 | } |
808 | |
809 | void CompareNetwork::Abort() { |
810 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 810); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 810; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
811 | |
812 | if (mState != Finished) { |
813 | mState = Finished; |
814 | |
815 | MOZ_ASSERT(mChannel)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mChannel)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mChannel))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mChannel", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 815); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mChannel" ")" ); do { *((volatile int*)__null) = 815; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
816 | mChannel->CancelWithReason(NS_BINDING_ABORTED, "CompareNetwork::Abort"_ns); |
817 | mChannel = nullptr; |
818 | |
819 | if (mCC) { |
820 | mCC->Abort(); |
821 | mCC = nullptr; |
822 | } |
823 | } |
824 | } |
825 | |
826 | NS_IMETHODIMPnsresult |
827 | CompareNetwork::OnStartRequest(nsIRequest* aRequest) { |
828 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 828); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 828; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
829 | |
830 | if (mState == Finished) { |
831 | return NS_OK; |
832 | } |
833 | |
834 | nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest); |
835 | MOZ_ASSERT_IF(mIsMainScript, channel == mChannel)do { if (mIsMainScript) { do { static_assert( mozilla::detail ::AssertionConditionType<decltype(channel == mChannel)> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(channel == mChannel))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("channel == mChannel", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 835); AnnotateMozCrashReason("MOZ_ASSERT" "(" "channel == mChannel" ")"); do { *((volatile int*)__null) = 835; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); |
836 | mChannel = channel; |
837 | |
838 | MOZ_ASSERT(!mChannelInfo.IsInitialized())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mChannelInfo.IsInitialized())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mChannelInfo.IsInitialized( )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!mChannelInfo.IsInitialized()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 838); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mChannelInfo.IsInitialized()" ")"); do { *((volatile int*)__null) = 838; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
839 | mChannelInfo.InitFromChannel(mChannel); |
840 | |
841 | nsresult rv = SetPrincipalInfo(mChannel); |
842 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 842)) { |
843 | return rv; |
844 | } |
845 | |
846 | mInternalHeaders->FillResponseHeaders(mChannel); |
847 | |
848 | nsCOMPtr<nsICacheInfoChannel> cacheChannel(do_QueryInterface(channel)); |
849 | if (cacheChannel) { |
850 | cacheChannel->IsFromCache(&mIsFromCache); |
851 | } |
852 | |
853 | return NS_OK; |
854 | } |
855 | |
856 | nsresult CompareNetwork::SetPrincipalInfo(nsIChannel* aChannel) { |
857 | nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); |
858 | if (!ssm) { |
859 | return NS_ERROR_FAILURE; |
860 | } |
861 | |
862 | nsCOMPtr<nsIPrincipal> channelPrincipal; |
863 | nsresult rv = ssm->GetChannelResultPrincipal( |
864 | aChannel, getter_AddRefs(channelPrincipal)); |
865 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 865)) { |
866 | return rv; |
867 | } |
868 | |
869 | UniquePtr<PrincipalInfo> principalInfo = MakeUnique<PrincipalInfo>(); |
870 | rv = PrincipalToPrincipalInfo(channelPrincipal, principalInfo.get()); |
871 | |
872 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 872)) { |
873 | return rv; |
874 | } |
875 | |
876 | mPrincipalInfo = std::move(principalInfo); |
877 | return NS_OK; |
878 | } |
879 | |
880 | NS_IMETHODIMPnsresult |
881 | CompareNetwork::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) { |
882 | // Nothing to do here! |
883 | return NS_OK; |
884 | } |
885 | |
886 | NS_IMETHODIMPnsresult |
887 | CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, |
888 | nsISupports* aContext, nsresult aStatus, |
889 | uint32_t aLen, const uint8_t* aString) { |
890 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 890); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 890; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
891 | |
892 | if (mState == Finished) { |
893 | return NS_OK; |
894 | } |
895 | |
896 | nsresult rv = NS_ERROR_FAILURE; |
897 | auto guard = MakeScopeExit([&] { NetworkFinish(rv); }); |
898 | |
899 | if (NS_WARN_IF(NS_FAILED(aStatus))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aStatus )), 0))), "NS_FAILED(aStatus)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 899)) { |
900 | rv = (aStatus == NS_ERROR_REDIRECT_LOOP) ? NS_ERROR_DOM_SECURITY_ERR |
901 | : aStatus; |
902 | return NS_OK; |
903 | } |
904 | |
905 | nsCOMPtr<nsIRequest> request; |
906 | rv = aLoader->GetRequest(getter_AddRefs(request)); |
907 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 907)) { |
908 | return NS_OK; |
909 | } |
910 | |
911 | nsCOMPtr<nsIChannel> channel = do_QueryInterface(request); |
912 | MOZ_ASSERT(channel, "How come we don't have any channel?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(channel)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(channel))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("channel" " (" "How come we don't have any channel?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 912); AnnotateMozCrashReason("MOZ_ASSERT" "(" "channel" ") (" "How come we don't have any channel?" ")"); do { *((volatile int*)__null) = 912; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
913 | |
914 | nsCOMPtr<nsIURI> uri; |
915 | channel->GetOriginalURI(getter_AddRefs(uri)); |
916 | bool isExtension = uri->SchemeIs("moz-extension"); |
917 | |
918 | if (isExtension && |
919 | !StaticPrefs::extensions_backgroundServiceWorker_enabled_AtStartup()) { |
920 | // Return earlier with error is the worker script is a moz-extension url |
921 | // but the feature isn't enabled by prefs. |
922 | return NS_ERROR_FAILURE; |
923 | } |
924 | |
925 | if (isExtension) { |
926 | // NOTE: trying to register any moz-extension use that doesn't ends |
927 | // with .js/.jsm/.mjs seems to be already completing with an error |
928 | // in aStatus and they never reach this point. |
929 | |
930 | // TODO: look into avoid duplicated parts that could be shared with the HTTP |
931 | // channel scenario. |
932 | nsCOMPtr<nsIURI> channelURL; |
933 | rv = channel->GetURI(getter_AddRefs(channelURL)); |
934 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 934)) { |
935 | return rv; |
936 | } |
937 | |
938 | nsCString channelURLSpec; |
939 | MOZ_ALWAYS_SUCCEEDS(channelURL->GetSpec(channelURLSpec))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (channelURL->GetSpec(channelURLSpec))), 1)))), 1))) { } else { do { static_assert( mozilla::detail::AssertionConditionType <decltype(false)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(channelURL->GetSpec(channelURLSpec))" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 939); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ") (" "NS_SUCCEEDED(channelURL->GetSpec(channelURLSpec))" ")"); do { *((volatile int*)__null) = 939; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); |
940 | |
941 | // Append the final URL (which for an extension worker script is going to |
942 | // be a file or jar url). |
943 | MOZ_DIAGNOSTIC_ASSERT(!mURLList.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mURLList.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mURLList.IsEmpty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mURLList.IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 943); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "!mURLList.IsEmpty()" ")"); do { *((volatile int*)__null) = 943; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
944 | if (channelURLSpec != mURLList[0]) { |
945 | mURLList.AppendElement(channelURLSpec); |
946 | } |
947 | |
948 | UniquePtr<char16_t[], JS::FreePolicy> buffer; |
949 | size_t len = 0; |
950 | |
951 | rv = ScriptLoader::ConvertToUTF16(channel, aString, aLen, u"UTF-8"_ns, |
952 | nullptr, buffer, len); |
953 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 953)) { |
954 | return rv; |
955 | } |
956 | |
957 | mBuffer.Adopt(buffer.release(), len); |
958 | |
959 | rv = NS_OK; |
960 | return NS_OK; |
961 | } |
962 | |
963 | nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request); |
964 | |
965 | // Main scripts cannot be redirected successfully, however extensions |
966 | // may successfuly redirect imported scripts to a moz-extension url |
967 | // (if listed in the web_accessible_resources manifest property). |
968 | // |
969 | // When the service worker is initially registered the imported scripts |
970 | // will be loaded from the child process (see dom/workers/ScriptLoader.cpp) |
971 | // and in that case this method will only be called for the main script. |
972 | // |
973 | // When a registered worker is loaded again (e.g. when the webpage calls |
974 | // the ServiceWorkerRegistration's update method): |
975 | // |
976 | // - both the main and imported scripts are loaded by the |
977 | // CompareManager::FetchScript |
978 | // - the update requests for the imported scripts will also be calling this |
979 | // method and we should expect scripts redirected to an extension script |
980 | // to have a null httpChannel. |
981 | // |
982 | // The request that triggers this method is: |
983 | // |
984 | // - the one that is coming from the network (which may be intercepted by |
985 | // WebRequest listeners in extensions and redirected to a web_accessible |
986 | // moz-extension url) |
987 | // - it will then be compared with a previous response that we may have |
988 | // in the cache |
989 | // |
990 | // When the next service worker update occurs, if the request (for an imported |
991 | // script) is not redirected by an extension the cache entry is invalidated |
992 | // and a network request is triggered for the import. |
993 | if (!httpChannel) { |
994 | // Redirecting a service worker main script should fail before reaching this |
995 | // method. |
996 | // If a main script is somehow redirected, the diagnostic assert will crash |
997 | // in non-release builds. Release builds will return an explicit error. |
998 | MOZ_DIAGNOSTIC_ASSERT(!mIsMainScript,do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mIsMainScript)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mIsMainScript))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mIsMainScript" " (" "Unexpected ServiceWorker main script redirected" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 999); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "!mIsMainScript" ") (" "Unexpected ServiceWorker main script redirected" ")") ; do { *((volatile int*)__null) = 999; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
999 | "Unexpected ServiceWorker main script redirected")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mIsMainScript)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mIsMainScript))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mIsMainScript" " (" "Unexpected ServiceWorker main script redirected" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 999); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "!mIsMainScript" ") (" "Unexpected ServiceWorker main script redirected" ")") ; do { *((volatile int*)__null) = 999; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1000 | if (mIsMainScript) { |
1001 | return NS_ERROR_UNEXPECTED; |
1002 | } |
1003 | |
1004 | nsCOMPtr<nsIPrincipal> channelPrincipal; |
1005 | |
1006 | nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); |
1007 | if (!ssm) { |
1008 | return NS_ERROR_UNEXPECTED; |
1009 | } |
1010 | |
1011 | nsresult rv = ssm->GetChannelResultPrincipal( |
Value stored to 'rv' during its initialization is never read | |
1012 | channel, getter_AddRefs(channelPrincipal)); |
1013 | |
1014 | // An extension did redirect a non-MainScript request to a moz-extension url |
1015 | // (in that case the originalURL is the resolved jar URI and so we have to |
1016 | // look to the channel principal instead). |
1017 | if (channelPrincipal->SchemeIs("moz-extension")) { |
1018 | UniquePtr<char16_t[], JS::FreePolicy> buffer; |
1019 | size_t len = 0; |
1020 | |
1021 | rv = ScriptLoader::ConvertToUTF16(channel, aString, aLen, u"UTF-8"_ns, |
1022 | nullptr, buffer, len); |
1023 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1023)) { |
1024 | return rv; |
1025 | } |
1026 | |
1027 | mBuffer.Adopt(buffer.release(), len); |
1028 | |
1029 | return NS_OK; |
1030 | } |
1031 | |
1032 | // Make non-release and debug builds to crash if this happens and fail |
1033 | // explicitly on release builds. |
1034 | MOZ_DIAGNOSTIC_ASSERT(false,do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "ServiceWorker imported script redirected to an url " "with an unexpected scheme" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1036); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ") (" "ServiceWorker imported script redirected to an url " "with an unexpected scheme" ")"); do { *((volatile int*)__null) = 1036; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
1035 | "ServiceWorker imported script redirected to an url "do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "ServiceWorker imported script redirected to an url " "with an unexpected scheme" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1036); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ") (" "ServiceWorker imported script redirected to an url " "with an unexpected scheme" ")"); do { *((volatile int*)__null) = 1036; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
1036 | "with an unexpected scheme")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "ServiceWorker imported script redirected to an url " "with an unexpected scheme" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1036); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ") (" "ServiceWorker imported script redirected to an url " "with an unexpected scheme" ")"); do { *((volatile int*)__null) = 1036; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1037 | return NS_ERROR_UNEXPECTED; |
1038 | } |
1039 | |
1040 | bool requestSucceeded; |
1041 | rv = httpChannel->GetRequestSucceeded(&requestSucceeded); |
1042 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1042)) { |
1043 | return NS_OK; |
1044 | } |
1045 | |
1046 | if (NS_WARN_IF(!requestSucceeded)NS_warn_if_impl(!requestSucceeded, "!requestSucceeded", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1046)) { |
1047 | // Get the stringified numeric status code, not statusText which could be |
1048 | // something misleading like OK for a 404. |
1049 | uint32_t status = 0; |
1050 | Unused << httpChannel->GetResponseStatus( |
1051 | &status); // don't care if this fails, use 0. |
1052 | nsAutoString statusAsText; |
1053 | statusAsText.AppendInt(status); |
1054 | |
1055 | ServiceWorkerManager::LocalizeAndReportToAllClients( |
1056 | mRegistration->Scope(), "ServiceWorkerRegisterNetworkError", |
1057 | nsTArray<nsString>{NS_ConvertUTF8toUTF16(mRegistration->Scope()), |
1058 | statusAsText, NS_ConvertUTF8toUTF16(mURL)}); |
1059 | |
1060 | rv = NS_ERROR_FAILURE; |
1061 | return NS_OK; |
1062 | } |
1063 | |
1064 | // Note: we explicitly don't check for the return value here, because the |
1065 | // absence of the header is not an error condition. |
1066 | Unused << httpChannel->GetResponseHeader("Service-Worker-Allowed"_ns, |
1067 | mMaxScope); |
1068 | |
1069 | // [9.2 Update]4.13, If response's cache state is not "local", |
1070 | // set registration's last update check time to the current time |
1071 | if (!mIsFromCache) { |
1072 | mRegistration->RefreshLastUpdateCheckTime(); |
1073 | } |
1074 | |
1075 | nsAutoCString mimeType; |
1076 | rv = httpChannel->GetContentType(mimeType); |
1077 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1077)) { |
1078 | // We should only end up here if !mResponseHead in the channel. If headers |
1079 | // were received but no content type was specified, we'll be given |
1080 | // UNKNOWN_CONTENT_TYPE "application/x-unknown-content-type" and so fall |
1081 | // into the next case with its better error message. |
1082 | rv = NS_ERROR_DOM_SECURITY_ERR; |
1083 | return rv; |
1084 | } |
1085 | |
1086 | if (mimeType.IsEmpty() || |
1087 | !nsContentUtils::IsJavascriptMIMEType(NS_ConvertUTF8toUTF16(mimeType))) { |
1088 | ServiceWorkerManager::LocalizeAndReportToAllClients( |
1089 | mRegistration->Scope(), "ServiceWorkerRegisterMimeTypeError2", |
1090 | nsTArray<nsString>{NS_ConvertUTF8toUTF16(mRegistration->Scope()), |
1091 | NS_ConvertUTF8toUTF16(mimeType), |
1092 | NS_ConvertUTF8toUTF16(mURL)}); |
1093 | rv = NS_ERROR_DOM_SECURITY_ERR; |
1094 | return rv; |
1095 | } |
1096 | |
1097 | nsCOMPtr<nsIURI> channelURL; |
1098 | rv = httpChannel->GetURI(getter_AddRefs(channelURL)); |
1099 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1099)) { |
1100 | return rv; |
1101 | } |
1102 | |
1103 | nsCString channelURLSpec; |
1104 | MOZ_ALWAYS_SUCCEEDS(channelURL->GetSpec(channelURLSpec))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (channelURL->GetSpec(channelURLSpec))), 1)))), 1))) { } else { do { static_assert( mozilla::detail::AssertionConditionType <decltype(false)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(channelURL->GetSpec(channelURLSpec))" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1104); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ") (" "NS_SUCCEEDED(channelURL->GetSpec(channelURLSpec))" ")"); do { *((volatile int*)__null) = 1104; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); |
1105 | |
1106 | // Append the final URL if its different from the original |
1107 | // request URL. This lets us note that a redirect occurred |
1108 | // even though we don't track every redirect URL here. |
1109 | MOZ_DIAGNOSTIC_ASSERT(!mURLList.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mURLList.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mURLList.IsEmpty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mURLList.IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1109); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "!mURLList.IsEmpty()" ")"); do { *((volatile int*)__null) = 1109; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1110 | if (channelURLSpec != mURLList[0]) { |
1111 | mURLList.AppendElement(channelURLSpec); |
1112 | } |
1113 | |
1114 | UniquePtr<char16_t[], JS::FreePolicy> buffer; |
1115 | size_t len = 0; |
1116 | |
1117 | rv = ScriptLoader::ConvertToUTF16(httpChannel, aString, aLen, u"UTF-8"_ns, |
1118 | nullptr, buffer, len); |
1119 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1119)) { |
1120 | return rv; |
1121 | } |
1122 | |
1123 | mBuffer.Adopt(buffer.release(), len); |
1124 | |
1125 | rv = NS_OK; |
1126 | return NS_OK; |
1127 | } |
1128 | |
1129 | nsresult CompareCache::Initialize(Cache* const aCache, const nsACString& aURL) { |
1130 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1130); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1130; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1131 | MOZ_ASSERT(aCache)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCache)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(aCache))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aCache", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1131); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCache" ")" ); do { *((volatile int*)__null) = 1131; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1132 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForInitialization)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForInitialization)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mState == WaitingForInitialization ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForInitialization", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1132); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForInitialization" ")"); do { *((volatile int*)__null) = 1132; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1133 | |
1134 | // This JSContext will not end up executing JS code because here there are |
1135 | // no ReadableStreams involved. |
1136 | AutoJSAPI jsapi; |
1137 | jsapi.Init(); |
1138 | |
1139 | RequestOrUTF8String request; |
1140 | request.SetAsUTF8String().ShareOrDependUpon(aURL); |
1141 | ErrorResult error; |
1142 | CacheQueryOptions params; |
1143 | RefPtr<Promise> promise = aCache->Match(jsapi.cx(), request, params, error); |
1144 | if (NS_WARN_IF(error.Failed())NS_warn_if_impl(error.Failed(), "error.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1144)) { |
1145 | // No exception here because there are no ReadableStreams involved here. |
1146 | MOZ_ASSERT(!error.IsJSException())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!error.IsJSException())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!error.IsJSException()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!error.IsJSException()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1146); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!error.IsJSException()" ")"); do { *((volatile int*)__null) = 1146; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1147 | mState = Finished; |
1148 | return error.StealNSResult(); |
1149 | } |
1150 | |
1151 | // Retrieve the script from aCache. |
1152 | mState = WaitingForScript; |
1153 | promise->AppendNativeHandler(this); |
1154 | return NS_OK; |
1155 | } |
1156 | |
1157 | void CompareCache::Finish(nsresult aStatus, bool aInCache) { |
1158 | if (mState != Finished) { |
1159 | mState = Finished; |
1160 | mInCache = aInCache; |
1161 | mCN->CacheFinish(aStatus); |
1162 | } |
1163 | } |
1164 | |
1165 | void CompareCache::Abort() { |
1166 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1166); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1166; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1167 | |
1168 | if (mState != Finished) { |
1169 | mState = Finished; |
1170 | |
1171 | if (mPump) { |
1172 | mPump->CancelWithReason(NS_BINDING_ABORTED, "CompareCache::Abort"_ns); |
1173 | mPump = nullptr; |
1174 | } |
1175 | } |
1176 | } |
1177 | |
1178 | NS_IMETHODIMPnsresult |
1179 | CompareCache::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext, |
1180 | nsresult aStatus, uint32_t aLen, |
1181 | const uint8_t* aString) { |
1182 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1182); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1182; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1183 | |
1184 | if (mState == Finished) { |
1185 | return aStatus; |
1186 | } |
1187 | |
1188 | if (NS_WARN_IF(NS_FAILED(aStatus))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aStatus )), 0))), "NS_FAILED(aStatus)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1188)) { |
1189 | Finish(aStatus, false); |
1190 | return aStatus; |
1191 | } |
1192 | |
1193 | UniquePtr<char16_t[], JS::FreePolicy> buffer; |
1194 | size_t len = 0; |
1195 | |
1196 | nsresult rv = ScriptLoader::ConvertToUTF16(nullptr, aString, aLen, |
1197 | u"UTF-8"_ns, nullptr, buffer, len); |
1198 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1198)) { |
1199 | Finish(rv, false); |
1200 | return rv; |
1201 | } |
1202 | |
1203 | mBuffer.Adopt(buffer.release(), len); |
1204 | |
1205 | Finish(NS_OK, true); |
1206 | return NS_OK; |
1207 | } |
1208 | |
1209 | void CompareCache::ResolvedCallback(JSContext* aCx, |
1210 | JS::Handle<JS::Value> aValue, |
1211 | ErrorResult& aRv) { |
1212 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1212); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1212; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1213 | |
1214 | switch (mState) { |
1215 | case Finished: |
1216 | return; |
1217 | case WaitingForScript: |
1218 | ManageValueResult(aCx, aValue); |
1219 | return; |
1220 | default: |
1221 | MOZ_CRASH("Unacceptable state.")do { do { } while (false); MOZ_ReportCrash("" "Unacceptable state." , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1221); AnnotateMozCrashReason("MOZ_CRASH(" "Unacceptable state." ")"); do { *((volatile int*)__null) = 1221; __attribute__((nomerge )) ::abort(); } while (false); } while (false); |
1222 | } |
1223 | } |
1224 | |
1225 | void CompareCache::RejectedCallback(JSContext* aCx, |
1226 | JS::Handle<JS::Value> aValue, |
1227 | ErrorResult& aRv) { |
1228 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1228); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1228; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1229 | |
1230 | if (mState != Finished) { |
1231 | Finish(NS_ERROR_FAILURE, false); |
1232 | return; |
1233 | } |
1234 | } |
1235 | |
1236 | void CompareCache::ManageValueResult(JSContext* aCx, |
1237 | JS::Handle<JS::Value> aValue) { |
1238 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1238); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1238; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1239 | |
1240 | // The cache returns undefined if the object is not stored. |
1241 | if (aValue.isUndefined()) { |
1242 | Finish(NS_OK, false); |
1243 | return; |
1244 | } |
1245 | |
1246 | MOZ_ASSERT(aValue.isObject())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aValue.isObject())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aValue.isObject()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aValue.isObject()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1246); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aValue.isObject()" ")"); do { *((volatile int*)__null) = 1246; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1247 | |
1248 | JS::Rooted<JSObject*> obj(aCx, &aValue.toObject()); |
1249 | if (NS_WARN_IF(!obj)NS_warn_if_impl(!obj, "!obj", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1249)) { |
1250 | Finish(NS_ERROR_FAILURE, false); |
1251 | return; |
1252 | } |
1253 | |
1254 | Response* response = nullptr; |
1255 | nsresult rv = UNWRAP_OBJECT(Response, &obj, response)mozilla::dom::binding_detail::UnwrapObjectWithCrossOriginAsserts < mozilla::dom::prototypes::id::Response, mozilla::dom::Response_Binding ::NativeType>(&obj, response); |
1256 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1256)) { |
1257 | Finish(rv, false); |
1258 | return; |
1259 | } |
1260 | |
1261 | MOZ_ASSERT(response->Ok())do { static_assert( mozilla::detail::AssertionConditionType< decltype(response->Ok())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(response->Ok()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("response->Ok()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1261); AnnotateMozCrashReason("MOZ_ASSERT" "(" "response->Ok()" ")"); do { *((volatile int*)__null) = 1261; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1262 | |
1263 | nsCOMPtr<nsIInputStream> inputStream; |
1264 | response->GetBody(getter_AddRefs(inputStream)); |
1265 | MOZ_ASSERT(inputStream)do { static_assert( mozilla::detail::AssertionConditionType< decltype(inputStream)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(inputStream))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("inputStream", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1265); AnnotateMozCrashReason("MOZ_ASSERT" "(" "inputStream" ")"); do { *((volatile int*)__null) = 1265; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1266 | |
1267 | MOZ_ASSERT(!mPump)do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mPump)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(!mPump))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mPump", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1267); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mPump" ")" ); do { *((volatile int*)__null) = 1267; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1268 | rv = NS_NewInputStreamPump(getter_AddRefs(mPump), inputStream.forget(), |
1269 | 0, /* default segsize */ |
1270 | 0, /* default segcount */ |
1271 | false, /* default closeWhenDone */ |
1272 | GetMainThreadSerialEventTarget()); |
1273 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1273)) { |
1274 | Finish(rv, false); |
1275 | return; |
1276 | } |
1277 | |
1278 | nsCOMPtr<nsIStreamLoader> loader; |
1279 | rv = NS_NewStreamLoader(getter_AddRefs(loader), this); |
1280 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1280)) { |
1281 | Finish(rv, false); |
1282 | return; |
1283 | } |
1284 | |
1285 | rv = mPump->AsyncRead(loader); |
1286 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1286)) { |
1287 | mPump = nullptr; |
1288 | Finish(rv, false); |
1289 | return; |
1290 | } |
1291 | |
1292 | nsCOMPtr<nsIThreadRetargetableRequest> rr = do_QueryInterface(mPump); |
1293 | if (rr) { |
1294 | nsCOMPtr<nsIEventTarget> sts = |
1295 | do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID"@mozilla.org/network/stream-transport-service;1"); |
1296 | RefPtr<TaskQueue> queue = |
1297 | TaskQueue::Create(sts.forget(), "CompareCache STS Delivery Queue"); |
1298 | rv = rr->RetargetDeliveryTo(queue); |
1299 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1299)) { |
1300 | mPump = nullptr; |
1301 | Finish(rv, false); |
1302 | return; |
1303 | } |
1304 | } |
1305 | } |
1306 | |
1307 | nsresult CompareManager::Initialize(nsIPrincipal* aPrincipal, |
1308 | const nsACString& aURL, |
1309 | const nsAString& aCacheName) { |
1310 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1310); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1310; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1311 | MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipal)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipal", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1311); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")"); do { *((volatile int*)__null) = 1311; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1312 | MOZ_ASSERT(mPendingCount == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPendingCount == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPendingCount == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mPendingCount == 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1312); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPendingCount == 0" ")"); do { *((volatile int*)__null) = 1312; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1313 | MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForInitialization)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mState == WaitingForInitialization)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mState == WaitingForInitialization ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mState == WaitingForInitialization", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1313); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mState == WaitingForInitialization" ")"); do { *((volatile int*)__null) = 1313; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1314 | |
1315 | // RAII Cleanup when fails. |
1316 | auto guard = MakeScopeExit([&] { Cleanup(); }); |
1317 | |
1318 | mURL = aURL; |
1319 | mPrincipal = aPrincipal; |
1320 | |
1321 | // Always create a CacheStorage since we want to write the network entry to |
1322 | // the cache even if there isn't an existing one. |
1323 | AutoJSAPI jsapi; |
1324 | jsapi.Init(); |
1325 | ErrorResult result; |
1326 | mCacheStorage = CreateCacheStorage(jsapi.cx(), aPrincipal, result); |
1327 | if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1327)) { |
1328 | MOZ_ASSERT(!result.IsErrorWithMessage())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!result.IsErrorWithMessage())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!result.IsErrorWithMessage() ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!result.IsErrorWithMessage()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1328); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!result.IsErrorWithMessage()" ")"); do { *((volatile int*)__null) = 1328; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1329 | return result.StealNSResult(); |
1330 | } |
1331 | |
1332 | // If there is no existing cache, proceed to fetch the script directly. |
1333 | if (aCacheName.IsEmpty()) { |
1334 | mState = WaitingForScriptOrComparisonResult; |
1335 | nsresult rv = FetchScript(aURL, true /* aIsMainScript */); |
1336 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1336)) { |
1337 | return rv; |
1338 | } |
1339 | |
1340 | guard.release(); |
1341 | return NS_OK; |
1342 | } |
1343 | |
1344 | // Open the cache saving the old source scripts. |
1345 | RefPtr<Promise> promise = mCacheStorage->Open(aCacheName, result); |
1346 | if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1346)) { |
1347 | MOZ_ASSERT(!result.IsErrorWithMessage())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!result.IsErrorWithMessage())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!result.IsErrorWithMessage() ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!result.IsErrorWithMessage()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1347); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!result.IsErrorWithMessage()" ")"); do { *((volatile int*)__null) = 1347; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1348 | return result.StealNSResult(); |
1349 | } |
1350 | |
1351 | mState = WaitingForExistingOpen; |
1352 | promise->AppendNativeHandler(this); |
1353 | |
1354 | guard.release(); |
1355 | return NS_OK; |
1356 | } |
1357 | |
1358 | // This class manages 4 promises if needed: |
1359 | // 1. Retrieve the Cache object by a given CacheName of OldCache. |
1360 | // 2. Retrieve the URLs saved in OldCache. |
1361 | // 3. Retrieve the Cache object of the NewCache for the newly created SW. |
1362 | // 4. Put the value in the cache. |
1363 | // For this reason we have mState to know what callback we are handling. |
1364 | void CompareManager::ResolvedCallback(JSContext* aCx, |
1365 | JS::Handle<JS::Value> aValue, |
1366 | ErrorResult& aRv) { |
1367 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1367); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1367; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1368 | MOZ_ASSERT(mCallback)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCallback)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCallback))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mCallback", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1368); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCallback" ")" ); do { *((volatile int*)__null) = 1368; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1369 | |
1370 | switch (mState) { |
1371 | case Finished: |
1372 | return; |
1373 | case WaitingForExistingOpen: |
1374 | ManageOldCache(aCx, aValue); |
1375 | return; |
1376 | case WaitingForExistingKeys: |
1377 | ManageOldKeys(aCx, aValue); |
1378 | return; |
1379 | case WaitingForOpen: |
1380 | ManageNewCache(aCx, aValue); |
1381 | return; |
1382 | case WaitingForPut: |
1383 | MOZ_DIAGNOSTIC_ASSERT(mPendingCount > 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPendingCount > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPendingCount > 0))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("mPendingCount > 0" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1383); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mPendingCount > 0" ")"); do { *((volatile int*)__null) = 1383; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1384 | if (--mPendingCount == 0) { |
1385 | mCallback->ComparisonResult(NS_OK, false /* aIsEqual */, mOnFailure, |
1386 | mNewCacheName, mMaxScope, mLoadFlags); |
1387 | Cleanup(); |
1388 | } |
1389 | return; |
1390 | default: |
1391 | MOZ_DIAGNOSTIC_ASSERT(false)do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1391); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ")"); do { *((volatile int*)__null) = 1391; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1392 | } |
1393 | } |
1394 | |
1395 | void CompareManager::RejectedCallback(JSContext* aCx, |
1396 | JS::Handle<JS::Value> aValue, |
1397 | ErrorResult& aRv) { |
1398 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1398); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1398; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1399 | switch (mState) { |
1400 | case Finished: |
1401 | return; |
1402 | case WaitingForExistingOpen: |
1403 | NS_WARNING("Could not open the existing cache.")NS_DebugBreak(NS_DEBUG_WARNING, "Could not open the existing cache." , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1403); |
1404 | break; |
1405 | case WaitingForExistingKeys: |
1406 | NS_WARNING("Could not get the existing URLs.")NS_DebugBreak(NS_DEBUG_WARNING, "Could not get the existing URLs." , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1406); |
1407 | break; |
1408 | case WaitingForOpen: |
1409 | NS_WARNING("Could not open cache.")NS_DebugBreak(NS_DEBUG_WARNING, "Could not open cache.", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1409); |
1410 | break; |
1411 | case WaitingForPut: |
1412 | NS_WARNING("Could not write to cache.")NS_DebugBreak(NS_DEBUG_WARNING, "Could not write to cache.", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1412); |
1413 | break; |
1414 | default: |
1415 | MOZ_DIAGNOSTIC_ASSERT(false)do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1415); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ")"); do { *((volatile int*)__null) = 1415; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1416 | } |
1417 | |
1418 | Fail(NS_ERROR_FAILURE); |
1419 | } |
1420 | |
1421 | void CompareManager::Fail(nsresult aStatus) { |
1422 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1422); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1422; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1423 | mCallback->ComparisonResult(aStatus, false /* aIsEqual */, mOnFailure, u""_ns, |
1424 | ""_ns, mLoadFlags); |
1425 | Cleanup(); |
1426 | } |
1427 | |
1428 | void CompareManager::Cleanup() { |
1429 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1429); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1429; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1430 | |
1431 | if (mState != Finished) { |
1432 | mState = Finished; |
1433 | |
1434 | MOZ_ASSERT(mCallback)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mCallback)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mCallback))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mCallback", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1434); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mCallback" ")" ); do { *((volatile int*)__null) = 1434; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1435 | mCallback = nullptr; |
1436 | |
1437 | // Abort and release CompareNetworks. |
1438 | for (uint32_t i = 0; i < mCNList.Length(); ++i) { |
1439 | mCNList[i]->Abort(); |
1440 | } |
1441 | mCNList.Clear(); |
1442 | } |
1443 | } |
1444 | |
1445 | } // namespace |
1446 | |
1447 | nsresult PurgeCache(nsIPrincipal* aPrincipal, const nsAString& aCacheName) { |
1448 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1448); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1448; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1449 | MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipal)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipal", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1449); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")"); do { *((volatile int*)__null) = 1449; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1450 | |
1451 | if (aCacheName.IsEmpty()) { |
1452 | return NS_OK; |
1453 | } |
1454 | |
1455 | AutoJSAPI jsapi; |
1456 | jsapi.Init(); |
1457 | ErrorResult rv; |
1458 | RefPtr<CacheStorage> cacheStorage = |
1459 | CreateCacheStorage(jsapi.cx(), aPrincipal, rv); |
1460 | if (NS_WARN_IF(rv.Failed())NS_warn_if_impl(rv.Failed(), "rv.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1460)) { |
1461 | return rv.StealNSResult(); |
1462 | } |
1463 | |
1464 | // We use the ServiceWorker scope as key for the cacheStorage. |
1465 | RefPtr<Promise> promise = cacheStorage->Delete(aCacheName, rv); |
1466 | if (NS_WARN_IF(rv.Failed())NS_warn_if_impl(rv.Failed(), "rv.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1466)) { |
1467 | return rv.StealNSResult(); |
1468 | } |
1469 | |
1470 | // Set [[PromiseIsHandled]] to ensure that if this promise gets rejected, |
1471 | // we don't end up reporting a rejected promise to the console. |
1472 | MOZ_ALWAYS_TRUE(promise->SetAnyPromiseIsHandled())do { if ((__builtin_expect(!!(promise->SetAnyPromiseIsHandled ()), 1))) { } else { do { static_assert( mozilla::detail::AssertionConditionType <decltype(false)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("false" " (" "promise->SetAnyPromiseIsHandled()" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1472); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false" ") (" "promise->SetAnyPromiseIsHandled()" ")"); do { *((volatile int*)__null) = 1472; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); } } while (false); |
1473 | |
1474 | // We don't actually care about the result of the delete operation. |
1475 | return NS_OK; |
1476 | } |
1477 | |
1478 | nsresult GenerateCacheName(nsAString& aName) { |
1479 | nsresult rv; |
1480 | nsCOMPtr<nsIUUIDGenerator> uuidGenerator = |
1481 | do_GetService("@mozilla.org/uuid-generator;1", &rv); |
1482 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1482)) { |
1483 | return rv; |
1484 | } |
1485 | |
1486 | nsID id; |
1487 | rv = uuidGenerator->GenerateUUIDInPlace(&id); |
1488 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1488)) { |
1489 | return rv; |
1490 | } |
1491 | |
1492 | char chars[NSID_LENGTH39]; |
1493 | id.ToProvidedString(chars); |
1494 | |
1495 | // NSID_LENGTH counts the null terminator. |
1496 | aName.AssignASCII(chars, NSID_LENGTH39 - 1); |
1497 | |
1498 | return NS_OK; |
1499 | } |
1500 | |
1501 | nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration, |
1502 | nsIPrincipal* aPrincipal, const nsAString& aCacheName, |
1503 | const nsACString& aURL, CompareCallback* aCallback) { |
1504 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1504); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1504; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1505 | MOZ_ASSERT(aRegistration)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aRegistration)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aRegistration))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aRegistration", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1505); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRegistration" ")"); do { *((volatile int*)__null) = 1505; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1506 | MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipal)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipal", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1506); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")"); do { *((volatile int*)__null) = 1506; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1507 | MOZ_ASSERT(!aURL.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aURL.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aURL.IsEmpty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!aURL.IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1507); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aURL.IsEmpty()" ")"); do { *((volatile int*)__null) = 1507; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1508 | MOZ_ASSERT(aCallback)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCallback)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aCallback))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aCallback", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1508); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCallback" ")" ); do { *((volatile int*)__null) = 1508; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1509 | |
1510 | RefPtr<CompareManager> cm = new CompareManager(aRegistration, aCallback); |
1511 | |
1512 | nsresult rv = cm->Initialize(aPrincipal, aURL, aCacheName); |
1513 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/dom/serviceworkers/ServiceWorkerScriptCache.cpp" , 1513)) { |
1514 | return rv; |
1515 | } |
1516 | |
1517 | return NS_OK; |
1518 | } |
1519 | |
1520 | } // namespace mozilla::dom::serviceWorkerScriptCache |