Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp
Warning:line 2011, column 3
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ActorsParent.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/indexedDB -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/indexedDB -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D STATIC_EXPORTABLE_JS_API -I /var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/indexedDB -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/dom/base -I /var/lib/jenkins/workspace/firefox-scan-build/dom/storage -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/glue -I /var/lib/jenkins/workspace/firefox-scan-build/third_party/sqlite3/src -I /var/lib/jenkins/workspace/firefox-scan-build/xpcom/build -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-05-16-034744-15991-1 -x c++ /var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp

/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp

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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7#include "ActorsParent.h"
8
9#include <inttypes.h>
10#include <math.h>
11#include <stdlib.h>
12#include <string.h>
13#include <algorithm>
14#include <cstdint>
15#include <functional>
16#include <iterator>
17#include <new>
18#include <numeric>
19#include <tuple>
20#include <type_traits>
21#include <utility>
22#include "ActorsParentCommon.h"
23#include "CrashAnnotations.h"
24#include "DatabaseFileInfo.h"
25#include "DatabaseFileManager.h"
26#include "DatabaseFileManagerImpl.h"
27#include "DBSchema.h"
28#include "ErrorList.h"
29#include "IDBCursorType.h"
30#include "IDBObjectStore.h"
31#include "IDBTransaction.h"
32#include "IndexedDBCommon.h"
33#include "IndexedDatabaseInlines.h"
34#include "IndexedDatabaseManager.h"
35#include "IndexedDBCipherKeyManager.h"
36#include "KeyPath.h"
37#include "MainThreadUtils.h"
38#include "ProfilerHelpers.h"
39#include "ReportInternalError.h"
40#include "SafeRefPtr.h"
41#include "SchemaUpgrades.h"
42#include "chrome/common/ipc_channel.h"
43#include "ipc/IPCMessageUtils.h"
44#include "js/RootingAPI.h"
45#include "js/StructuredClone.h"
46#include "js/Value.h"
47#include "jsapi.h"
48#include "mozIStorageAsyncConnection.h"
49#include "mozIStorageConnection.h"
50#include "mozIStorageFunction.h"
51#include "mozIStorageProgressHandler.h"
52#include "mozIStorageService.h"
53#include "mozIStorageStatement.h"
54#include "mozIStorageValueArray.h"
55#include "mozStorageCID.h"
56#include "mozStorageHelper.h"
57#include "mozilla/Algorithm.h"
58#include "mozilla/ArrayAlgorithm.h"
59#include "mozilla/ArrayIterator.h"
60#include "mozilla/Assertions.h"
61#include "mozilla/Atomics.h"
62#include "mozilla/Attributes.h"
63#include "mozilla/Casting.h"
64#include "mozilla/CondVar.h"
65#include "mozilla/DebugOnly.h"
66#include "mozilla/EndianUtils.h"
67#include "mozilla/ErrorNames.h"
68#include "mozilla/ErrorResult.h"
69#include "mozilla/InitializedOnce.h"
70#include "mozilla/Logging.h"
71#include "mozilla/MacroForEach.h"
72#include "mozilla/Maybe.h"
73#include "mozilla/Monitor.h"
74#include "mozilla/Mutex.h"
75#include "mozilla/NotNull.h"
76#include "mozilla/Preferences.h"
77#include "mozilla/ProfilerLabels.h"
78#include "mozilla/RefCountType.h"
79#include "mozilla/RefCounted.h"
80#include "mozilla/RemoteLazyInputStreamParent.h"
81#include "mozilla/RemoteLazyInputStreamStorage.h"
82#include "mozilla/Result.h"
83#include "mozilla/ResultExtensions.h"
84#include "mozilla/SchedulerGroup.h"
85#include "mozilla/SnappyCompressOutputStream.h"
86#include "mozilla/SpinEventLoopUntil.h"
87#include "mozilla/StaticPtr.h"
88#include "mozilla/TimeStamp.h"
89#include "mozilla/UniquePtr.h"
90#include "mozilla/Unused.h"
91#include "mozilla/Variant.h"
92#include "mozilla/dom/BlobImpl.h"
93#include "mozilla/dom/ContentParent.h"
94#include "mozilla/dom/FileBlobImpl.h"
95#include "mozilla/dom/FlippedOnce.h"
96#include "mozilla/dom/IDBCursorBinding.h"
97#include "mozilla/dom/IDBFactory.h"
98#include "mozilla/dom/IPCBlob.h"
99#include "mozilla/dom/IPCBlobUtils.h"
100#include "mozilla/dom/IndexedDatabase.h"
101#include "mozilla/dom/Nullable.h"
102#include "mozilla/dom/PContentParent.h"
103#include "mozilla/dom/ScriptSettings.h"
104#include "mozilla/dom/indexedDB/IDBResult.h"
105#include "mozilla/dom/indexedDB/Key.h"
106#include "mozilla/dom/indexedDB/PBackgroundIDBCursor.h"
107#include "mozilla/dom/indexedDB/PBackgroundIDBCursorParent.h"
108#include "mozilla/dom/indexedDB/PBackgroundIDBDatabase.h"
109#include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseFileParent.h"
110#include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseParent.h"
111#include "mozilla/dom/indexedDB/PBackgroundIDBFactory.h"
112#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryParent.h"
113#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryRequestParent.h"
114#include "mozilla/dom/indexedDB/PBackgroundIDBRequest.h"
115#include "mozilla/dom/indexedDB/PBackgroundIDBRequestParent.h"
116#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
117#include "mozilla/dom/indexedDB/PBackgroundIDBTransactionParent.h"
118#include "mozilla/dom/indexedDB/PBackgroundIDBVersionChangeTransactionParent.h"
119#include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsParent.h"
120#include "mozilla/dom/ipc/IdType.h"
121#include "mozilla/dom/quota/Assertions.h"
122#include "mozilla/dom/quota/CachingDatabaseConnection.h"
123#include "mozilla/dom/quota/CheckedUnsafePtr.h"
124#include "mozilla/dom/quota/Client.h"
125#include "mozilla/dom/quota/ClientImpl.h"
126#include "mozilla/dom/quota/DebugOnlyMacro.h"
127#include "mozilla/dom/quota/DirectoryLock.h"
128#include "mozilla/dom/quota/DecryptingInputStream_impl.h"
129#include "mozilla/dom/quota/EncryptingOutputStream_impl.h"
130#include "mozilla/dom/quota/FileStreams.h"
131#include "mozilla/dom/quota/OriginScope.h"
132#include "mozilla/dom/quota/PersistenceType.h"
133#include "mozilla/dom/quota/QuotaCommon.h"
134#include "mozilla/dom/quota/QuotaManager.h"
135#include "mozilla/dom/quota/QuotaObject.h"
136#include "mozilla/dom/quota/ResultExtensions.h"
137#include "mozilla/dom/quota/UsageInfo.h"
138#include "mozilla/fallible.h"
139#include "mozilla/ipc/BackgroundParent.h"
140#include "mozilla/ipc/BackgroundUtils.h"
141#include "mozilla/ipc/InputStreamParams.h"
142#include "mozilla/ipc/PBackgroundParent.h"
143#include "mozilla/ipc/PBackgroundSharedTypes.h"
144#include "mozilla/ipc/ProtocolUtils.h"
145#include "mozilla/mozalloc.h"
146#include "mozilla/storage/Variant.h"
147#include "nsBaseHashtable.h"
148#include "nsCOMPtr.h"
149#include "nsClassHashtable.h"
150#include "nsContentUtils.h"
151#include "nsTHashMap.h"
152#include "nsDebug.h"
153#include "nsError.h"
154#include "nsEscape.h"
155#include "nsHashKeys.h"
156#include "nsIAsyncInputStream.h"
157#include "nsID.h"
158#include "nsIDUtils.h"
159#include "nsIDirectoryEnumerator.h"
160#include "nsIEventTarget.h"
161#include "nsIFile.h"
162#include "nsIFileProtocolHandler.h"
163#include "nsIFileStreams.h"
164#include "nsIFileURL.h"
165#include "nsIInputStream.h"
166#include "nsIOutputStream.h"
167#include "nsIProtocolHandler.h"
168#include "nsIRunnable.h"
169#include "nsISupports.h"
170#include "nsISupportsPriority.h"
171#include "nsISupportsUtils.h"
172#include "nsIThread.h"
173#include "nsIThreadInternal.h"
174#include "nsITimer.h"
175#include "nsIURIMutator.h"
176#include "nsIVariant.h"
177#include "nsLiteralString.h"
178#include "nsNetCID.h"
179#include "nsPrintfCString.h"
180#include "nsProxyRelease.h"
181#include "nsServiceManagerUtils.h"
182#include "nsStreamUtils.h"
183#include "nsString.h"
184#include "nsStringFlags.h"
185#include "nsStringFwd.h"
186#include "nsTArray.h"
187#include "nsTHashSet.h"
188#include "nsTHashtable.h"
189#include "nsTLiteralString.h"
190#include "nsTStringRepr.h"
191#include "nsThreadPool.h"
192#include "nsThreadUtils.h"
193#include "nscore.h"
194#include "prinrval.h"
195#include "prio.h"
196#include "prsystem.h"
197#include "prthread.h"
198#include "prtime.h"
199#include "prtypes.h"
200#include "snappy/snappy.h"
201
202struct JSContext;
203class JSObject;
204template <class T>
205class nsPtrHashKey;
206
207#define IDB_DEBUG_LOG(_args) \
208 MOZ_LOG(IndexedDatabaseManager::GetLoggingModule(), LogLevel::Debug, _args)do { const ::mozilla::LogModule* moz_real_module = IndexedDatabaseManager
::GetLoggingModule(); if ((__builtin_expect(!!(mozilla::detail
::log_test(moz_real_module, LogLevel::Debug)), 0))) { mozilla
::detail::log_print(moz_real_module, LogLevel::Debug, MOZ_LOG_EXPAND_ARGS
_args); } } while (0)
209
210#if defined(MOZ_WIDGET_ANDROID)
211# define IDB_MOBILE
212#endif
213
214// Helper macros to reduce assertion verbosity
215// AUUF == ASSERT_UNREACHABLE_UNLESS_FUZZING
216#ifdef DEBUG1
217# ifdef FUZZING
218# define NS_AUUF_OR_WARN(...)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/indexedDB/ActorsParent.cpp"
, 218); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
... ")"); do { *((volatile int*)__null) = 218; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
NS_WARNING(__VA_ARGS__)NS_DebugBreak(NS_DEBUG_WARNING, __VA_ARGS__, nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 218)
219# else
220# define NS_AUUF_OR_WARN(...)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/indexedDB/ActorsParent.cpp"
, 220); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
... ")"); do { *((volatile int*)__null) = 220; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
MOZ_ASSERT(false, __VA_ARGS__)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" __VA_ARGS__ ")"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 220); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
__VA_ARGS__ ")"); do { *((volatile int*)__null) = 220; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
221# endif
222# define NS_AUUF_OR_WARN_IF(cond)[](bool aCond) { if ((__builtin_expect(!!(aCond), 0))) { do {
static_assert( mozilla::detail::AssertionConditionType<decltype
(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("false" " (" "cond" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 222); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
"cond" ")"); do { *((volatile int*)__null) = 222; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false); } return
aCond; }((cond))
\
223 [](bool aCond) { \
224 if (MOZ_UNLIKELY(aCond)(__builtin_expect(!!(aCond), 0))) { \
225 NS_AUUF_OR_WARN(#cond)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" #cond ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 225); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
#cond ")"); do { *((volatile int*)__null) = 225; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
; \
226 } \
227 return aCond; \
228 }((cond))
229#else
230# define NS_AUUF_OR_WARN(...)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/indexedDB/ActorsParent.cpp"
, 230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
... ")"); do { *((volatile int*)__null) = 230; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
\
231 do { \
232 } while (false)
233# define NS_AUUF_OR_WARN_IF(cond)[](bool aCond) { if ((__builtin_expect(!!(aCond), 0))) { do {
static_assert( mozilla::detail::AssertionConditionType<decltype
(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("false" " (" "cond" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 233); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
"cond" ")"); do { *((volatile int*)__null) = 233; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false); } return
aCond; }((cond))
static_cast<bool>(cond)
234#endif
235
236namespace mozilla {
237
238namespace dom::indexedDB {
239
240using namespace mozilla::dom::quota;
241using namespace mozilla::ipc;
242using mozilla::dom::quota::Client;
243
244namespace {
245
246class ConnectionPool;
247class Database;
248struct DatabaseActorInfo;
249class DatabaseFile;
250class DatabaseLoggingInfo;
251class DatabaseMaintenance;
252class Factory;
253class Maintenance;
254class OpenDatabaseOp;
255class TransactionBase;
256class TransactionDatabaseOperationBase;
257class VersionChangeTransaction;
258template <bool StatementHasIndexKeyBindings>
259struct ValuePopulateResponseHelper;
260
261/*******************************************************************************
262 * Constants
263 ******************************************************************************/
264
265const int32_t kStorageProgressGranularity = 1000;
266
267// Changing the value here will override the page size of new databases only.
268// A journal mode change and VACUUM are needed to change existing databases, so
269// the best way to do that is to use the schema version upgrade mechanism.
270const uint32_t kSQLitePageSizeOverride =
271#ifdef IDB_MOBILE
272 2048;
273#else
274 4096;
275#endif
276
277static_assert(kSQLitePageSizeOverride == /* mozStorage default */ 0 ||
278 (kSQLitePageSizeOverride % 2 == 0 &&
279 kSQLitePageSizeOverride >= 512 &&
280 kSQLitePageSizeOverride <= 65536),
281 "Must be 0 (disabled) or a power of 2 between 512 and 65536!");
282
283// Set to -1 to use SQLite's default, 0 to disable, or some positive number to
284// enforce a custom limit.
285const int32_t kMaxWALPages = 5000; // 20MB on desktop, 10MB on mobile.
286
287// Set to some multiple of the page size to grow the database in larger chunks.
288const uint32_t kSQLiteGrowthIncrement = kSQLitePageSizeOverride * 2;
289
290static_assert(kSQLiteGrowthIncrement >= 0 &&
291 kSQLiteGrowthIncrement % kSQLitePageSizeOverride == 0 &&
292 kSQLiteGrowthIncrement < uint32_t(INT32_MAX(2147483647)),
293 "Must be 0 (disabled) or a positive multiple of the page size!");
294
295// The maximum number of threads that can be used for database activity at a
296// single time. Please keep in sync with the constants in
297// test_connection_idle_maintenance*.js tests
298const uint32_t kMaxConnectionThreadCount = 20;
299
300static_assert(kMaxConnectionThreadCount, "Must have at least one thread!");
301
302// The maximum number of threads to keep when idle. Threads that become idle in
303// excess of this number will be shut down immediately.
304const uint32_t kMaxIdleConnectionThreadCount = 2;
305
306static_assert(kMaxConnectionThreadCount >= kMaxIdleConnectionThreadCount,
307 "Idle thread limit must be less than total thread limit!");
308
309// The length of time that database connections will be held open after all
310// transactions have completed before doing idle maintenance. Please keep in
311// sync with the timeouts in test_connection_idle_maintenance*.js tests
312const uint32_t kConnectionIdleMaintenanceMS = 2 * 1000; // 2 seconds
313
314// The length of time that database connections will be held open after all
315// transactions and maintenance have completed.
316const uint32_t kConnectionIdleCloseMS = 10 * 1000; // 10 seconds
317
318// The length of time that idle threads will stay alive before being shut down.
319const uint32_t kConnectionThreadIdleMS = 30 * 1000; // 30 seconds
320
321#define SAVEPOINT_CLAUSE"SAVEPOINT sp;"_ns "SAVEPOINT sp;"_ns
322
323// For efficiency reasons, kEncryptedStreamBlockSize must be a multiple of large
324// 4k disk sectors.
325static_assert(kEncryptedStreamBlockSize % 4096 == 0);
326// Similarly, the file copy buffer size must be a multiple of the encrypted
327// block size.
328static_assert(kFileCopyBufferSize % kEncryptedStreamBlockSize == 0);
329
330constexpr auto kFileManagerDirectoryNameSuffix = u".files"_ns;
331constexpr auto kSQLiteSuffix = u".sqlite"_ns;
332constexpr auto kSQLiteJournalSuffix = u".sqlite-journal"_ns;
333constexpr auto kSQLiteSHMSuffix = u".sqlite-shm"_ns;
334constexpr auto kSQLiteWALSuffix = u".sqlite-wal"_ns;
335
336// The following constants define all names of binding parameters in statements,
337// where they are bound by name. This should include all parameter names which
338// are bound by name. Binding may be done by index when the statement definition
339// and binding are done in the same local scope, and no other reasons prevent
340// using the indexes (e.g. multiple statement variants with differing number or
341// order of parameters). Neither the styles of specifying parameter names
342// (literally vs. via these constants) nor the binding styles (by index vs. by
343// name) should not be mixed for the same statement. The decision must be made
344// for each statement based on the proximity of statement and binding calls.
345constexpr auto kStmtParamNameCurrentKey = "current_key"_ns;
346constexpr auto kStmtParamNameRangeBound = "range_bound"_ns;
347constexpr auto kStmtParamNameObjectStorePosition = "object_store_position"_ns;
348constexpr auto kStmtParamNameLowerKey = "lower_key"_ns;
349constexpr auto kStmtParamNameUpperKey = "upper_key"_ns;
350constexpr auto kStmtParamNameKey = "key"_ns;
351constexpr auto kStmtParamNameObjectStoreId = "object_store_id"_ns;
352constexpr auto kStmtParamNameIndexId = "index_id"_ns;
353// TODO: Maybe the uses of kStmtParamNameId should be replaced by more
354// specific constants such as kStmtParamNameObjectStoreId.
355constexpr auto kStmtParamNameId = "id"_ns;
356constexpr auto kStmtParamNameValue = "value"_ns;
357constexpr auto kStmtParamNameObjectDataKey = "object_data_key"_ns;
358constexpr auto kStmtParamNameIndexDataValues = "index_data_values"_ns;
359constexpr auto kStmtParamNameData = "data"_ns;
360constexpr auto kStmtParamNameFileIds = "file_ids"_ns;
361constexpr auto kStmtParamNameValueLocale = "value_locale"_ns;
362constexpr auto kStmtParamNameLimit = "limit"_ns;
363
364// The following constants define some names of columns in tables, which are
365// referred to in remote locations, e.g. in calls to
366// GetBindingClauseForKeyRange.
367constexpr auto kColumnNameKey = "key"_ns;
368constexpr auto kColumnNameValue = "value"_ns;
369constexpr auto kColumnNameAliasSortKey = "sort_column"_ns;
370
371// SQL fragments used at multiple locations.
372constexpr auto kOpenLimit = " LIMIT "_ns;
373
374// The deletion marker file is created before RemoveDatabaseFilesAndDirectory
375// begins deleting a database. It is removed as the last step of deletion. If a
376// deletion marker file is found when initializing the origin, the deletion
377// routine is run again to ensure that the database and all of its related files
378// are removed. The primary goal of this mechanism is to avoid situations where
379// a database has been partially deleted, leading to inconsistent state for the
380// origin.
381constexpr auto kIdbDeletionMarkerFilePrefix = u"idb-deleting-"_ns;
382
383const uint32_t kDeleteTimeoutMs = 1000;
384
385#ifdef DEBUG1
386
387const int32_t kDEBUGThreadPriority = nsISupportsPriority::PRIORITY_NORMAL;
388const uint32_t kDEBUGThreadSleepMS = 0;
389
390#endif
391
392/*******************************************************************************
393 * Metadata classes
394 ******************************************************************************/
395
396// Can be instantiated either on the QuotaManager IO thread or on a
397// versionchange transaction thread. These threads can never race so this is
398// totally safe.
399struct FullIndexMetadata {
400 IndexMetadata mCommonMetadata = {0, nsString(), KeyPath(0), nsCString(),
401 false, false, false};
402
403 FlippedOnce<false> mDeleted;
404
405 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FullIndexMetadata)public: MozExternalRefCountType AddRef(void) { static_assert(
!std::is_destructible_v<FullIndexMetadata>, "Reference-counted class "
"FullIndexMetadata" " 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/indexedDB/ActorsParent.cpp"
, 405); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
405; __attribute__((nomerge)) ::abort(); } while (false); } }
while (false); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this
), (count), ("FullIndexMetadata"), (uint32_t)(sizeof(*this)))
; return (nsrefcnt)count; } MozExternalRefCountType 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/indexedDB/ActorsParent.cpp"
, 405); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 405
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); nsrefcnt count = --mRefCnt; NS_LogRelease((this), (
count), ("FullIndexMetadata")); if (count == 0) { delete (this
); return 0; } return count; } using HasThreadSafeRefCnt = std
::true_type; protected: ::mozilla::ThreadSafeAutoRefCnt mRefCnt
; public:
406
407 private:
408 ~FullIndexMetadata() = default;
409};
410
411using IndexTable = nsTHashMap<nsUint64HashKey, SafeRefPtr<FullIndexMetadata>>;
412
413// Can be instantiated either on the QuotaManager IO thread or on a
414// versionchange transaction thread. These threads can never race so this is
415// totally safe.
416struct FullObjectStoreMetadata {
417 ObjectStoreMetadata mCommonMetadata;
418 IndexTable mIndexes;
419
420 // The auto increment ids are touched on both the background thread and the
421 // transaction I/O thread, and they must be kept in sync, so we need a mutex
422 // to protect them.
423 struct AutoIncrementIds {
424 int64_t next;
425 int64_t committed;
426 };
427 DataMutex<AutoIncrementIds> mAutoIncrementIds;
428
429 FlippedOnce<false> mDeleted;
430
431 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FullObjectStoreMetadata)public: MozExternalRefCountType AddRef(void) { static_assert(
!std::is_destructible_v<FullObjectStoreMetadata>, "Reference-counted class "
"FullObjectStoreMetadata" " 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/indexedDB/ActorsParent.cpp"
, 431); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
431; __attribute__((nomerge)) ::abort(); } while (false); } }
while (false); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this
), (count), ("FullObjectStoreMetadata"), (uint32_t)(sizeof(*this
))); return (nsrefcnt)count; } MozExternalRefCountType 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/indexedDB/ActorsParent.cpp"
, 431); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 431
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); nsrefcnt count = --mRefCnt; NS_LogRelease((this), (
count), ("FullObjectStoreMetadata")); if (count == 0) { delete
(this); return 0; } return count; } using HasThreadSafeRefCnt
= std::true_type; protected: ::mozilla::ThreadSafeAutoRefCnt
mRefCnt; public:
;
432
433 bool HasLiveIndexes() const;
434
435 FullObjectStoreMetadata(ObjectStoreMetadata aCommonMetadata,
436 const AutoIncrementIds& aAutoIncrementIds)
437 : mCommonMetadata{std::move(aCommonMetadata)},
438 mAutoIncrementIds{AutoIncrementIds{aAutoIncrementIds},
439 "FullObjectStoreMetadata"} {}
440
441 private:
442 ~FullObjectStoreMetadata() = default;
443};
444
445using ObjectStoreTable =
446 nsTHashMap<nsUint64HashKey, SafeRefPtr<FullObjectStoreMetadata>>;
447
448static_assert(
449 std::is_same_v<IndexOrObjectStoreId,
450 std::remove_cv_t<std::remove_reference_t<
451 decltype(std::declval<const ObjectStoreGetParams&>()
452 .objectStoreId())>>>);
453static_assert(
454 std::is_same_v<
455 IndexOrObjectStoreId,
456 std::remove_cv_t<std::remove_reference_t<
457 decltype(std::declval<const IndexGetParams&>().objectStoreId())>>>);
458
459struct FullDatabaseMetadata final : AtomicSafeRefCounted<FullDatabaseMetadata> {
460 DatabaseMetadata mCommonMetadata;
461 nsCString mDatabaseId;
462 nsString mFilePath;
463 ObjectStoreTable mObjectStores;
464
465 IndexOrObjectStoreId mNextObjectStoreId = 0;
466 IndexOrObjectStoreId mNextIndexId = 0;
467
468 public:
469 explicit FullDatabaseMetadata(const DatabaseMetadata& aCommonMetadata)
470 : mCommonMetadata(aCommonMetadata) {
471 AssertIsOnBackgroundThread();
472 }
473
474 [[nodiscard]] SafeRefPtr<FullDatabaseMetadata> Duplicate() const;
475
476 MOZ_DECLARE_REFCOUNTED_TYPENAME(FullDatabaseMetadata)const char* typeName() const { return "FullDatabaseMetadata";
} size_t typeSize() const { return sizeof(*this); }
477};
478
479template <class Enumerable>
480auto MatchMetadataNameOrId(const Enumerable& aEnumerable,
481 IndexOrObjectStoreId aId,
482 Maybe<const nsAString&> aName = Nothing()) {
483 AssertIsOnBackgroundThread();
484 MOZ_ASSERT(aId)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aId)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(aId))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("aId", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 484); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aId" ")"); do
{ *((volatile int*)__null) = 484; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
485
486 const auto it = std::find_if(
487 aEnumerable.cbegin(), aEnumerable.cend(),
488 [aId, aName](const auto& entry) {
489 MOZ_ASSERT(entry.GetKey() != 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(entry.GetKey() != 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(entry.GetKey() != 0))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("entry.GetKey() != 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 489); AnnotateMozCrashReason("MOZ_ASSERT" "(" "entry.GetKey() != 0"
")"); do { *((volatile int*)__null) = 489; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
490
491 const auto& value = entry.GetData();
492 MOZ_ASSERT(value)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(value)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(value))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("value", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 492); AnnotateMozCrashReason("MOZ_ASSERT" "(" "value" ")");
do { *((volatile int*)__null) = 492; __attribute__((nomerge)
) ::abort(); } while (false); } } while (false)
;
493
494 return !value->mDeleted &&
495 (aId == value->mCommonMetadata.id() ||
496 (aName && *aName == value->mCommonMetadata.name()));
497 });
498
499 return ToMaybeRef(it != aEnumerable.cend() ? it->GetData().unsafeGetRawPtr()
500 : nullptr);
501}
502
503/*******************************************************************************
504 * SQLite functions
505 ******************************************************************************/
506
507// WARNING: the hash function used for the database name must not change.
508// That's why this function exists separately from mozilla::HashString(), even
509// though it is (at the time of writing) equivalent. See bug 780408 and bug
510// 940315 for details.
511uint32_t HashName(const nsAString& aName) {
512 struct Helper {
513 static uint32_t RotateBitsLeft32(uint32_t aValue, uint8_t aBits) {
514 MOZ_ASSERT(aBits < 32)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aBits < 32)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aBits < 32))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("aBits < 32",
"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 514); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aBits < 32"
")"); do { *((volatile int*)__null) = 514; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
515 return (aValue << aBits) | (aValue >> (32 - aBits));
516 }
517 };
518
519 static const uint32_t kGoldenRatioU32 = 0x9e3779b9u;
520
521 return std::accumulate(aName.BeginReading(), aName.EndReading(), uint32_t(0),
522 [](uint32_t hash, char16_t ch) {
523 return kGoldenRatioU32 *
524 (Helper::RotateBitsLeft32(hash, 5) ^ ch);
525 });
526}
527
528nsresult ClampResultCode(nsresult aResultCode) {
529 if (NS_SUCCEEDED(aResultCode)((bool)(__builtin_expect(!!(!NS_FAILED_impl(aResultCode)), 1)
))
||
530 NS_ERROR_GET_MODULE(aResultCode) == NS_ERROR_MODULE_DOM_INDEXEDDB33) {
531 return aResultCode;
532 }
533
534 switch (aResultCode) {
535 case NS_ERROR_FILE_NO_DEVICE_SPACE:
536 return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
537 case NS_ERROR_STORAGE_CONSTRAINT:
538 return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
539 default:
540#ifdef DEBUG1
541 nsPrintfCString message("Converting non-IndexedDB error code (0x%" PRIX32"X"
542 ") to "
543 "NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR",
544 static_cast<uint32_t>(aResultCode));
545 NS_WARNING(message.get())NS_DebugBreak(NS_DEBUG_WARNING, message.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 545)
;
546#else
547 ;
548#endif
549 }
550
551 IDB_REPORT_INTERNAL_ERR()mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 551, "UnknownErr")
;
552 return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
553}
554
555Result<nsCOMPtr<nsIFileURL>, nsresult> GetDatabaseFileURL(
556 nsIFile& aDatabaseFile, const int64_t aDirectoryLockId,
557 const Maybe<CipherKey>& aMaybeKey) {
558 MOZ_ASSERT(aDirectoryLockId >= -1)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aDirectoryLockId >= -1)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aDirectoryLockId >= -1)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("aDirectoryLockId >= -1"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 558); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDirectoryLockId >= -1"
")"); do { *((volatile int*)__null) = 558; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
559
560 QM_TRY_INSPECT(auto tryResult3032 = (::mozilla::ToResultGet< nsCOMPtr<
nsIProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/network/protocol;1?name="
"file")); if ((__builtin_expect(!!(tryResult3032.isErr()), 0
))) { mozilla::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<nsIProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/network/protocol;1?name=\" \"file\")"
, tryResult3032.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 564, mozilla::dom::quota::Severity::Error); return tryResult3032
.propagateErr(); } const auto& protocolHandler = tryResult3032
.inspect();
561 const auto& protocolHandler,auto tryResult3032 = (::mozilla::ToResultGet< nsCOMPtr<
nsIProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/network/protocol;1?name="
"file")); if ((__builtin_expect(!!(tryResult3032.isErr()), 0
))) { mozilla::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<nsIProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/network/protocol;1?name=\" \"file\")"
, tryResult3032.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 564, mozilla::dom::quota::Severity::Error); return tryResult3032
.propagateErr(); } const auto& protocolHandler = tryResult3032
.inspect();
562 MOZ_TO_RESULT_GET_TYPED(nsCOMPtr<nsIProtocolHandler>,auto tryResult3032 = (::mozilla::ToResultGet< nsCOMPtr<
nsIProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/network/protocol;1?name="
"file")); if ((__builtin_expect(!!(tryResult3032.isErr()), 0
))) { mozilla::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<nsIProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/network/protocol;1?name=\" \"file\")"
, tryResult3032.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 564, mozilla::dom::quota::Severity::Error); return tryResult3032
.propagateErr(); } const auto& protocolHandler = tryResult3032
.inspect();
563 MOZ_SELECT_OVERLOAD(do_GetService),auto tryResult3032 = (::mozilla::ToResultGet< nsCOMPtr<
nsIProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/network/protocol;1?name="
"file")); if ((__builtin_expect(!!(tryResult3032.isErr()), 0
))) { mozilla::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<nsIProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/network/protocol;1?name=\" \"file\")"
, tryResult3032.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 564, mozilla::dom::quota::Severity::Error); return tryResult3032
.propagateErr(); } const auto& protocolHandler = tryResult3032
.inspect();
564 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "file"))auto tryResult3032 = (::mozilla::ToResultGet< nsCOMPtr<
nsIProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/network/protocol;1?name="
"file")); if ((__builtin_expect(!!(tryResult3032.isErr()), 0
))) { mozilla::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<nsIProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/network/protocol;1?name=\" \"file\")"
, tryResult3032.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 564, mozilla::dom::quota::Severity::Error); return tryResult3032
.propagateErr(); } const auto& protocolHandler = tryResult3032
.inspect();
;
565
566 QM_TRY_INSPECT(const auto& fileHandler,auto tryResult3033 = (::mozilla::ToResultGet< nsCOMPtr<
nsIFileProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_QueryInterface(std::forward<decltype
(aArgs)>(aArgs)...); }, protocolHandler)); if ((__builtin_expect
(!!(tryResult3033.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultGet< nsCOMPtr<nsIFileProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_QueryInterface(std::forward<decltype(aArgs)>(aArgs)...); }, protocolHandler)"
, tryResult3033.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 569, mozilla::dom::quota::Severity::Error); return tryResult3033
.propagateErr(); } const auto& fileHandler = tryResult3033
.inspect();
567 MOZ_TO_RESULT_GET_TYPED(nsCOMPtr<nsIFileProtocolHandler>,auto tryResult3033 = (::mozilla::ToResultGet< nsCOMPtr<
nsIFileProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_QueryInterface(std::forward<decltype
(aArgs)>(aArgs)...); }, protocolHandler)); if ((__builtin_expect
(!!(tryResult3033.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultGet< nsCOMPtr<nsIFileProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_QueryInterface(std::forward<decltype(aArgs)>(aArgs)...); }, protocolHandler)"
, tryResult3033.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 569, mozilla::dom::quota::Severity::Error); return tryResult3033
.propagateErr(); } const auto& fileHandler = tryResult3033
.inspect();
568 MOZ_SELECT_OVERLOAD(do_QueryInterface),auto tryResult3033 = (::mozilla::ToResultGet< nsCOMPtr<
nsIFileProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_QueryInterface(std::forward<decltype
(aArgs)>(aArgs)...); }, protocolHandler)); if ((__builtin_expect
(!!(tryResult3033.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultGet< nsCOMPtr<nsIFileProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_QueryInterface(std::forward<decltype(aArgs)>(aArgs)...); }, protocolHandler)"
, tryResult3033.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 569, mozilla::dom::quota::Severity::Error); return tryResult3033
.propagateErr(); } const auto& fileHandler = tryResult3033
.inspect();
569 protocolHandler))auto tryResult3033 = (::mozilla::ToResultGet< nsCOMPtr<
nsIFileProtocolHandler> >([](auto&&... aArgs) ->
decltype(auto) { return do_QueryInterface(std::forward<decltype
(aArgs)>(aArgs)...); }, protocolHandler)); if ((__builtin_expect
(!!(tryResult3033.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultGet< nsCOMPtr<nsIFileProtocolHandler>>([](auto&&... aArgs) -> decltype(auto) { return do_QueryInterface(std::forward<decltype(aArgs)>(aArgs)...); }, protocolHandler)"
, tryResult3033.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 569, mozilla::dom::quota::Severity::Error); return tryResult3033
.propagateErr(); } const auto& fileHandler = tryResult3033
.inspect();
;
570
571 QM_TRY_INSPECT(const auto& mutator, MOZ_TO_RESULT_INVOKE_MEMBER_TYPED(auto tryResult3034 = (::mozilla::ToResultInvoke< nsCOMPtr<
nsIURIMutator> >( ::std::mem_fn( &::mozilla::detail
::DerefedType<decltype(fileHandler)>::NewFileURIMutator
), (fileHandler), &aDatabaseFile)); if ((__builtin_expect
(!!(tryResult3034.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<nsIURIMutator>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(fileHandler)>::NewFileURIMutator), (fileHandler), &aDatabaseFile)"
, tryResult3034.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 573, mozilla::dom::quota::Severity::Error); return tryResult3034
.propagateErr(); } const auto& mutator = tryResult3034.inspect
();
572 nsCOMPtr<nsIURIMutator>, fileHandler,auto tryResult3034 = (::mozilla::ToResultInvoke< nsCOMPtr<
nsIURIMutator> >( ::std::mem_fn( &::mozilla::detail
::DerefedType<decltype(fileHandler)>::NewFileURIMutator
), (fileHandler), &aDatabaseFile)); if ((__builtin_expect
(!!(tryResult3034.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<nsIURIMutator>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(fileHandler)>::NewFileURIMutator), (fileHandler), &aDatabaseFile)"
, tryResult3034.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 573, mozilla::dom::quota::Severity::Error); return tryResult3034
.propagateErr(); } const auto& mutator = tryResult3034.inspect
();
573 NewFileURIMutator, &aDatabaseFile))auto tryResult3034 = (::mozilla::ToResultInvoke< nsCOMPtr<
nsIURIMutator> >( ::std::mem_fn( &::mozilla::detail
::DerefedType<decltype(fileHandler)>::NewFileURIMutator
), (fileHandler), &aDatabaseFile)); if ((__builtin_expect
(!!(tryResult3034.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<nsIURIMutator>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(fileHandler)>::NewFileURIMutator), (fileHandler), &aDatabaseFile)"
, tryResult3034.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 573, mozilla::dom::quota::Severity::Error); return tryResult3034
.propagateErr(); } const auto& mutator = tryResult3034.inspect
();
;
574
575 // aDirectoryLockId should only be -1 when we are called
576 // - from DatabaseFileManager::InitDirectory when the temporary storage
577 // hasn't been initialized yet. At that time, the in-memory objects (e.g.
578 // OriginInfo) are only being created so it doesn't make sense to tunnel
579 // quota information to QuotaVFS to get corresponding QuotaObject instances
580 // for SQLite files.
581 // - from DeleteDatabaseOp::LoadPreviousVersion, since this might require
582 // temporarily exceeding the quota limit before the database can be
583 // deleted.
584 const nsCString directoryLockIdClause =
585 "&directoryLockId="_ns + IntToCString(aDirectoryLockId);
586
587 const auto keyClause = [&aMaybeKey] {
588 nsAutoCString keyClause;
589 if (aMaybeKey) {
590 keyClause.AssignLiteral("&key=");
591 for (uint8_t byte : IndexedDBCipherStrategy::SerializeKey(*aMaybeKey)) {
592 keyClause.AppendPrintf("%02x", byte);
593 }
594 }
595 return keyClause;
596 }();
597
598 QM_TRY_UNWRAP(auto result, ([&mutator, &directoryLockIdClause, &keyClause] {auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
599 nsCOMPtr<nsIFileURL> result;auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
600 nsresult rv = NS_MutateURI(mutator)auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
601 .SetQuery("cache=private"_ns +auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
602 directoryLockIdClause + keyClause)auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
603 .Finalize(result);auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
604 return NS_SUCCEEDED(rv)auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
605 ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result}auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
606 : Err(rv);auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
607 }()))auto tryResult3035 = (([&mutator, &directoryLockIdClause
, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult
rv = NS_MutateURI(mutator) .SetQuery("cache=private"_ns + directoryLockIdClause
+ keyClause) .Finalize(result); return ((bool)(__builtin_expect
(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL
>, nsresult>{result} : Err(rv); }())); if ((__builtin_expect
(!!(tryResult3035.isErr()), 0))) { mozilla::dom::quota::HandleError
("([&mutator, &directoryLockIdClause, &keyClause] { nsCOMPtr<nsIFileURL> result; nsresult rv = NS_MutateURI(mutator) .SetQuery(\"cache=private\"_ns + directoryLockIdClause + keyClause) .Finalize(result); return ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) ? Result<nsCOMPtr<nsIFileURL>, nsresult>{result} : Err(rv); }())"
, tryResult3035.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 607, mozilla::dom::quota::Severity::Error); return tryResult3035
.propagateErr(); } auto result = tryResult3035.unwrap();
;
608
609 return result;
610}
611
612nsresult SetDefaultPragmas(mozIStorageConnection& aConnection) {
613 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/indexedDB/ActorsParent.cpp"
, 613); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()"
")"); do { *((volatile int*)__null) = 613; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
614
615 static constexpr auto kBuiltInPragmas =
616 // We use foreign keys in DEBUG builds only because there is a performance
617 // cost to using them.
618 "PRAGMA foreign_keys = "
619#ifdef DEBUG1
620 "ON"
621#else
622 "OFF"
623#endif
624 ";"
625
626 // The "INSERT OR REPLACE" statement doesn't fire the update trigger,
627 // instead it fires only the insert trigger. This confuses the update
628 // refcount function. This behavior changes with enabled recursive
629 // triggers, so the statement fires the delete trigger first and then the
630 // insert trigger.
631 "PRAGMA recursive_triggers = ON;"
632
633 // We aggressively truncate the database file when idle so don't bother
634 // overwriting the WAL with 0 during active periods.
635 "PRAGMA secure_delete = OFF;"_ns;
636
637 QM_TRY(MOZ_TO_RESULT(aConnection.ExecuteSimpleSQL(kBuiltInPragmas))){ auto tryResult3036 = (ToResult(aConnection.ExecuteSimpleSQL
(kBuiltInPragmas))); static_assert(std::is_empty_v<typename
decltype(tryResult3036)::ok_type>); if ((__builtin_expect
(!!(tryResult3036.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection.ExecuteSimpleSQL(kBuiltInPragmas))", tryResult3036
.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 637, mozilla::dom::quota::Severity::Error); return tryResult3036
.propagateErr(); } }
;
638
639 QM_TRY(MOZ_TO_RESULT(aConnection.ExecuteSimpleSQL(nsAutoCString{{ auto tryResult3037 = (ToResult(aConnection.ExecuteSimpleSQL
(nsAutoCString{ "PRAGMA synchronous = "_ns + (IndexedDatabaseManager
::FullSynchronous() ? "FULL"_ns : "NORMAL"_ns) + ";"_ns}))); static_assert
(std::is_empty_v<typename decltype(tryResult3037)::ok_type
>); if ((__builtin_expect(!!(tryResult3037.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL(nsAutoCString{ \"PRAGMA synchronous = \"_ns + (IndexedDatabaseManager::FullSynchronous() ? \"FULL\"_ns : \"NORMAL\"_ns) + \";\"_ns}))"
, tryResult3037.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 642, mozilla::dom::quota::Severity::Error); return tryResult3037
.propagateErr(); } }
640 "PRAGMA synchronous = "_ns +{ auto tryResult3037 = (ToResult(aConnection.ExecuteSimpleSQL
(nsAutoCString{ "PRAGMA synchronous = "_ns + (IndexedDatabaseManager
::FullSynchronous() ? "FULL"_ns : "NORMAL"_ns) + ";"_ns}))); static_assert
(std::is_empty_v<typename decltype(tryResult3037)::ok_type
>); if ((__builtin_expect(!!(tryResult3037.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL(nsAutoCString{ \"PRAGMA synchronous = \"_ns + (IndexedDatabaseManager::FullSynchronous() ? \"FULL\"_ns : \"NORMAL\"_ns) + \";\"_ns}))"
, tryResult3037.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 642, mozilla::dom::quota::Severity::Error); return tryResult3037
.propagateErr(); } }
641 (IndexedDatabaseManager::FullSynchronous() ? "FULL"_ns : "NORMAL"_ns) +{ auto tryResult3037 = (ToResult(aConnection.ExecuteSimpleSQL
(nsAutoCString{ "PRAGMA synchronous = "_ns + (IndexedDatabaseManager
::FullSynchronous() ? "FULL"_ns : "NORMAL"_ns) + ";"_ns}))); static_assert
(std::is_empty_v<typename decltype(tryResult3037)::ok_type
>); if ((__builtin_expect(!!(tryResult3037.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL(nsAutoCString{ \"PRAGMA synchronous = \"_ns + (IndexedDatabaseManager::FullSynchronous() ? \"FULL\"_ns : \"NORMAL\"_ns) + \";\"_ns}))"
, tryResult3037.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 642, mozilla::dom::quota::Severity::Error); return tryResult3037
.propagateErr(); } }
642 ";"_ns}))){ auto tryResult3037 = (ToResult(aConnection.ExecuteSimpleSQL
(nsAutoCString{ "PRAGMA synchronous = "_ns + (IndexedDatabaseManager
::FullSynchronous() ? "FULL"_ns : "NORMAL"_ns) + ";"_ns}))); static_assert
(std::is_empty_v<typename decltype(tryResult3037)::ok_type
>); if ((__builtin_expect(!!(tryResult3037.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL(nsAutoCString{ \"PRAGMA synchronous = \"_ns + (IndexedDatabaseManager::FullSynchronous() ? \"FULL\"_ns : \"NORMAL\"_ns) + \";\"_ns}))"
, tryResult3037.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 642, mozilla::dom::quota::Severity::Error); return tryResult3037
.propagateErr(); } }
;
643
644#ifndef IDB_MOBILE
645 if (kSQLiteGrowthIncrement) {
646 // This is just an optimization so ignore the failure if the disk is
647 // currently too full.
648 QM_TRY(QM_OR_ELSE_WARN_IF({ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
649 // Expression.{ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
650 MOZ_TO_RESULT({ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
651 aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns)),{ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
652 // Predicate.{ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
653 IsSpecificError<NS_ERROR_FILE_TOO_BIG>,{ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
654 // Fallback.{ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
655 ErrToDefaultOk<>)){ auto tryResult3038 = (mozilla::dom::quota::OrElseIf( (ToResult
(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, ""_ns
))), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::
HandleError("\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\"\\\"_ns))\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<>)); static_assert(std::is_empty_v<typename decltype
(tryResult3038)::ok_type>); if ((__builtin_expect(!!(tryResult3038
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \"\"_ns))), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_FILE_TOO_BIG>(firstRes); mozilla::dom::quota::HandleError(\"\\\"ToResult(aConnection.SetGrowthIncrement(kSQLiteGrowthIncrement, \\\\\\\"\\\\\\\"_ns))\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 655, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<>)"
, tryResult3038.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 655, mozilla::dom::quota::Severity::Error); return tryResult3038
.propagateErr(); } }
;
656 }
657#endif // IDB_MOBILE
658
659 return NS_OK;
660}
661
662nsresult SetJournalMode(mozIStorageConnection& aConnection) {
663 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/indexedDB/ActorsParent.cpp"
, 663); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()"
")"); do { *((volatile int*)__null) = 663; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
664
665 // Try enabling WAL mode. This can fail in various circumstances so we have to
666 // check the results here.
667 constexpr auto journalModeQueryStart = "PRAGMA journal_mode = "_ns;
668 constexpr auto journalModeWAL = "wal"_ns;
669
670 QM_TRY_INSPECT(const auto& stmt,auto tryResult3039 = (CreateAndExecuteSingleStepStatement( aConnection
, journalModeQueryStart + journalModeWAL)); if ((__builtin_expect
(!!(tryResult3039.isErr()), 0))) { mozilla::dom::quota::HandleError
("CreateAndExecuteSingleStepStatement( aConnection, journalModeQueryStart + journalModeWAL)"
, tryResult3039.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 672, mozilla::dom::quota::Severity::Error); return tryResult3039
.propagateErr(); } const auto& stmt = tryResult3039.inspect
();
671 CreateAndExecuteSingleStepStatement(auto tryResult3039 = (CreateAndExecuteSingleStepStatement( aConnection
, journalModeQueryStart + journalModeWAL)); if ((__builtin_expect
(!!(tryResult3039.isErr()), 0))) { mozilla::dom::quota::HandleError
("CreateAndExecuteSingleStepStatement( aConnection, journalModeQueryStart + journalModeWAL)"
, tryResult3039.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 672, mozilla::dom::quota::Severity::Error); return tryResult3039
.propagateErr(); } const auto& stmt = tryResult3039.inspect
();
672 aConnection, journalModeQueryStart + journalModeWAL))auto tryResult3039 = (CreateAndExecuteSingleStepStatement( aConnection
, journalModeQueryStart + journalModeWAL)); if ((__builtin_expect
(!!(tryResult3039.isErr()), 0))) { mozilla::dom::quota::HandleError
("CreateAndExecuteSingleStepStatement( aConnection, journalModeQueryStart + journalModeWAL)"
, tryResult3039.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 672, mozilla::dom::quota::Severity::Error); return tryResult3039
.propagateErr(); } const auto& stmt = tryResult3039.inspect
();
;
673
674 QM_TRY_INSPECT(auto tryResult3040 = (::mozilla::ToResultInvoke< nsCString
>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype
(*stmt)>::GetUTF8String), (*stmt), 0)); if ((__builtin_expect
(!!(tryResult3040.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCString>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(*stmt)>::GetUTF8String), (*stmt), 0)"
, tryResult3040.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 676, mozilla::dom::quota::Severity::Error); return tryResult3040
.propagateErr(); } const auto& journalMode = tryResult3040
.inspect();
675 const auto& journalMode,auto tryResult3040 = (::mozilla::ToResultInvoke< nsCString
>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype
(*stmt)>::GetUTF8String), (*stmt), 0)); if ((__builtin_expect
(!!(tryResult3040.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCString>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(*stmt)>::GetUTF8String), (*stmt), 0)"
, tryResult3040.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 676, mozilla::dom::quota::Severity::Error); return tryResult3040
.propagateErr(); } const auto& journalMode = tryResult3040
.inspect();
676 MOZ_TO_RESULT_INVOKE_MEMBER_TYPED(nsCString, *stmt, GetUTF8String, 0))auto tryResult3040 = (::mozilla::ToResultInvoke< nsCString
>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype
(*stmt)>::GetUTF8String), (*stmt), 0)); if ((__builtin_expect
(!!(tryResult3040.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCString>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(*stmt)>::GetUTF8String), (*stmt), 0)"
, tryResult3040.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 676, mozilla::dom::quota::Severity::Error); return tryResult3040
.propagateErr(); } const auto& journalMode = tryResult3040
.inspect();
;
677
678 if (journalMode.Equals(journalModeWAL)) {
679 // WAL mode successfully enabled. Maybe set limits on its size here.
680 if (kMaxWALPages >= 0) {
681 QM_TRY(MOZ_TO_RESULT(aConnection.ExecuteSimpleSQL({ auto tryResult3041 = (ToResult(aConnection.ExecuteSimpleSQL
( "PRAGMA wal_autocheckpoint = "_ns + IntToCString(kMaxWALPages
)))); static_assert(std::is_empty_v<typename decltype(tryResult3041
)::ok_type>); if ((__builtin_expect(!!(tryResult3041.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL( \"PRAGMA wal_autocheckpoint = \"_ns + IntToCString(kMaxWALPages)))"
, tryResult3041.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 682, mozilla::dom::quota::Severity::Error); return tryResult3041
.propagateErr(); } }
682 "PRAGMA wal_autocheckpoint = "_ns + IntToCString(kMaxWALPages)))){ auto tryResult3041 = (ToResult(aConnection.ExecuteSimpleSQL
( "PRAGMA wal_autocheckpoint = "_ns + IntToCString(kMaxWALPages
)))); static_assert(std::is_empty_v<typename decltype(tryResult3041
)::ok_type>); if ((__builtin_expect(!!(tryResult3041.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL( \"PRAGMA wal_autocheckpoint = \"_ns + IntToCString(kMaxWALPages)))"
, tryResult3041.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 682, mozilla::dom::quota::Severity::Error); return tryResult3041
.propagateErr(); } }
;
683 }
684 } else {
685 NS_WARNING("Failed to set WAL mode, falling back to normal journal mode.")NS_DebugBreak(NS_DEBUG_WARNING, "Failed to set WAL mode, falling back to normal journal mode."
, nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 685)
;
686#ifdef IDB_MOBILE
687 QM_TRY(MOZ_TO_RESULT({ auto tryResult3042 = (ToResult(aConnection.ExecuteSimpleSQL
(journalModeQueryStart + "truncate"_ns))); static_assert(std::
is_empty_v<typename decltype(tryResult3042)::ok_type>);
if ((__builtin_expect(!!(tryResult3042.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL(journalModeQueryStart + \"truncate\"_ns))"
, tryResult3042.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 688, mozilla::dom::quota::Severity::Error); return tryResult3042
.propagateErr(); } }
688 aConnection.ExecuteSimpleSQL(journalModeQueryStart + "truncate"_ns))){ auto tryResult3042 = (ToResult(aConnection.ExecuteSimpleSQL
(journalModeQueryStart + "truncate"_ns))); static_assert(std::
is_empty_v<typename decltype(tryResult3042)::ok_type>);
if ((__builtin_expect(!!(tryResult3042.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aConnection.ExecuteSimpleSQL(journalModeQueryStart + \"truncate\"_ns))"
, tryResult3042.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 688, mozilla::dom::quota::Severity::Error); return tryResult3042
.propagateErr(); } }
;
689#endif
690 }
691
692 return NS_OK;
693}
694
695Result<MovingNotNull<nsCOMPtr<mozIStorageConnection>>, nsresult> OpenDatabase(
696 mozIStorageService& aStorageService, nsIFileURL& aFileURL,
697 const uint32_t aTelemetryId = 0) {
698 const nsAutoCString telemetryFilename =
699 aTelemetryId ? "indexedDB-"_ns + IntToCString(aTelemetryId) +
700 NS_ConvertUTF16toUTF8(kSQLiteSuffix)
701 : nsAutoCString();
702
703 QM_TRY_UNWRAP(auto connection,auto tryResult3043 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageConnection> >( ::std::mem_fn( &::mozilla
::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL
), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService
::CONNECTION_INTERRUPTIBLE)); if ((__builtin_expect(!!(tryResult3043
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageConnection>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService::CONNECTION_INTERRUPTIBLE)"
, tryResult3043.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 707, mozilla::dom::quota::Severity::Error); return tryResult3043
.propagateErr(); } auto connection = tryResult3043.unwrap();
704 MOZ_TO_RESULT_INVOKE_MEMBER_TYPED(auto tryResult3043 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageConnection> >( ::std::mem_fn( &::mozilla
::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL
), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService
::CONNECTION_INTERRUPTIBLE)); if ((__builtin_expect(!!(tryResult3043
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageConnection>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService::CONNECTION_INTERRUPTIBLE)"
, tryResult3043.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 707, mozilla::dom::quota::Severity::Error); return tryResult3043
.propagateErr(); } auto connection = tryResult3043.unwrap();
705 nsCOMPtr<mozIStorageConnection>, aStorageService,auto tryResult3043 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageConnection> >( ::std::mem_fn( &::mozilla
::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL
), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService
::CONNECTION_INTERRUPTIBLE)); if ((__builtin_expect(!!(tryResult3043
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageConnection>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService::CONNECTION_INTERRUPTIBLE)"
, tryResult3043.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 707, mozilla::dom::quota::Severity::Error); return tryResult3043
.propagateErr(); } auto connection = tryResult3043.unwrap();
706 OpenDatabaseWithFileURL, &aFileURL, telemetryFilename,auto tryResult3043 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageConnection> >( ::std::mem_fn( &::mozilla
::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL
), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService
::CONNECTION_INTERRUPTIBLE)); if ((__builtin_expect(!!(tryResult3043
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageConnection>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService::CONNECTION_INTERRUPTIBLE)"
, tryResult3043.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 707, mozilla::dom::quota::Severity::Error); return tryResult3043
.propagateErr(); } auto connection = tryResult3043.unwrap();
707 mozIStorageService::CONNECTION_INTERRUPTIBLE))auto tryResult3043 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageConnection> >( ::std::mem_fn( &::mozilla
::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL
), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService
::CONNECTION_INTERRUPTIBLE)); if ((__builtin_expect(!!(tryResult3043
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageConnection>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(aStorageService)>::OpenDatabaseWithFileURL), (aStorageService), &aFileURL, telemetryFilename, mozIStorageService::CONNECTION_INTERRUPTIBLE)"
, tryResult3043.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 707, mozilla::dom::quota::Severity::Error); return tryResult3043
.propagateErr(); } auto connection = tryResult3043.unwrap();
;
708
709 return WrapMovingNotNull(std::move(connection));
710}
711
712Result<MovingNotNull<nsCOMPtr<mozIStorageConnection>>, nsresult>
713OpenDatabaseAndHandleBusy(mozIStorageService& aStorageService,
714 nsIFileURL& aFileURL,
715 const uint32_t aTelemetryId = 0) {
716 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/indexedDB/ActorsParent.cpp"
, 716); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()"
")"); do { *((volatile int*)__null) = 716; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
717 MOZ_ASSERT(!IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 717); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 717; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
718
719 using ConnectionType = Maybe<MovingNotNull<nsCOMPtr<mozIStorageConnection>>>;
720
721 QM_TRY_UNWRAP(auto connection,auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
722 QM_OR_ELSE_WARN_IF(auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
723 // Expressionauto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
724 OpenDatabase(aStorageService, aFileURL, aTelemetryId)auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
725 .map([](auto connection) -> ConnectionType {auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
726 return Some(std::move(connection));auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
727 }),auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
728 // Predicate.auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
729 IsSpecificError<NS_ERROR_STORAGE_BUSY>,auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
730 // Fallback.auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
731 ErrToDefaultOk<ConnectionType>))auto tryResult3044 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = IsSpecificError
<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::
HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3044
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = IsSpecificError<NS_ERROR_STORAGE_BUSY>(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 731, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3044.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 731, mozilla::dom::quota::Severity::Error); return tryResult3044
.propagateErr(); } auto connection = tryResult3044.unwrap();
;
732
733 if (connection.isNothing()) {
734#ifdef DEBUG1
735 {
736 nsCString path;
737 MOZ_ALWAYS_SUCCEEDS(aFileURL.GetFileName(path))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aFileURL.GetFileName(path))), 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(aFileURL.GetFileName(path))" ")",
"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 737); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aFileURL.GetFileName(path))" ")"); do { *
((volatile int*)__null) = 737; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false); } } while (false)
;
738
739 nsPrintfCString message(
740 "Received NS_ERROR_STORAGE_BUSY when attempting to open database "
741 "'%s', retrying for up to 10 seconds",
742 path.get());
743 NS_WARNING(message.get())NS_DebugBreak(NS_DEBUG_WARNING, message.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 743)
;
744 }
745#endif
746
747 // Another thread must be checkpointing the WAL. Wait up to 10 seconds for
748 // that to complete.
749 const TimeStamp start = TimeStamp::NowLoRes();
750
751 do {
752 PR_Sleep(PR_MillisecondsToInterval(100));
753
754 QM_TRY_UNWRAP(connection,auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
755 QM_OR_ELSE_WARN_IF(auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
756 // Expression.auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
757 OpenDatabase(aStorageService, aFileURL, aTelemetryId)auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
758 .map([](auto connection) -> ConnectionType {auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
759 return Some(std::move(connection));auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
760 }),auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
761 // Predicate.auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
762 ([&start](nsresult aValue) {auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
763 return aValue == NS_ERROR_STORAGE_BUSY &&auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
764 TimeStamp::NowLoRes() - start <=auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
765 TimeDuration::FromSeconds(10);auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
766 }),auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
767 // Fallback.auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
768 ErrToDefaultOk<ConnectionType>))auto tryResult3045 = (mozilla::dom::quota::OrElseIf( (OpenDatabase
(aStorageService, aFileURL, aTelemetryId) .map([](auto connection
) -> ConnectionType { return Some(std::move(connection)); }
)), [&](const auto& firstRes) { bool res = ([&start
](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY &&
TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds
(10); })(firstRes); mozilla::dom::quota::HandleError("\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<ConnectionType>)); if ((__builtin_expect(!!(tryResult3045
.isErr()), 0))) { mozilla::dom::quota::HandleError("mozilla::dom::quota::OrElseIf( (OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })), [&](const auto& firstRes) { bool res = ([&start](nsresult aValue) { return aValue == NS_ERROR_STORAGE_BUSY && TimeStamp::NowLoRes() - start <= TimeDuration::FromSeconds(10); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabase(aStorageService, aFileURL, aTelemetryId) .map([](auto connection) -> ConnectionType { return Some(std::move(connection)); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 768, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<ConnectionType>)"
, tryResult3045.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 768, mozilla::dom::quota::Severity::Error); return tryResult3045
.propagateErr(); } connection = tryResult3045.unwrap();
;
769 } while (connection.isNothing());
770 }
771
772 return connection.extract();
773}
774
775// Returns true if a given nsIFile exists and is a directory. Returns false if
776// it doesn't exist. Returns an error if it exists, but is not a directory, or
777// any other error occurs.
778Result<bool, nsresult> ExistsAsDirectory(nsIFile& aDirectory) {
779 QM_TRY_INSPECT(const bool& exists,auto tryResult3046 = (::mozilla::ToResultInvokeMember( (aDirectory
), &::mozilla::detail::DerefedType<decltype(aDirectory
)>::Exists)); if ((__builtin_expect(!!(tryResult3046.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDirectory), &::mozilla::detail::DerefedType<decltype(aDirectory)>::Exists)"
, tryResult3046.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 780, mozilla::dom::quota::Severity::Error); return tryResult3046
.propagateErr(); } const bool& exists = tryResult3046.inspect
();
780 MOZ_TO_RESULT_INVOKE_MEMBER(aDirectory, Exists))auto tryResult3046 = (::mozilla::ToResultInvokeMember( (aDirectory
), &::mozilla::detail::DerefedType<decltype(aDirectory
)>::Exists)); if ((__builtin_expect(!!(tryResult3046.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDirectory), &::mozilla::detail::DerefedType<decltype(aDirectory)>::Exists)"
, tryResult3046.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 780, mozilla::dom::quota::Severity::Error); return tryResult3046
.propagateErr(); } const bool& exists = tryResult3046.inspect
();
;
781
782 if (exists) {
783 QM_TRY_INSPECT(const bool& isDirectory,auto tryResult3047 = (::mozilla::ToResultInvokeMember( (aDirectory
), &::mozilla::detail::DerefedType<decltype(aDirectory
)>::IsDirectory)); if ((__builtin_expect(!!(tryResult3047.
isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDirectory), &::mozilla::detail::DerefedType<decltype(aDirectory)>::IsDirectory)"
, tryResult3047.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 784, mozilla::dom::quota::Severity::Error); return tryResult3047
.propagateErr(); } const bool& isDirectory = tryResult3047
.inspect();
784 MOZ_TO_RESULT_INVOKE_MEMBER(aDirectory, IsDirectory))auto tryResult3047 = (::mozilla::ToResultInvokeMember( (aDirectory
), &::mozilla::detail::DerefedType<decltype(aDirectory
)>::IsDirectory)); if ((__builtin_expect(!!(tryResult3047.
isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDirectory), &::mozilla::detail::DerefedType<decltype(aDirectory)>::IsDirectory)"
, tryResult3047.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 784, mozilla::dom::quota::Severity::Error); return tryResult3047
.propagateErr(); } const bool& isDirectory = tryResult3047
.inspect();
;
785
786 QM_TRY(OkIf(isDirectory), Err(NS_ERROR_FAILURE)){ auto tryResult3048 = (OkIf(isDirectory)); static_assert(std
::is_empty_v<typename decltype(tryResult3048)::ok_type>
); if ((__builtin_expect(!!(tryResult3048.isErr()), 0))) { auto
tryTempError __attribute__((__unused__)) = tryResult3048.unwrapErr
(); mozilla::dom::quota::HandleError("OkIf(isDirectory)", tryTempError
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 786, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "OkIf(isDirectory)"
, tryTempError, Err(NS_ERROR_FAILURE)); } }
;
787 }
788
789 return exists;
790}
791
792constexpr nsresult mapNoDeviceSpaceError(nsresult aRv) {
793 if (aRv == NS_ERROR_FILE_NO_DEVICE_SPACE) {
794 // mozstorage translates SQLITE_FULL to
795 // NS_ERROR_FILE_NO_DEVICE_SPACE, which we know better as
796 // NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR.
797 return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
798 }
799 return aRv;
800}
801
802Result<MovingNotNull<nsCOMPtr<mozIStorageConnection>>, nsresult>
803CreateStorageConnection(nsIFile& aDBFile, nsIFile& aFMDirectory,
804 const nsAString& aName, const nsACString& aOrigin,
805 const int64_t aDirectoryLockId,
806 const uint32_t aTelemetryId,
807 const Maybe<CipherKey>& aMaybeKey) {
808 AssertIsOnIOThread();
809 MOZ_ASSERT(aDirectoryLockId >= -1)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aDirectoryLockId >= -1)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aDirectoryLockId >= -1)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("aDirectoryLockId >= -1"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 809); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDirectoryLockId >= -1"
")"); do { *((volatile int*)__null) = 809; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
810
811 AUTO_PROFILER_LABEL("CreateStorageConnection", DOM)mozilla::AutoProfilerLabel raiiObject811( "CreateStorageConnection"
, nullptr, JS::ProfilingCategoryPair::DOM)
;
812
813 QM_TRY_INSPECT(const auto& dbFileUrl,auto tryResult3049 = (GetDatabaseFileURL(aDBFile, aDirectoryLockId
, aMaybeKey)); if ((__builtin_expect(!!(tryResult3049.isErr()
), 0))) { mozilla::dom::quota::HandleError("GetDatabaseFileURL(aDBFile, aDirectoryLockId, aMaybeKey)"
, tryResult3049.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 814, mozilla::dom::quota::Severity::Error); return tryResult3049
.propagateErr(); } const auto& dbFileUrl = tryResult3049.
inspect();
814 GetDatabaseFileURL(aDBFile, aDirectoryLockId, aMaybeKey))auto tryResult3049 = (GetDatabaseFileURL(aDBFile, aDirectoryLockId
, aMaybeKey)); if ((__builtin_expect(!!(tryResult3049.isErr()
), 0))) { mozilla::dom::quota::HandleError("GetDatabaseFileURL(aDBFile, aDirectoryLockId, aMaybeKey)"
, tryResult3049.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 814, mozilla::dom::quota::Severity::Error); return tryResult3049
.propagateErr(); } const auto& dbFileUrl = tryResult3049.
inspect();
;
815
816 QM_TRY_INSPECT(const auto& storageService,auto tryResult3050 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3050.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3050.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 819, mozilla::dom::quota::Severity::Error); return tryResult3050
.propagateErr(); } const auto& storageService = tryResult3050
.inspect();
817 MOZ_TO_RESULT_GET_TYPED(nsCOMPtr<mozIStorageService>,auto tryResult3050 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3050.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3050.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 819, mozilla::dom::quota::Severity::Error); return tryResult3050
.propagateErr(); } const auto& storageService = tryResult3050
.inspect();
818 MOZ_SELECT_OVERLOAD(do_GetService),auto tryResult3050 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3050.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3050.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 819, mozilla::dom::quota::Severity::Error); return tryResult3050
.propagateErr(); } const auto& storageService = tryResult3050
.inspect();
819 MOZ_STORAGE_SERVICE_CONTRACTID))auto tryResult3050 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3050.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3050.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 819, mozilla::dom::quota::Severity::Error); return tryResult3050
.propagateErr(); } const auto& storageService = tryResult3050
.inspect();
;
820
821 QM_TRY_UNWRAP(auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
822 auto connection,auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
823 QM_OR_ELSE_WARN_IF(auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
824 // Expression.auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
825 OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId)auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
826 .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> {auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
827 return std::move(connection).unwrapBasePtr();auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
828 }),auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
829 // Predicate.auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
830 ([&aName](nsresult aValue) {auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
831 // If we're just opening the database during origin initialization,auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
832 // then we don't want to erase any files. The failure here will failauto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
833 // origin initialization too.auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
834 return IsDatabaseCorruptionError(aValue) && !aName.IsVoid();auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
835 }),auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
836 // Fallback.auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
837 ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>))auto tryResult3051 = (mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy
(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection
) -> nsCOMPtr<mozIStorageConnection> { return std::move
(connection).unwrapBasePtr(); })), [&](const auto& firstRes
) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError
(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom
::quota::HandleError("\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\""
, firstRes, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, res ? mozilla::dom::quota::Severity::Warning : mozilla
::dom::quota::Severity::Error); return res; }, ErrToDefaultOk
<nsCOMPtr<mozIStorageConnection>>)); if ((__builtin_expect
(!!(tryResult3051.isErr()), 0))) { mozilla::dom::quota::HandleError
("mozilla::dom::quota::OrElseIf( (OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })), [&](const auto& firstRes) { bool res = ([&aName](nsresult aValue) { return IsDatabaseCorruptionError(aValue) && !aName.IsVoid(); })(firstRes); mozilla::dom::quota::HandleError(\"\\\"OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId) .map([](auto connection) -> nsCOMPtr<mozIStorageConnection> { return std::move(connection).unwrapBasePtr(); })\\\"\", firstRes, \"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp\", 837, res ? mozilla::dom::quota::Severity::Warning : mozilla::dom::quota::Severity::Error); return res; }, ErrToDefaultOk<nsCOMPtr<mozIStorageConnection>>)"
, tryResult3051.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 837, mozilla::dom::quota::Severity::Error); return tryResult3051
.propagateErr(); } auto connection = tryResult3051.unwrap();
;
838
839 if (!connection) {
840 // XXX Shouldn't we also update quota usage?
841
842 // Nuke the database file.
843 QM_TRY(MOZ_TO_RESULT(aDBFile.Remove(false))){ auto tryResult3052 = (ToResult(aDBFile.Remove(false))); static_assert
(std::is_empty_v<typename decltype(tryResult3052)::ok_type
>); if ((__builtin_expect(!!(tryResult3052.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(aDBFile.Remove(false))"
, tryResult3052.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 843, mozilla::dom::quota::Severity::Error); return tryResult3052
.propagateErr(); } }
;
844 QM_TRY_INSPECT(const bool& existsAsDirectory,auto tryResult3053 = (ExistsAsDirectory(aFMDirectory)); if ((
__builtin_expect(!!(tryResult3053.isErr()), 0))) { mozilla::dom
::quota::HandleError("ExistsAsDirectory(aFMDirectory)", tryResult3053
.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 845, mozilla::dom::quota::Severity::Error); return tryResult3053
.propagateErr(); } const bool& existsAsDirectory = tryResult3053
.inspect();
845 ExistsAsDirectory(aFMDirectory))auto tryResult3053 = (ExistsAsDirectory(aFMDirectory)); if ((
__builtin_expect(!!(tryResult3053.isErr()), 0))) { mozilla::dom
::quota::HandleError("ExistsAsDirectory(aFMDirectory)", tryResult3053
.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 845, mozilla::dom::quota::Severity::Error); return tryResult3053
.propagateErr(); } const bool& existsAsDirectory = tryResult3053
.inspect();
;
846
847 if (existsAsDirectory) {
848 QM_TRY(MOZ_TO_RESULT(aFMDirectory.Remove(true))){ auto tryResult3054 = (ToResult(aFMDirectory.Remove(true)));
static_assert(std::is_empty_v<typename decltype(tryResult3054
)::ok_type>); if ((__builtin_expect(!!(tryResult3054.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(aFMDirectory.Remove(true))"
, tryResult3054.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 848, mozilla::dom::quota::Severity::Error); return tryResult3054
.propagateErr(); } }
;
849 }
850
851 QM_TRY_UNWRAP(connection, OpenDatabaseAndHandleBusy(auto tryResult3055 = (OpenDatabaseAndHandleBusy( *storageService
, *dbFileUrl, aTelemetryId)); if ((__builtin_expect(!!(tryResult3055
.isErr()), 0))) { mozilla::dom::quota::HandleError("OpenDatabaseAndHandleBusy( *storageService, *dbFileUrl, aTelemetryId)"
, tryResult3055.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 852, mozilla::dom::quota::Severity::Error); return tryResult3055
.propagateErr(); } connection = tryResult3055.unwrap();
852 *storageService, *dbFileUrl, aTelemetryId))auto tryResult3055 = (OpenDatabaseAndHandleBusy( *storageService
, *dbFileUrl, aTelemetryId)); if ((__builtin_expect(!!(tryResult3055
.isErr()), 0))) { mozilla::dom::quota::HandleError("OpenDatabaseAndHandleBusy( *storageService, *dbFileUrl, aTelemetryId)"
, tryResult3055.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 852, mozilla::dom::quota::Severity::Error); return tryResult3055
.propagateErr(); } connection = tryResult3055.unwrap();
;
853 }
854
855 QM_TRY(MOZ_TO_RESULT(SetDefaultPragmas(*connection))){ auto tryResult3056 = (ToResult(SetDefaultPragmas(*connection
))); static_assert(std::is_empty_v<typename decltype(tryResult3056
)::ok_type>); if ((__builtin_expect(!!(tryResult3056.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(SetDefaultPragmas(*connection))"
, tryResult3056.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 855, mozilla::dom::quota::Severity::Error); return tryResult3056
.propagateErr(); } }
;
856 QM_TRY(MOZ_TO_RESULT(connection->EnableModule("filesystem"_ns))){ auto tryResult3057 = (ToResult(connection->EnableModule(
"filesystem"_ns))); static_assert(std::is_empty_v<typename
decltype(tryResult3057)::ok_type>); if ((__builtin_expect
(!!(tryResult3057.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(connection->EnableModule(\"filesystem\"_ns))", tryResult3057
.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 856, mozilla::dom::quota::Severity::Error); return tryResult3057
.propagateErr(); } }
;
857
858 // Check to make sure that the database schema is correct.
859 QM_TRY_INSPECT(const int32_t& schemaVersion,auto tryResult3058 = (::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::GetSchemaVersion)); if ((__builtin_expect(!!(tryResult3058
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryResult3058.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 860, mozilla::dom::quota::Severity::Error); return tryResult3058
.propagateErr(); } const int32_t& schemaVersion = tryResult3058
.inspect();
860 MOZ_TO_RESULT_INVOKE_MEMBER(connection, GetSchemaVersion))auto tryResult3058 = (::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::GetSchemaVersion)); if ((__builtin_expect(!!(tryResult3058
.isErr()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryResult3058.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 860, mozilla::dom::quota::Severity::Error); return tryResult3058
.propagateErr(); } const int32_t& schemaVersion = tryResult3058
.inspect();
;
861
862 // Unknown schema will fail origin initialization too.
863 QM_TRY(OkIf(schemaVersion || !aName.IsVoid()),{ auto tryResult3059 = (OkIf(schemaVersion || !aName.IsVoid()
)); static_assert(std::is_empty_v<typename decltype(tryResult3059
)::ok_type>); if ((__builtin_expect(!!(tryResult3059.isErr
()), 0))) { auto tryTempError = tryResult3059.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 866, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is not set!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
864 Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR), [](const auto&) {{ auto tryResult3059 = (OkIf(schemaVersion || !aName.IsVoid()
)); static_assert(std::is_empty_v<typename decltype(tryResult3059
)::ok_type>); if ((__builtin_expect(!!(tryResult3059.isErr
()), 0))) { auto tryTempError = tryResult3059.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 866, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is not set!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
865 IDB_WARNING("Unable to open IndexedDB database, schema is not set!");{ auto tryResult3059 = (OkIf(schemaVersion || !aName.IsVoid()
)); static_assert(std::is_empty_v<typename decltype(tryResult3059
)::ok_type>); if ((__builtin_expect(!!(tryResult3059.isErr
()), 0))) { auto tryTempError = tryResult3059.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 866, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is not set!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
866 }){ auto tryResult3059 = (OkIf(schemaVersion || !aName.IsVoid()
)); static_assert(std::is_empty_v<typename decltype(tryResult3059
)::ok_type>); if ((__builtin_expect(!!(tryResult3059.isErr
()), 0))) { auto tryTempError = tryResult3059.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 866, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is not set!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 865); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion || !aName.IsVoid())"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
;
867
868 QM_TRY({ auto tryResult3060 = (OkIf(schemaVersion <= kSQLiteSchemaVersion
)); static_assert(std::is_empty_v<typename decltype(tryResult3060
)::ok_type>); if ((__builtin_expect(!!(tryResult3060.isErr
()), 0))) { auto tryTempError = tryResult3060.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 872, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is too high!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
869 OkIf(schemaVersion <= kSQLiteSchemaVersion),{ auto tryResult3060 = (OkIf(schemaVersion <= kSQLiteSchemaVersion
)); static_assert(std::is_empty_v<typename decltype(tryResult3060
)::ok_type>); if ((__builtin_expect(!!(tryResult3060.isErr
()), 0))) { auto tryTempError = tryResult3060.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 872, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is too high!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
870 Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR), [](const auto&) {{ auto tryResult3060 = (OkIf(schemaVersion <= kSQLiteSchemaVersion
)); static_assert(std::is_empty_v<typename decltype(tryResult3060
)::ok_type>); if ((__builtin_expect(!!(tryResult3060.isErr
()), 0))) { auto tryTempError = tryResult3060.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 872, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is too high!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
871 IDB_WARNING("Unable to open IndexedDB database, schema is too high!");{ auto tryResult3060 = (OkIf(schemaVersion <= kSQLiteSchemaVersion
)); static_assert(std::is_empty_v<typename decltype(tryResult3060
)::ok_type>); if ((__builtin_expect(!!(tryResult3060.isErr
()), 0))) { auto tryTempError = tryResult3060.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 872, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is too high!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
872 }){ auto tryResult3060 = (OkIf(schemaVersion <= kSQLiteSchemaVersion
)); static_assert(std::is_empty_v<typename decltype(tryResult3060
)::ok_type>); if ((__builtin_expect(!!(tryResult3060.isErr
()), 0))) { auto tryTempError = tryResult3060.unwrapErr(); mozilla
::dom::quota::HandleError("OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 872, mozilla::dom::quota::Severity::Error); [](const auto&
) { do { nsPrintfCString s("Unable to open IndexedDB database, schema is too high!"
); mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871, s.get()); NS_DebugBreak(NS_DEBUG_WARNING, s.get(), nullptr
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 871); } while (0); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(schemaVersion <= kSQLiteSchemaVersion)"
, tryTempError, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
;
873
874 bool journalModeSet = false;
875
876 if (schemaVersion != kSQLiteSchemaVersion) {
877 const bool newDatabase = !schemaVersion;
878
879 if (newDatabase) {
880 // Set the page size first.
881 const auto sqlitePageSizeOverride =
882 aMaybeKey ? 8192 : kSQLitePageSizeOverride;
883 if (sqlitePageSizeOverride) {
884 QM_TRY(MOZ_TO_RESULT(connection->ExecuteSimpleSQL(nsPrintfCString({ auto tryResult3061 = (ToResult(connection->ExecuteSimpleSQL
(nsPrintfCString( "PRAGMA page_size = %" "u" ";", sqlitePageSizeOverride
)))); static_assert(std::is_empty_v<typename decltype(tryResult3061
)::ok_type>); if ((__builtin_expect(!!(tryResult3061.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(connection->ExecuteSimpleSQL(nsPrintfCString( \"PRAGMA page_size = %\" \"u\" \";\", sqlitePageSizeOverride)))"
, tryResult3061.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 885, mozilla::dom::quota::Severity::Error); return tryResult3061
.propagateErr(); } }
885 "PRAGMA page_size = %" PRIu32 ";", sqlitePageSizeOverride)))){ auto tryResult3061 = (ToResult(connection->ExecuteSimpleSQL
(nsPrintfCString( "PRAGMA page_size = %" "u" ";", sqlitePageSizeOverride
)))); static_assert(std::is_empty_v<typename decltype(tryResult3061
)::ok_type>); if ((__builtin_expect(!!(tryResult3061.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(connection->ExecuteSimpleSQL(nsPrintfCString( \"PRAGMA page_size = %\" \"u\" \";\", sqlitePageSizeOverride)))"
, tryResult3061.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 885, mozilla::dom::quota::Severity::Error); return tryResult3061
.propagateErr(); } }
;
886 }
887
888 // We have to set the auto_vacuum mode before opening a transaction.
889 QM_TRY((MOZ_TO_RESULT_INVOKE_MEMBER({ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
890 connection, ExecuteSimpleSQL,{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
891#ifdef IDB_MOBILE{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
892 // Turn on full auto_vacuum mode to reclaim disk space on{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
893 // mobile devices (at the cost of some COMMIT speed).{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
894 "PRAGMA auto_vacuum = FULL;"_ns{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
895#else{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
896 // Turn on incremental auto_vacuum mode on desktop builds.{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
897 "PRAGMA auto_vacuum = INCREMENTAL;"_ns{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
898#endif{ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
899 ){ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
900 .mapErr(mapNoDeviceSpaceError))){ auto tryResult3062 = ((::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::ExecuteSimpleSQL,ifdef IDB_MOBILE "PRAGMA auto_vacuum = FULL;"_ns
else "PRAGMA auto_vacuum = INCREMENTAL;"_ns endif) .mapErr(mapNoDeviceSpaceError
))); static_assert(std::is_empty_v<typename decltype(tryResult3062
)::ok_type>); if ((__builtin_expect(!!(tryResult3062.isErr
()), 0))) { mozilla::dom::quota::HandleError("(::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::ExecuteSimpleSQL,ifdef IDB_MOBILE \"PRAGMA auto_vacuum = FULL;\"_nselse \"PRAGMA auto_vacuum = INCREMENTAL;\"_nsendif) .mapErr(mapNoDeviceSpaceError))"
, tryResult3062.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 900, mozilla::dom::quota::Severity::Error); return tryResult3062
.propagateErr(); } }
;
901
902 QM_TRY(MOZ_TO_RESULT(SetJournalMode(*connection))){ auto tryResult3063 = (ToResult(SetJournalMode(*connection))
); static_assert(std::is_empty_v<typename decltype(tryResult3063
)::ok_type>); if ((__builtin_expect(!!(tryResult3063.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(SetJournalMode(*connection))"
, tryResult3063.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 902, mozilla::dom::quota::Severity::Error); return tryResult3063
.propagateErr(); } }
;
903
904 journalModeSet = true;
905 } else {
906#ifdef DEBUG1
907 // Disable foreign key support while upgrading. This has to be done before
908 // starting a transaction.
909 MOZ_ALWAYS_SUCCEEDS(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(connection->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns
))), 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(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 910); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")"); do { *((volatile int*)__null) = 910; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
910 connection->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(connection->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns
))), 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(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 910); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")"); do { *((volatile int*)__null) = 910; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
911#endif
912 }
913
914 bool vacuumNeeded = false;
915
916 mozStorageTransaction transaction(
917 connection.get(), false, mozIStorageConnection::TRANSACTION_IMMEDIATE);
918
919 QM_TRY(MOZ_TO_RESULT(transaction.Start())){ auto tryResult3064 = (ToResult(transaction.Start())); static_assert
(std::is_empty_v<typename decltype(tryResult3064)::ok_type
>); if ((__builtin_expect(!!(tryResult3064.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(transaction.Start())"
, tryResult3064.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 919, mozilla::dom::quota::Severity::Error); return tryResult3064
.propagateErr(); } }
;
920
921 if (newDatabase) {
922 QM_TRY(MOZ_TO_RESULT(CreateTables(*connection))){ auto tryResult3065 = (ToResult(CreateTables(*connection)));
static_assert(std::is_empty_v<typename decltype(tryResult3065
)::ok_type>); if ((__builtin_expect(!!(tryResult3065.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(CreateTables(*connection))"
, tryResult3065.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 922, mozilla::dom::quota::Severity::Error); return tryResult3065
.propagateErr(); } }
;
923
924#ifdef DEBUG1
925 {
926 QM_TRY_INSPECT(auto tryResult3066 = (::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::GetSchemaVersion)); if ((__builtin_expect(!!(tryResult3066
.isErr()), 0))) { auto tryTempError __attribute__((__unused__
)) = tryResult3066.unwrapErr(); mozilla::dom::quota::HandleError
("::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 929; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const int32_t
& schemaVersion = tryResult3066.inspect();
927 const int32_t& schemaVersion,auto tryResult3066 = (::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::GetSchemaVersion)); if ((__builtin_expect(!!(tryResult3066
.isErr()), 0))) { auto tryTempError __attribute__((__unused__
)) = tryResult3066.unwrapErr(); mozilla::dom::quota::HandleError
("::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 929; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const int32_t
& schemaVersion = tryResult3066.inspect();
928 MOZ_TO_RESULT_INVOKE_MEMBER(connection, GetSchemaVersion),auto tryResult3066 = (::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::GetSchemaVersion)); if ((__builtin_expect(!!(tryResult3066
.isErr()), 0))) { auto tryTempError __attribute__((__unused__
)) = tryResult3066.unwrapErr(); mozilla::dom::quota::HandleError
("::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 929; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const int32_t
& schemaVersion = tryResult3066.inspect();
929 QM_ASSERT_UNREACHABLE)auto tryResult3066 = (::mozilla::ToResultInvokeMember( (connection
), &::mozilla::detail::DerefedType<decltype(connection
)>::GetSchemaVersion)); if ((__builtin_expect(!!(tryResult3066
.isErr()), 0))) { auto tryTempError __attribute__((__unused__
)) = tryResult3066.unwrapErr(); mozilla::dom::quota::HandleError
("::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "::mozilla::ToResultInvokeMember( (connection), &::mozilla::detail::DerefedType<decltype(connection)>::GetSchemaVersion)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 929); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 929; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const int32_t
& schemaVersion = tryResult3066.inspect();
;
930 MOZ_ASSERT(schemaVersion == kSQLiteSchemaVersion)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(schemaVersion == kSQLiteSchemaVersion)>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(schemaVersion == kSQLiteSchemaVersion))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("schemaVersion == kSQLiteSchemaVersion"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 930); AnnotateMozCrashReason("MOZ_ASSERT" "(" "schemaVersion == kSQLiteSchemaVersion"
")"); do { *((volatile int*)__null) = 930; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
931 }
932#endif
933
934 // The parameter names are not used, parameters are bound by index only
935 // locally in the same function.
936 QM_TRY_INSPECT(auto tryResult3067 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "INSERT INTO database (name, origin) " "VALUES (:name, :origin)"_ns
)); if ((__builtin_expect(!!(tryResult3067.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"INSERT INTO database (name, origin) \" \"VALUES (:name, :origin)\"_ns)"
, tryResult3067.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 941, mozilla::dom::quota::Severity::Error); return tryResult3067
.propagateErr(); } const auto& stmt = tryResult3067.inspect
();
937 const auto& stmt,auto tryResult3067 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "INSERT INTO database (name, origin) " "VALUES (:name, :origin)"_ns
)); if ((__builtin_expect(!!(tryResult3067.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"INSERT INTO database (name, origin) \" \"VALUES (:name, :origin)\"_ns)"
, tryResult3067.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 941, mozilla::dom::quota::Severity::Error); return tryResult3067
.propagateErr(); } const auto& stmt = tryResult3067.inspect
();
938 MOZ_TO_RESULT_INVOKE_MEMBER_TYPED(auto tryResult3067 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "INSERT INTO database (name, origin) " "VALUES (:name, :origin)"_ns
)); if ((__builtin_expect(!!(tryResult3067.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"INSERT INTO database (name, origin) \" \"VALUES (:name, :origin)\"_ns)"
, tryResult3067.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 941, mozilla::dom::quota::Severity::Error); return tryResult3067
.propagateErr(); } const auto& stmt = tryResult3067.inspect
();
939 nsCOMPtr<mozIStorageStatement>, connection, CreateStatement,auto tryResult3067 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "INSERT INTO database (name, origin) " "VALUES (:name, :origin)"_ns
)); if ((__builtin_expect(!!(tryResult3067.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"INSERT INTO database (name, origin) \" \"VALUES (:name, :origin)\"_ns)"
, tryResult3067.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 941, mozilla::dom::quota::Severity::Error); return tryResult3067
.propagateErr(); } const auto& stmt = tryResult3067.inspect
();
940 "INSERT INTO database (name, origin) "auto tryResult3067 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "INSERT INTO database (name, origin) " "VALUES (:name, :origin)"_ns
)); if ((__builtin_expect(!!(tryResult3067.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"INSERT INTO database (name, origin) \" \"VALUES (:name, :origin)\"_ns)"
, tryResult3067.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 941, mozilla::dom::quota::Severity::Error); return tryResult3067
.propagateErr(); } const auto& stmt = tryResult3067.inspect
();
941 "VALUES (:name, :origin)"_ns))auto tryResult3067 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "INSERT INTO database (name, origin) " "VALUES (:name, :origin)"_ns
)); if ((__builtin_expect(!!(tryResult3067.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"INSERT INTO database (name, origin) \" \"VALUES (:name, :origin)\"_ns)"
, tryResult3067.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 941, mozilla::dom::quota::Severity::Error); return tryResult3067
.propagateErr(); } const auto& stmt = tryResult3067.inspect
();
;
942
943 QM_TRY(MOZ_TO_RESULT(stmt->BindStringByIndex(0, aName))){ auto tryResult3068 = (ToResult(stmt->BindStringByIndex(0
, aName))); static_assert(std::is_empty_v<typename decltype
(tryResult3068)::ok_type>); if ((__builtin_expect(!!(tryResult3068
.isErr()), 0))) { mozilla::dom::quota::HandleError("ToResult(stmt->BindStringByIndex(0, aName))"
, tryResult3068.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 943, mozilla::dom::quota::Severity::Error); return tryResult3068
.propagateErr(); } }
;
944 QM_TRY(MOZ_TO_RESULT(stmt->BindUTF8StringByIndex(1, aOrigin))){ auto tryResult3069 = (ToResult(stmt->BindUTF8StringByIndex
(1, aOrigin))); static_assert(std::is_empty_v<typename decltype
(tryResult3069)::ok_type>); if ((__builtin_expect(!!(tryResult3069
.isErr()), 0))) { mozilla::dom::quota::HandleError("ToResult(stmt->BindUTF8StringByIndex(1, aOrigin))"
, tryResult3069.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 944, mozilla::dom::quota::Severity::Error); return tryResult3069
.propagateErr(); } }
;
945 QM_TRY(MOZ_TO_RESULT(stmt->Execute())){ auto tryResult3070 = (ToResult(stmt->Execute())); static_assert
(std::is_empty_v<typename decltype(tryResult3070)::ok_type
>); if ((__builtin_expect(!!(tryResult3070.isErr()), 0))) {
mozilla::dom::quota::HandleError("ToResult(stmt->Execute())"
, tryResult3070.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 945, mozilla::dom::quota::Severity::Error); return tryResult3070
.propagateErr(); } }
;
946 } else {
947 QM_TRY_UNWRAP(vacuumNeeded, MaybeUpgradeSchema(*connection, schemaVersion,auto tryResult3071 = (MaybeUpgradeSchema(*connection, schemaVersion
, aFMDirectory, aOrigin)); if ((__builtin_expect(!!(tryResult3071
.isErr()), 0))) { mozilla::dom::quota::HandleError("MaybeUpgradeSchema(*connection, schemaVersion, aFMDirectory, aOrigin)"
, tryResult3071.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 948, mozilla::dom::quota::Severity::Error); return tryResult3071
.propagateErr(); } vacuumNeeded = tryResult3071.unwrap();
948 aFMDirectory, aOrigin))auto tryResult3071 = (MaybeUpgradeSchema(*connection, schemaVersion
, aFMDirectory, aOrigin)); if ((__builtin_expect(!!(tryResult3071
.isErr()), 0))) { mozilla::dom::quota::HandleError("MaybeUpgradeSchema(*connection, schemaVersion, aFMDirectory, aOrigin)"
, tryResult3071.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 948, mozilla::dom::quota::Severity::Error); return tryResult3071
.propagateErr(); } vacuumNeeded = tryResult3071.unwrap();
;
949 }
950
951 QM_TRY(MOZ_TO_RESULT_INVOKE_MEMBER(transaction, Commit){ auto tryResult3072 = (::mozilla::ToResultInvokeMember( (transaction
), &::mozilla::detail::DerefedType<decltype(transaction
)>::Commit) .mapErr(mapNoDeviceSpaceError)); static_assert
(std::is_empty_v<typename decltype(tryResult3072)::ok_type
>); if ((__builtin_expect(!!(tryResult3072.isErr()), 0))) {
mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (transaction), &::mozilla::detail::DerefedType<decltype(transaction)>::Commit) .mapErr(mapNoDeviceSpaceError)"
, tryResult3072.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 952, mozilla::dom::quota::Severity::Error); return tryResult3072
.propagateErr(); } }
952 .mapErr(mapNoDeviceSpaceError)){ auto tryResult3072 = (::mozilla::ToResultInvokeMember( (transaction
), &::mozilla::detail::DerefedType<decltype(transaction
)>::Commit) .mapErr(mapNoDeviceSpaceError)); static_assert
(std::is_empty_v<typename decltype(tryResult3072)::ok_type
>); if ((__builtin_expect(!!(tryResult3072.isErr()), 0))) {
mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (transaction), &::mozilla::detail::DerefedType<decltype(transaction)>::Commit) .mapErr(mapNoDeviceSpaceError)"
, tryResult3072.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 952, mozilla::dom::quota::Severity::Error); return tryResult3072
.propagateErr(); } }
;
953
954#ifdef DEBUG1
955 if (!newDatabase) {
956 // Re-enable foreign key support after doing a foreign key check.
957 QM_TRY_INSPECT(const bool& foreignKeyError,auto tryResult3073 = (CreateAndExecuteSingleStepStatement<
SingleStepResult::ReturnNullIfNoResult>( *connection, "PRAGMA foreign_key_check;"_ns
)); if ((__builtin_expect(!!(tryResult3073.isErr()), 0))) { auto
tryTempError __attribute__((__unused__)) = tryResult3073.unwrapErr
(); mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 961; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const bool
& foreignKeyError = tryResult3073.inspect();
958 CreateAndExecuteSingleStepStatement<auto tryResult3073 = (CreateAndExecuteSingleStepStatement<
SingleStepResult::ReturnNullIfNoResult>( *connection, "PRAGMA foreign_key_check;"_ns
)); if ((__builtin_expect(!!(tryResult3073.isErr()), 0))) { auto
tryTempError __attribute__((__unused__)) = tryResult3073.unwrapErr
(); mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 961; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const bool
& foreignKeyError = tryResult3073.inspect();
959 SingleStepResult::ReturnNullIfNoResult>(auto tryResult3073 = (CreateAndExecuteSingleStepStatement<
SingleStepResult::ReturnNullIfNoResult>( *connection, "PRAGMA foreign_key_check;"_ns
)); if ((__builtin_expect(!!(tryResult3073.isErr()), 0))) { auto
tryTempError __attribute__((__unused__)) = tryResult3073.unwrapErr
(); mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 961; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const bool
& foreignKeyError = tryResult3073.inspect();
960 *connection, "PRAGMA foreign_key_check;"_ns),auto tryResult3073 = (CreateAndExecuteSingleStepStatement<
SingleStepResult::ReturnNullIfNoResult>( *connection, "PRAGMA foreign_key_check;"_ns
)); if ((__builtin_expect(!!(tryResult3073.isErr()), 0))) { auto
tryTempError __attribute__((__unused__)) = tryResult3073.unwrapErr
(); mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 961; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const bool
& foreignKeyError = tryResult3073.inspect();
961 QM_ASSERT_UNREACHABLE)auto tryResult3073 = (CreateAndExecuteSingleStepStatement<
SingleStepResult::ReturnNullIfNoResult>( *connection, "PRAGMA foreign_key_check;"_ns
)); if ((__builtin_expect(!!(tryResult3073.isErr()), 0))) { auto
tryTempError __attribute__((__unused__)) = tryResult3073.unwrapErr
(); mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "CreateAndExecuteSingleStepStatement< SingleStepResult::ReturnNullIfNoResult>( *connection, \"PRAGMA foreign_key_check;\"_ns)"
, tryTempError, [](const char*, const char*) -> ::mozilla::
GenericErrorResult<nsresult> { do { do { } while (false
); MOZ_ReportCrash("" "Should never be reached.", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 961); AnnotateMozCrashReason("MOZ_CRASH(" "Should never be reached."
")"); do { *((volatile int*)__null) = 961; __attribute__((nomerge
)) ::abort(); } while (false); } while (false); }); } const bool
& foreignKeyError = tryResult3073.inspect();
;
962
963 MOZ_ASSERT(!foreignKeyError, "Database has inconsisistent foreign keys!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!foreignKeyError)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!foreignKeyError))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!foreignKeyError"
" (" "Database has inconsisistent foreign keys!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 963); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!foreignKeyError"
") (" "Database has inconsisistent foreign keys!" ")"); do {
*((volatile int*)__null) = 963; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
;
964
965 MOZ_ALWAYS_SUCCEEDS(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(connection->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns
))), 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(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 966); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")"); do { *((volatile int*)__null) = 966; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
966 connection->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(connection->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns
))), 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(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 966); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(connection->ExecuteSimpleSQL(\"PRAGMA foreign_keys = OFF;\"_ns))"
")"); do { *((volatile int*)__null) = 966; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
967 }
968#endif
969
970 if (kSQLitePageSizeOverride && !newDatabase) {
971 QM_TRY_INSPECT(const auto& stmt,auto tryResult3074 = (CreateAndExecuteSingleStepStatement( *connection
, "PRAGMA page_size;"_ns)); if ((__builtin_expect(!!(tryResult3074
.isErr()), 0))) { mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement( *connection, \"PRAGMA page_size;\"_ns)"
, tryResult3074.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 973, mozilla::dom::quota::Severity::Error); return tryResult3074
.propagateErr(); } const auto& stmt = tryResult3074.inspect
();
972 CreateAndExecuteSingleStepStatement(auto tryResult3074 = (CreateAndExecuteSingleStepStatement( *connection
, "PRAGMA page_size;"_ns)); if ((__builtin_expect(!!(tryResult3074
.isErr()), 0))) { mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement( *connection, \"PRAGMA page_size;\"_ns)"
, tryResult3074.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 973, mozilla::dom::quota::Severity::Error); return tryResult3074
.propagateErr(); } const auto& stmt = tryResult3074.inspect
();
973 *connection, "PRAGMA page_size;"_ns))auto tryResult3074 = (CreateAndExecuteSingleStepStatement( *connection
, "PRAGMA page_size;"_ns)); if ((__builtin_expect(!!(tryResult3074
.isErr()), 0))) { mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement( *connection, \"PRAGMA page_size;\"_ns)"
, tryResult3074.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 973, mozilla::dom::quota::Severity::Error); return tryResult3074
.propagateErr(); } const auto& stmt = tryResult3074.inspect
();
;
974
975 QM_TRY_INSPECT(const int32_t& pageSize,auto tryResult3075 = (::mozilla::ToResultInvokeMember( (*stmt
), &::mozilla::detail::DerefedType<decltype(*stmt)>
::GetInt32, 0)); if ((__builtin_expect(!!(tryResult3075.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (*stmt), &::mozilla::detail::DerefedType<decltype(*stmt)>::GetInt32, 0)"
, tryResult3075.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 976, mozilla::dom::quota::Severity::Error); return tryResult3075
.propagateErr(); } const int32_t& pageSize = tryResult3075
.inspect();
976 MOZ_TO_RESULT_INVOKE_MEMBER(*stmt, GetInt32, 0))auto tryResult3075 = (::mozilla::ToResultInvokeMember( (*stmt
), &::mozilla::detail::DerefedType<decltype(*stmt)>
::GetInt32, 0)); if ((__builtin_expect(!!(tryResult3075.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (*stmt), &::mozilla::detail::DerefedType<decltype(*stmt)>::GetInt32, 0)"
, tryResult3075.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 976, mozilla::dom::quota::Severity::Error); return tryResult3075
.propagateErr(); } const int32_t& pageSize = tryResult3075
.inspect();
;
977 MOZ_ASSERT(pageSize >= 512 && pageSize <= 65536)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pageSize >= 512 && pageSize <= 65536)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(pageSize >= 512 && pageSize <= 65536))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("pageSize >= 512 && pageSize <= 65536"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 977); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pageSize >= 512 && pageSize <= 65536"
")"); do { *((volatile int*)__null) = 977; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
978
979 if (kSQLitePageSizeOverride != uint32_t(pageSize)) {
980 // We must not be in WAL journal mode to change the page size.
981 QM_TRY(MOZ_TO_RESULT({ auto tryResult3076 = (ToResult(connection->ExecuteSimpleSQL
("PRAGMA journal_mode = DELETE;"_ns))); static_assert(std::is_empty_v
<typename decltype(tryResult3076)::ok_type>); if ((__builtin_expect
(!!(tryResult3076.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(connection->ExecuteSimpleSQL(\"PRAGMA journal_mode = DELETE;\"_ns))"
, tryResult3076.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 982, mozilla::dom::quota::Severity::Error); return tryResult3076
.propagateErr(); } }
982 connection->ExecuteSimpleSQL("PRAGMA journal_mode = DELETE;"_ns))){ auto tryResult3076 = (ToResult(connection->ExecuteSimpleSQL
("PRAGMA journal_mode = DELETE;"_ns))); static_assert(std::is_empty_v
<typename decltype(tryResult3076)::ok_type>); if ((__builtin_expect
(!!(tryResult3076.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(connection->ExecuteSimpleSQL(\"PRAGMA journal_mode = DELETE;\"_ns))"
, tryResult3076.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 982, mozilla::dom::quota::Severity::Error); return tryResult3076
.propagateErr(); } }
;
983
984 QM_TRY_INSPECT(const auto& stmt,auto tryResult3077 = (CreateAndExecuteSingleStepStatement( *connection
, "PRAGMA journal_mode;"_ns)); if ((__builtin_expect(!!(tryResult3077
.isErr()), 0))) { mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement( *connection, \"PRAGMA journal_mode;\"_ns)"
, tryResult3077.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 986, mozilla::dom::quota::Severity::Error); return tryResult3077
.propagateErr(); } const auto& stmt = tryResult3077.inspect
();
985 CreateAndExecuteSingleStepStatement(auto tryResult3077 = (CreateAndExecuteSingleStepStatement( *connection
, "PRAGMA journal_mode;"_ns)); if ((__builtin_expect(!!(tryResult3077
.isErr()), 0))) { mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement( *connection, \"PRAGMA journal_mode;\"_ns)"
, tryResult3077.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 986, mozilla::dom::quota::Severity::Error); return tryResult3077
.propagateErr(); } const auto& stmt = tryResult3077.inspect
();
986 *connection, "PRAGMA journal_mode;"_ns))auto tryResult3077 = (CreateAndExecuteSingleStepStatement( *connection
, "PRAGMA journal_mode;"_ns)); if ((__builtin_expect(!!(tryResult3077
.isErr()), 0))) { mozilla::dom::quota::HandleError("CreateAndExecuteSingleStepStatement( *connection, \"PRAGMA journal_mode;\"_ns)"
, tryResult3077.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 986, mozilla::dom::quota::Severity::Error); return tryResult3077
.propagateErr(); } const auto& stmt = tryResult3077.inspect
();
;
987
988 QM_TRY_INSPECT(const auto& journalMode,auto tryResult3078 = (::mozilla::ToResultInvoke< nsCString
>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype
(*stmt)>::GetUTF8String), (*stmt), 0)); if ((__builtin_expect
(!!(tryResult3078.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCString>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(*stmt)>::GetUTF8String), (*stmt), 0)"
, tryResult3078.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 990, mozilla::dom::quota::Severity::Error); return tryResult3078
.propagateErr(); } const auto& journalMode = tryResult3078
.inspect();
989 MOZ_TO_RESULT_INVOKE_MEMBER_TYPED(nsCString, *stmt,auto tryResult3078 = (::mozilla::ToResultInvoke< nsCString
>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype
(*stmt)>::GetUTF8String), (*stmt), 0)); if ((__builtin_expect
(!!(tryResult3078.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCString>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(*stmt)>::GetUTF8String), (*stmt), 0)"
, tryResult3078.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 990, mozilla::dom::quota::Severity::Error); return tryResult3078
.propagateErr(); } const auto& journalMode = tryResult3078
.inspect();
990 GetUTF8String, 0))auto tryResult3078 = (::mozilla::ToResultInvoke< nsCString
>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype
(*stmt)>::GetUTF8String), (*stmt), 0)); if ((__builtin_expect
(!!(tryResult3078.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCString>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(*stmt)>::GetUTF8String), (*stmt), 0)"
, tryResult3078.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 990, mozilla::dom::quota::Severity::Error); return tryResult3078
.propagateErr(); } const auto& journalMode = tryResult3078
.inspect();
;
991
992 if (journalMode.EqualsLiteral("delete")) {
993 // Successfully set to rollback journal mode so changing the page size
994 // is possible with a VACUUM.
995 QM_TRY(MOZ_TO_RESULT(connection->ExecuteSimpleSQL(nsPrintfCString({ auto tryResult3079 = (ToResult(connection->ExecuteSimpleSQL
(nsPrintfCString( "PRAGMA page_size = %" "u" ";", kSQLitePageSizeOverride
)))); static_assert(std::is_empty_v<typename decltype(tryResult3079
)::ok_type>); if ((__builtin_expect(!!(tryResult3079.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(connection->ExecuteSimpleSQL(nsPrintfCString( \"PRAGMA page_size = %\" \"u\" \";\", kSQLitePageSizeOverride)))"
, tryResult3079.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 996, mozilla::dom::quota::Severity::Error); return tryResult3079
.propagateErr(); } }
996 "PRAGMA page_size = %" PRIu32 ";", kSQLitePageSizeOverride)))){ auto tryResult3079 = (ToResult(connection->ExecuteSimpleSQL
(nsPrintfCString( "PRAGMA page_size = %" "u" ";", kSQLitePageSizeOverride
)))); static_assert(std::is_empty_v<typename decltype(tryResult3079
)::ok_type>); if ((__builtin_expect(!!(tryResult3079.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(connection->ExecuteSimpleSQL(nsPrintfCString( \"PRAGMA page_size = %\" \"u\" \";\", kSQLitePageSizeOverride)))"
, tryResult3079.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 996, mozilla::dom::quota::Severity::Error); return tryResult3079
.propagateErr(); } }
;
997
998 // We will need to VACUUM in order to change the page size.
999 vacuumNeeded = true;
1000 } else {
1001 NS_WARNING(NS_DebugBreak(NS_DEBUG_WARNING, "Failed to set journal_mode for database, unable to "
"change the page size!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1003)
1002 "Failed to set journal_mode for database, unable to "NS_DebugBreak(NS_DEBUG_WARNING, "Failed to set journal_mode for database, unable to "
"change the page size!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1003)
1003 "change the page size!")NS_DebugBreak(NS_DEBUG_WARNING, "Failed to set journal_mode for database, unable to "
"change the page size!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1003)
;
1004 }
1005 }
1006 }
1007
1008 if (vacuumNeeded) {
1009 QM_TRY(MOZ_TO_RESULT(connection->ExecuteSimpleSQL("VACUUM;"_ns))){ auto tryResult3080 = (ToResult(connection->ExecuteSimpleSQL
("VACUUM;"_ns))); static_assert(std::is_empty_v<typename decltype
(tryResult3080)::ok_type>); if ((__builtin_expect(!!(tryResult3080
.isErr()), 0))) { mozilla::dom::quota::HandleError("ToResult(connection->ExecuteSimpleSQL(\"VACUUM;\"_ns))"
, tryResult3080.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1009, mozilla::dom::quota::Severity::Error); return tryResult3080
.propagateErr(); } }
;
1010 }
1011
1012 if (newDatabase || vacuumNeeded) {
1013 if (journalModeSet) {
1014 // Make sure we checkpoint to get an accurate file size.
1015 QM_TRY(MOZ_TO_RESULT({ auto tryResult3081 = (ToResult(connection->ExecuteSimpleSQL
("PRAGMA wal_checkpoint(FULL);"_ns))); static_assert(std::is_empty_v
<typename decltype(tryResult3081)::ok_type>); if ((__builtin_expect
(!!(tryResult3081.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(connection->ExecuteSimpleSQL(\"PRAGMA wal_checkpoint(FULL);\"_ns))"
, tryResult3081.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1016, mozilla::dom::quota::Severity::Error); return tryResult3081
.propagateErr(); } }
1016 connection->ExecuteSimpleSQL("PRAGMA wal_checkpoint(FULL);"_ns))){ auto tryResult3081 = (ToResult(connection->ExecuteSimpleSQL
("PRAGMA wal_checkpoint(FULL);"_ns))); static_assert(std::is_empty_v
<typename decltype(tryResult3081)::ok_type>); if ((__builtin_expect
(!!(tryResult3081.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(connection->ExecuteSimpleSQL(\"PRAGMA wal_checkpoint(FULL);\"_ns))"
, tryResult3081.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1016, mozilla::dom::quota::Severity::Error); return tryResult3081
.propagateErr(); } }
;
1017 }
1018
1019 QM_TRY_INSPECT(const int64_t& fileSize,auto tryResult3082 = (::mozilla::ToResultInvokeMember( (aDBFile
), &::mozilla::detail::DerefedType<decltype(aDBFile)>
::GetFileSize)); if ((__builtin_expect(!!(tryResult3082.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDBFile), &::mozilla::detail::DerefedType<decltype(aDBFile)>::GetFileSize)"
, tryResult3082.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1020, mozilla::dom::quota::Severity::Error); return tryResult3082
.propagateErr(); } const int64_t& fileSize = tryResult3082
.inspect();
1020 MOZ_TO_RESULT_INVOKE_MEMBER(aDBFile, GetFileSize))auto tryResult3082 = (::mozilla::ToResultInvokeMember( (aDBFile
), &::mozilla::detail::DerefedType<decltype(aDBFile)>
::GetFileSize)); if ((__builtin_expect(!!(tryResult3082.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDBFile), &::mozilla::detail::DerefedType<decltype(aDBFile)>::GetFileSize)"
, tryResult3082.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1020, mozilla::dom::quota::Severity::Error); return tryResult3082
.propagateErr(); } const int64_t& fileSize = tryResult3082
.inspect();
;
1021 MOZ_ASSERT(fileSize > 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(fileSize > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(fileSize > 0))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("fileSize > 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1021); AnnotateMozCrashReason("MOZ_ASSERT" "(" "fileSize > 0"
")"); do { *((volatile int*)__null) = 1021; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1022
1023 PRTime vacuumTime = PR_Now();
1024 MOZ_ASSERT(vacuumTime)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(vacuumTime)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(vacuumTime))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("vacuumTime", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1024); AnnotateMozCrashReason("MOZ_ASSERT" "(" "vacuumTime"
")"); do { *((volatile int*)__null) = 1024; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1025
1026 // The parameter names are not used, parameters are bound by index only
1027 // locally in the same function.
1028 QM_TRY_INSPECT(auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
1029 const auto& vacuumTimeStmt,auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
1030 MOZ_TO_RESULT_INVOKE_MEMBER_TYPED(nsCOMPtr<mozIStorageStatement>,auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
1031 connection, CreateStatement,auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
1032 "UPDATE database "auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
1033 "SET last_vacuum_time = :time"auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
1034 ", last_vacuum_size = :size;"_ns))auto tryResult3083 = (::mozilla::ToResultInvoke< nsCOMPtr<
mozIStorageStatement> >( ::std::mem_fn( &::mozilla::
detail::DerefedType<decltype(connection)>::CreateStatement
), (connection), "UPDATE database " "SET last_vacuum_time = :time"
", last_vacuum_size = :size;"_ns)); if ((__builtin_expect(!!
(tryResult3083.isErr()), 0))) { mozilla::dom::quota::HandleError
("::mozilla::ToResultInvoke< nsCOMPtr<mozIStorageStatement>>( ::std::mem_fn( &::mozilla::detail::DerefedType<decltype(connection)>::CreateStatement), (connection), \"UPDATE database \" \"SET last_vacuum_time = :time\" \", last_vacuum_size = :size;\"_ns)"
, tryResult3083.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1034, mozilla::dom::quota::Severity::Error); return tryResult3083
.propagateErr(); } const auto& vacuumTimeStmt = tryResult3083
.inspect();
;
1035
1036 QM_TRY(MOZ_TO_RESULT(vacuumTimeStmt->BindInt64ByIndex(0, vacuumTime))){ auto tryResult3084 = (ToResult(vacuumTimeStmt->BindInt64ByIndex
(0, vacuumTime))); static_assert(std::is_empty_v<typename decltype
(tryResult3084)::ok_type>); if ((__builtin_expect(!!(tryResult3084
.isErr()), 0))) { mozilla::dom::quota::HandleError("ToResult(vacuumTimeStmt->BindInt64ByIndex(0, vacuumTime))"
, tryResult3084.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1036, mozilla::dom::quota::Severity::Error); return tryResult3084
.propagateErr(); } }
;
1037 QM_TRY(MOZ_TO_RESULT(vacuumTimeStmt->BindInt64ByIndex(1, fileSize))){ auto tryResult3085 = (ToResult(vacuumTimeStmt->BindInt64ByIndex
(1, fileSize))); static_assert(std::is_empty_v<typename decltype
(tryResult3085)::ok_type>); if ((__builtin_expect(!!(tryResult3085
.isErr()), 0))) { mozilla::dom::quota::HandleError("ToResult(vacuumTimeStmt->BindInt64ByIndex(1, fileSize))"
, tryResult3085.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1037, mozilla::dom::quota::Severity::Error); return tryResult3085
.propagateErr(); } }
;
1038 QM_TRY(MOZ_TO_RESULT(vacuumTimeStmt->Execute())){ auto tryResult3086 = (ToResult(vacuumTimeStmt->Execute()
)); static_assert(std::is_empty_v<typename decltype(tryResult3086
)::ok_type>); if ((__builtin_expect(!!(tryResult3086.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(vacuumTimeStmt->Execute())"
, tryResult3086.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1038, mozilla::dom::quota::Severity::Error); return tryResult3086
.propagateErr(); } }
;
1039 }
1040 }
1041
1042 if (!journalModeSet) {
1043 QM_TRY(MOZ_TO_RESULT(SetJournalMode(*connection))){ auto tryResult3087 = (ToResult(SetJournalMode(*connection))
); static_assert(std::is_empty_v<typename decltype(tryResult3087
)::ok_type>); if ((__builtin_expect(!!(tryResult3087.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(SetJournalMode(*connection))"
, tryResult3087.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1043, mozilla::dom::quota::Severity::Error); return tryResult3087
.propagateErr(); } }
;
1044 }
1045
1046 return WrapMovingNotNullUnchecked(std::move(connection));
1047}
1048
1049nsCOMPtr<nsIFile> GetFileForPath(const nsAString& aPath) {
1050 MOZ_ASSERT(!aPath.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!aPath.IsEmpty())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!aPath.IsEmpty()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!aPath.IsEmpty()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1050); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aPath.IsEmpty()"
")"); do { *((volatile int*)__null) = 1050; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1051
1052 QM_TRY_RETURN(QM_NewLocalFile(aPath), nullptr){ auto tryResult3088 = (QM_NewLocalFile(aPath)); if ((__builtin_expect
(!!(tryResult3088.isErr()), 0))) { auto tryTempError __attribute__
((__unused__)) = tryResult3088.unwrapErr(); mozilla::dom::quota
::HandleError("QM_NewLocalFile(aPath)", tryResult3088.inspectErr
(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1052, mozilla::dom::quota::Severity::Error); constexpr const
auto& func __attribute__((__unused__)) = __func__; return
mozilla::dom::quota::HandleCustomRetVal(func, "QM_NewLocalFile(aPath)"
, tryTempError, nullptr); } return tryResult3088.unwrap(); }
;
1053}
1054
1055Result<MovingNotNull<nsCOMPtr<mozIStorageConnection>>, nsresult>
1056GetStorageConnection(nsIFile& aDatabaseFile, const int64_t aDirectoryLockId,
1057 const uint32_t aTelemetryId,
1058 const Maybe<CipherKey>& aMaybeKey) {
1059 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/indexedDB/ActorsParent.cpp"
, 1059); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()"
")"); do { *((volatile int*)__null) = 1059; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1060 MOZ_ASSERT(!IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1060); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 1060; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1061 MOZ_ASSERT(aDirectoryLockId >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aDirectoryLockId >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aDirectoryLockId >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("aDirectoryLockId >= 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1061); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDirectoryLockId >= 0"
")"); do { *((volatile int*)__null) = 1061; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1062
1063 AUTO_PROFILER_LABEL("GetStorageConnection", DOM)mozilla::AutoProfilerLabel raiiObject1063( "GetStorageConnection"
, nullptr, JS::ProfilingCategoryPair::DOM)
;
1064
1065 QM_TRY_INSPECT(const bool& exists,auto tryResult3089 = (::mozilla::ToResultInvokeMember( (aDatabaseFile
), &::mozilla::detail::DerefedType<decltype(aDatabaseFile
)>::Exists)); if ((__builtin_expect(!!(tryResult3089.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDatabaseFile), &::mozilla::detail::DerefedType<decltype(aDatabaseFile)>::Exists)"
, tryResult3089.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1066, mozilla::dom::quota::Severity::Error); return tryResult3089
.propagateErr(); } const bool& exists = tryResult3089.inspect
();
1066 MOZ_TO_RESULT_INVOKE_MEMBER(aDatabaseFile, Exists))auto tryResult3089 = (::mozilla::ToResultInvokeMember( (aDatabaseFile
), &::mozilla::detail::DerefedType<decltype(aDatabaseFile
)>::Exists)); if ((__builtin_expect(!!(tryResult3089.isErr
()), 0))) { mozilla::dom::quota::HandleError("::mozilla::ToResultInvokeMember( (aDatabaseFile), &::mozilla::detail::DerefedType<decltype(aDatabaseFile)>::Exists)"
, tryResult3089.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1066, mozilla::dom::quota::Severity::Error); return tryResult3089
.propagateErr(); } const bool& exists = tryResult3089.inspect
();
;
1067
1068 QM_TRY(OkIf(exists), Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR),{ auto tryResult3090 = (OkIf(exists)); static_assert(std::is_empty_v
<typename decltype(tryResult3090)::ok_type>); if ((__builtin_expect
(!!(tryResult3090.isErr()), 0))) { auto tryTempError = tryResult3090
.unwrapErr(); mozilla::dom::quota::HandleError("OkIf(exists)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1069, mozilla::dom::quota::Severity::Error); [](const auto&
) { mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1069, "UnknownErr"); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(exists)", tryTempError
, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
1069 IDB_REPORT_INTERNAL_ERR_LAMBDA){ auto tryResult3090 = (OkIf(exists)); static_assert(std::is_empty_v
<typename decltype(tryResult3090)::ok_type>); if ((__builtin_expect
(!!(tryResult3090.isErr()), 0))) { auto tryTempError = tryResult3090
.unwrapErr(); mozilla::dom::quota::HandleError("OkIf(exists)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1069, mozilla::dom::quota::Severity::Error); [](const auto&
) { mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1069, "UnknownErr"); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(exists)", tryTempError
, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
;
1070
1071 QM_TRY_INSPECT(auto tryResult3091 = (GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId
, aMaybeKey)); if ((__builtin_expect(!!(tryResult3091.isErr()
), 0))) { mozilla::dom::quota::HandleError("GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId, aMaybeKey)"
, tryResult3091.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1073, mozilla::dom::quota::Severity::Error); return tryResult3091
.propagateErr(); } const auto& dbFileUrl = tryResult3091.
inspect();
1072 const auto& dbFileUrl,auto tryResult3091 = (GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId
, aMaybeKey)); if ((__builtin_expect(!!(tryResult3091.isErr()
), 0))) { mozilla::dom::quota::HandleError("GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId, aMaybeKey)"
, tryResult3091.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1073, mozilla::dom::quota::Severity::Error); return tryResult3091
.propagateErr(); } const auto& dbFileUrl = tryResult3091.
inspect();
1073 GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId, aMaybeKey))auto tryResult3091 = (GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId
, aMaybeKey)); if ((__builtin_expect(!!(tryResult3091.isErr()
), 0))) { mozilla::dom::quota::HandleError("GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId, aMaybeKey)"
, tryResult3091.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1073, mozilla::dom::quota::Severity::Error); return tryResult3091
.propagateErr(); } const auto& dbFileUrl = tryResult3091.
inspect();
;
1074
1075 QM_TRY_INSPECT(const auto& storageService,auto tryResult3092 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3092.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3092.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1078, mozilla::dom::quota::Severity::Error); return tryResult3092
.propagateErr(); } const auto& storageService = tryResult3092
.inspect();
1076 MOZ_TO_RESULT_GET_TYPED(nsCOMPtr<mozIStorageService>,auto tryResult3092 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3092.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3092.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1078, mozilla::dom::quota::Severity::Error); return tryResult3092
.propagateErr(); } const auto& storageService = tryResult3092
.inspect();
1077 MOZ_SELECT_OVERLOAD(do_GetService),auto tryResult3092 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3092.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3092.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1078, mozilla::dom::quota::Severity::Error); return tryResult3092
.propagateErr(); } const auto& storageService = tryResult3092
.inspect();
1078 MOZ_STORAGE_SERVICE_CONTRACTID))auto tryResult3092 = (::mozilla::ToResultGet< nsCOMPtr<
mozIStorageService> >([](auto&&... aArgs) ->
decltype(auto) { return do_GetService(std::forward<decltype
(aArgs)>(aArgs)...); }, "@mozilla.org/storage" "/service;1"
)); if ((__builtin_expect(!!(tryResult3092.isErr()), 0))) { mozilla
::dom::quota::HandleError("::mozilla::ToResultGet< nsCOMPtr<mozIStorageService>>([](auto&&... aArgs) -> decltype(auto) { return do_GetService(std::forward<decltype(aArgs)>(aArgs)...); }, \"@mozilla.org/storage\" \"/service;1\")"
, tryResult3092.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1078, mozilla::dom::quota::Severity::Error); return tryResult3092
.propagateErr(); } const auto& storageService = tryResult3092
.inspect();
;
1079
1080 QM_TRY_UNWRAP(auto tryResult3093 = (OpenDatabaseAndHandleBusy(*storageService
, *dbFileUrl, aTelemetryId)); if ((__builtin_expect(!!(tryResult3093
.isErr()), 0))) { mozilla::dom::quota::HandleError("OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId)"
, tryResult3093.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1082, mozilla::dom::quota::Severity::Error); return tryResult3093
.propagateErr(); } nsCOMPtr<mozIStorageConnection> connection
= tryResult3093.unwrap();
1081 nsCOMPtr<mozIStorageConnection> connection,auto tryResult3093 = (OpenDatabaseAndHandleBusy(*storageService
, *dbFileUrl, aTelemetryId)); if ((__builtin_expect(!!(tryResult3093
.isErr()), 0))) { mozilla::dom::quota::HandleError("OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId)"
, tryResult3093.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1082, mozilla::dom::quota::Severity::Error); return tryResult3093
.propagateErr(); } nsCOMPtr<mozIStorageConnection> connection
= tryResult3093.unwrap();
1082 OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId))auto tryResult3093 = (OpenDatabaseAndHandleBusy(*storageService
, *dbFileUrl, aTelemetryId)); if ((__builtin_expect(!!(tryResult3093
.isErr()), 0))) { mozilla::dom::quota::HandleError("OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId)"
, tryResult3093.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1082, mozilla::dom::quota::Severity::Error); return tryResult3093
.propagateErr(); } nsCOMPtr<mozIStorageConnection> connection
= tryResult3093.unwrap();
;
1083
1084 QM_TRY(MOZ_TO_RESULT(SetDefaultPragmas(*connection))){ auto tryResult3094 = (ToResult(SetDefaultPragmas(*connection
))); static_assert(std::is_empty_v<typename decltype(tryResult3094
)::ok_type>); if ((__builtin_expect(!!(tryResult3094.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(SetDefaultPragmas(*connection))"
, tryResult3094.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1084, mozilla::dom::quota::Severity::Error); return tryResult3094
.propagateErr(); } }
;
1085
1086 QM_TRY(MOZ_TO_RESULT(SetJournalMode(*connection))){ auto tryResult3095 = (ToResult(SetJournalMode(*connection))
); static_assert(std::is_empty_v<typename decltype(tryResult3095
)::ok_type>); if ((__builtin_expect(!!(tryResult3095.isErr
()), 0))) { mozilla::dom::quota::HandleError("ToResult(SetJournalMode(*connection))"
, tryResult3095.inspectErr(), "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1086, mozilla::dom::quota::Severity::Error); return tryResult3095
.propagateErr(); } }
;
1087
1088 return WrapMovingNotNullUnchecked(std::move(connection));
1089}
1090
1091Result<MovingNotNull<nsCOMPtr<mozIStorageConnection>>, nsresult>
1092GetStorageConnection(const nsAString& aDatabaseFilePath,
1093 const int64_t aDirectoryLockId,
1094 const uint32_t aTelemetryId,
1095 const Maybe<CipherKey>& aMaybeKey) {
1096 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/indexedDB/ActorsParent.cpp"
, 1096); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()"
")"); do { *((volatile int*)__null) = 1096; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1097 MOZ_ASSERT(!IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1097); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 1097; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1098 MOZ_ASSERT(!aDatabaseFilePath.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!aDatabaseFilePath.IsEmpty())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!aDatabaseFilePath.IsEmpty()
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"!aDatabaseFilePath.IsEmpty()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1098); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aDatabaseFilePath.IsEmpty()"
")"); do { *((volatile int*)__null) = 1098; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1099 MOZ_ASSERT(StringEndsWith(aDatabaseFilePath, kSQLiteSuffix))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(StringEndsWith(aDatabaseFilePath, kSQLiteSuffix))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(StringEndsWith(aDatabaseFilePath, kSQLiteSuffix)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("StringEndsWith(aDatabaseFilePath, kSQLiteSuffix)"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1099); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StringEndsWith(aDatabaseFilePath, kSQLiteSuffix)"
")"); do { *((volatile int*)__null) = 1099; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1100 MOZ_ASSERT(aDirectoryLockId >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aDirectoryLockId >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aDirectoryLockId >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("aDirectoryLockId >= 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1100); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDirectoryLockId >= 0"
")"); do { *((volatile int*)__null) = 1100; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1101
1102 nsCOMPtr<nsIFile> dbFile = GetFileForPath(aDatabaseFilePath);
1103
1104 QM_TRY(OkIf(dbFile), Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR),{ auto tryResult3096 = (OkIf(dbFile)); static_assert(std::is_empty_v
<typename decltype(tryResult3096)::ok_type>); if ((__builtin_expect
(!!(tryResult3096.isErr()), 0))) { auto tryTempError = tryResult3096
.unwrapErr(); mozilla::dom::quota::HandleError("OkIf(dbFile)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1105, mozilla::dom::quota::Severity::Error); [](const auto&
) { mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1105, "UnknownErr"); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(dbFile)", tryTempError
, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
1105 IDB_REPORT_INTERNAL_ERR_LAMBDA){ auto tryResult3096 = (OkIf(dbFile)); static_assert(std::is_empty_v
<typename decltype(tryResult3096)::ok_type>); if ((__builtin_expect
(!!(tryResult3096.isErr()), 0))) { auto tryTempError = tryResult3096
.unwrapErr(); mozilla::dom::quota::HandleError("OkIf(dbFile)"
, tryTempError, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1105, mozilla::dom::quota::Severity::Error); [](const auto&
) { mozilla::dom::indexedDB::ReportInternalError("/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1105, "UnknownErr"); }(tryTempError); constexpr const auto&
func __attribute__((__unused__)) = __func__; return mozilla::
dom::quota::HandleCustomRetVal(func, "OkIf(dbFile)", tryTempError
, Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)); } }
;
1106
1107 return GetStorageConnection(*dbFile, aDirectoryLockId, aTelemetryId,
1108 aMaybeKey);
1109}
1110
1111/*******************************************************************************
1112 * ConnectionPool declarations
1113 ******************************************************************************/
1114
1115class DatabaseConnection final : public CachingDatabaseConnection {
1116 friend class ConnectionPool;
1117
1118 enum class CheckpointMode { Full, Restart, Truncate };
1119
1120 public:
1121 class AutoSavepoint;
1122 class UpdateRefcountFunction;
1123
1124 private:
1125 InitializedOnce<const NotNull<SafeRefPtr<DatabaseFileManager>>> mFileManager;
1126 RefPtr<UpdateRefcountFunction> mUpdateRefcountFunction;
1127 RefPtr<QuotaObject> mQuotaObject;
1128 RefPtr<QuotaObject> mJournalQuotaObject;
1129 bool mInReadTransaction;
1130 bool mInWriteTransaction;
1131
1132#ifdef DEBUG1
1133 uint32_t mDEBUGSavepointCount;
1134#endif
1135
1136 public:
1137 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DatabaseConnection)public: MozExternalRefCountType AddRef(void) { static_assert(
!std::is_destructible_v<DatabaseConnection>, "Reference-counted class "
"DatabaseConnection" " 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/indexedDB/ActorsParent.cpp"
, 1137); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
1137; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this
), (count), ("DatabaseConnection"), (uint32_t)(sizeof(*this))
); return (nsrefcnt)count; } MozExternalRefCountType 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/indexedDB/ActorsParent.cpp"
, 1137); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 1137
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); nsrefcnt count = --mRefCnt; NS_LogRelease((this), (
count), ("DatabaseConnection")); if (count == 0) { delete (this
); return 0; } return count; } using HasThreadSafeRefCnt = std
::true_type; protected: ::mozilla::ThreadSafeAutoRefCnt mRefCnt
; public:
1138
1139 UpdateRefcountFunction* GetUpdateRefcountFunction() const {
1140 AssertIsOnConnectionThread();
1141
1142 return mUpdateRefcountFunction;
1143 }
1144
1145 nsresult BeginWriteTransaction();
1146
1147 nsresult CommitWriteTransaction();
1148
1149 void RollbackWriteTransaction();
1150
1151 void FinishWriteTransaction();
1152
1153 nsresult StartSavepoint();
1154
1155 nsresult ReleaseSavepoint();
1156
1157 nsresult RollbackSavepoint();
1158
1159 nsresult Checkpoint() {
1160 AssertIsOnConnectionThread();
1161
1162 return CheckpointInternal(CheckpointMode::Full);
1163 }
1164
1165 void DoIdleProcessing(bool aNeedsCheckpoint,
1166 const Atomic<bool>& aInterrupted);
1167
1168 void Close();
1169
1170 nsresult DisableQuotaChecks();
1171
1172 void EnableQuotaChecks();
1173
1174 private:
1175 DatabaseConnection(
1176 MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection,
1177 MovingNotNull<SafeRefPtr<DatabaseFileManager>> aFileManager);
1178
1179 ~DatabaseConnection();
1180
1181 nsresult Init();
1182
1183 nsresult CheckpointInternal(CheckpointMode aMode);
1184
1185 Result<uint32_t, nsresult> GetFreelistCount(
1186 CachedStatement& aCachedStatement);
1187
1188 /**
1189 * On success, returns whether some pages were freed.
1190 */
1191 Result<bool, nsresult> ReclaimFreePagesWhileIdle(
1192 CachedStatement& aFreelistStatement, CachedStatement& aRollbackStatement,
1193 uint32_t aFreelistCount, bool aNeedsCheckpoint,
1194 const Atomic<bool>& aInterrupted);
1195
1196 Result<int64_t, nsresult> GetFileSize(const nsAString& aPath);
1197};
1198
1199class MOZ_STACK_CLASS DatabaseConnection::AutoSavepoint final {
1200 DatabaseConnection* mConnection;
1201#ifdef DEBUG1
1202 const TransactionBase* mDEBUGTransaction;
1203#endif
1204
1205 public:
1206 AutoSavepoint();
1207 ~AutoSavepoint();
1208
1209 nsresult Start(const TransactionBase& aTransaction);
1210
1211 nsresult Commit();
1212};
1213
1214class DatabaseConnection::UpdateRefcountFunction final
1215 : public mozIStorageFunction {
1216 class FileInfoEntry;
1217
1218 enum class UpdateType { Increment, Decrement };
1219
1220 DatabaseConnection* const mConnection;
1221 DatabaseFileManager& mFileManager;
1222 nsClassHashtable<nsUint64HashKey, FileInfoEntry> mFileInfoEntries;
1223 nsTHashMap<nsUint64HashKey, NotNull<FileInfoEntry*>> mSavepointEntriesIndex;
1224
1225 nsTArray<int64_t> mJournalsToCreateBeforeCommit;
1226 nsTArray<int64_t> mJournalsToRemoveAfterCommit;
1227 nsTArray<int64_t> mJournalsToRemoveAfterAbort;
1228
1229 bool mInSavepoint;
1230
1231 public:
1232 NS_DECL_ISUPPORTS_ONEVENTTARGETpublic: 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; nsAutoOwningEventTarget _mOwningThread
; public:
1233 NS_DECL_MOZISTORAGEFUNCTIONvirtual nsresult OnFunctionCall(mozIStorageValueArray *aFunctionArguments
, nsIVariant **_retval) override;
1234
1235 UpdateRefcountFunction(DatabaseConnection* aConnection,
1236 DatabaseFileManager& aFileManager);
1237
1238 nsresult WillCommit();
1239
1240 void DidCommit();
1241
1242 void DidAbort();
1243
1244 void StartSavepoint();
1245
1246 void ReleaseSavepoint();
1247
1248 void RollbackSavepoint();
1249
1250 void Reset();
1251
1252 private:
1253 ~UpdateRefcountFunction() = default;
1254
1255 nsresult ProcessValue(mozIStorageValueArray* aValues, int32_t aIndex,
1256 UpdateType aUpdateType);
1257
1258 nsresult CreateJournals();
1259
1260 nsresult RemoveJournals(const nsTArray<int64_t>& aJournals);
1261};
1262
1263class DatabaseConnection::UpdateRefcountFunction::FileInfoEntry final {
1264 SafeRefPtr<DatabaseFileInfo> mFileInfo;
1265 int32_t mDelta;
1266 int32_t mSavepointDelta;
1267
1268 public:
1269 explicit FileInfoEntry(SafeRefPtr<DatabaseFileInfo> aFileInfo)
1270 : mFileInfo(std::move(aFileInfo)), mDelta(0), mSavepointDelta(0) {
1271 MOZ_COUNT_CTOR(DatabaseConnection::UpdateRefcountFunction::FileInfoEntry)do { static_assert(std::is_class_v<DatabaseConnection::UpdateRefcountFunction
::FileInfoEntry>, "Token '" "DatabaseConnection::UpdateRefcountFunction::FileInfoEntry"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, DatabaseConnection::UpdateRefcountFunction::FileInfoEntry
>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "DatabaseConnection::UpdateRefcountFunction::FileInfoEntry"
, sizeof(*this)); } while (0)
;
1272 }
1273
1274 void IncDeltas(bool aUpdateSavepointDelta) {
1275 ++mDelta;
1276 if (aUpdateSavepointDelta) {
1277 ++mSavepointDelta;
1278 }
1279 }
1280 void DecDeltas(bool aUpdateSavepointDelta) {
1281 --mDelta;
1282 if (aUpdateSavepointDelta) {
1283 --mSavepointDelta;
1284 }
1285 }
1286 void DecBySavepointDelta() { mDelta -= mSavepointDelta; }
1287 SafeRefPtr<DatabaseFileInfo> ReleaseFileInfo() {
1288 return std::move(mFileInfo);
1289 }
1290 void MaybeUpdateDBRefs() {
1291 if (mDelta) {
1292 mFileInfo->UpdateDBRefs(mDelta);
1293 }
1294 }
1295
1296 int32_t Delta() const { return mDelta; }
1297 int32_t SavepointDelta() const { return mSavepointDelta; }
1298
1299 ~FileInfoEntry() {
1300 MOZ_COUNT_DTOR(DatabaseConnection::UpdateRefcountFunction::FileInfoEntry)do { static_assert(std::is_class_v<DatabaseConnection::UpdateRefcountFunction
::FileInfoEntry>, "Token '" "DatabaseConnection::UpdateRefcountFunction::FileInfoEntry"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, DatabaseConnection::UpdateRefcountFunction::FileInfoEntry
>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogDtor((void*)this, "DatabaseConnection::UpdateRefcountFunction::FileInfoEntry"
, sizeof(*this)); } while (0)
;
1301 }
1302};
1303
1304class ConnectionPool final {
1305 public:
1306 class FinishCallback;
1307
1308 private:
1309 class ConnectionRunnable;
1310 class CloseConnectionRunnable;
1311 struct DatabaseInfo;
1312 struct DatabaseCompleteCallback;
1313 class FinishCallbackWrapper;
1314 class IdleConnectionRunnable;
1315
1316 class TransactionInfo;
1317 struct TransactionInfoPair;
1318
1319 struct IdleResource {
1320 TimeStamp mIdleTime;
1321
1322 IdleResource(const IdleResource& aOther) = delete;
1323 IdleResource(IdleResource&& aOther) noexcept
1324 : IdleResource(aOther.mIdleTime) {}
1325 IdleResource& operator=(const IdleResource& aOther) = delete;
1326 IdleResource& operator=(IdleResource&& aOther) = delete;
1327
1328 protected:
1329 explicit IdleResource(const TimeStamp& aIdleTime);
1330
1331 ~IdleResource();
1332 };
1333
1334 struct IdleDatabaseInfo final : public IdleResource {
1335 InitializedOnce<const NotNull<DatabaseInfo*>> mDatabaseInfo;
1336
1337 public:
1338 explicit IdleDatabaseInfo(DatabaseInfo& aDatabaseInfo);
1339
1340 IdleDatabaseInfo(const IdleDatabaseInfo& aOther) = delete;
1341 IdleDatabaseInfo(IdleDatabaseInfo&& aOther) noexcept
1342 : IdleResource(std::move(aOther)),
1343 mDatabaseInfo{std::move(aOther.mDatabaseInfo)} {
1344 MOZ_ASSERT(mDatabaseInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabaseInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabaseInfo))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("mDatabaseInfo",
"/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1344); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabaseInfo"
")"); do { *((volatile int*)__null) = 1344; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1345
1346 MOZ_COUNT_CTOR(ConnectionPool::IdleDatabaseInfo)do { static_assert(std::is_class_v<ConnectionPool::IdleDatabaseInfo
>, "Token '" "ConnectionPool::IdleDatabaseInfo" "' is not a class type."
); static_assert(!std::is_base_of<nsISupports, ConnectionPool
::IdleDatabaseInfo>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "ConnectionPool::IdleDatabaseInfo"
, sizeof(*this)); } while (0)
;
1347 }
1348 IdleDatabaseInfo& operator=(const IdleDatabaseInfo& aOther) = delete;
1349 IdleDatabaseInfo& operator=(IdleDatabaseInfo&& aOther) = delete;
1350
1351 ~IdleDatabaseInfo();
1352
1353 bool operator==(const IdleDatabaseInfo& aOther) const {
1354 return *mDatabaseInfo == *aOther.mDatabaseInfo;
1355 }
1356
1357 bool operator==(const DatabaseInfo* aDatabaseInfo) const {
1358 return *mDatabaseInfo == aDatabaseInfo;
1359 }
1360
1361 bool operator<(const IdleDatabaseInfo& aOther) const {
1362 return mIdleTime < aOther.mIdleTime;
1363 }
1364 };
1365
1366 struct PerformingIdleMaintenanceDatabaseInfo {
1367 const NotNull<DatabaseInfo*> mDatabaseInfo;
1368 RefPtr<IdleConnectionRunnable> mIdleConnectionRunnable;
1369
1370 PerformingIdleMaintenanceDatabaseInfo(
1371 DatabaseInfo& aDatabaseInfo,
1372 RefPtr<IdleConnectionRunnable> aIdleConnectionRunnable);
1373
1374 PerformingIdleMaintenanceDatabaseInfo(
1375 const PerformingIdleMaintenanceDatabaseInfo& aOther) = delete;
1376 PerformingIdleMaintenanceDatabaseInfo(
1377 PerformingIdleMaintenanceDatabaseInfo&& aOther) noexcept
1378 : mDatabaseInfo{aOther.mDatabaseInfo},
1379 mIdleConnectionRunnable{std::move(aOther.mIdleConnectionRunnable)} {
1380 MOZ_COUNT_CTOR(ConnectionPool::PerformingIdleMaintenanceDatabaseInfo)do { static_assert(std::is_class_v<ConnectionPool::PerformingIdleMaintenanceDatabaseInfo
>, "Token '" "ConnectionPool::PerformingIdleMaintenanceDatabaseInfo"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, ConnectionPool::PerformingIdleMaintenanceDatabaseInfo
>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "ConnectionPool::PerformingIdleMaintenanceDatabaseInfo"
, sizeof(*this)); } while (0)
;
1381 }
1382 PerformingIdleMaintenanceDatabaseInfo& operator=(
1383 const PerformingIdleMaintenanceDatabaseInfo& aOther) = delete;
1384 PerformingIdleMaintenanceDatabaseInfo& operator=(
1385 PerformingIdleMaintenanceDatabaseInfo&& aOther) = delete;
1386
1387 ~PerformingIdleMaintenanceDatabaseInfo();
1388
1389 bool operator==(const DatabaseInfo* aDatabaseInfo) const {
1390 return mDatabaseInfo == aDatabaseInfo;
1391 }
1392 };
1393
1394 // This mutex guards mDatabases, see below.
1395 Mutex mDatabasesMutex MOZ_UNANNOTATED;
1396
1397 nsCOMPtr<nsIThreadPool> mIOTarget;
1398 nsTArray<IdleDatabaseInfo> mIdleDatabases;
1399 nsTArray<PerformingIdleMaintenanceDatabaseInfo>
1400 mDatabasesPerformingIdleMaintenance;
1401 nsCOMPtr<nsITimer> mIdleTimer;
1402 TimeStamp mTargetIdleTime;
1403
1404 // Only modifed on the owning thread, but read on multiple threads. Therefore
1405 // all modifications and all reads off the owning thread must be protected by
1406 // mDatabasesMutex.
1407 nsClassHashtable<nsCStringHashKey, DatabaseInfo> mDatabases;
1408
1409 nsClassHashtable<nsUint64HashKey, TransactionInfo> mTransactions;
1410 nsTArray<NotNull<TransactionInfo*>> mQueuedTransactions;
1411
1412 nsTArray<UniquePtr<DatabaseCompleteCallback>> mCompleteCallbacks;
1413
1414 uint64_t mNextTransactionId;
1415 FlippedOnce<false> mShutdownRequested;
1416 FlippedOnce<false> mShutdownComplete;
1417
1418 public:
1419 ConnectionPool();
1420
1421 void AssertIsOnOwningThread() const {
1422 NS_ASSERT_OWNINGTHREAD(ConnectionPool)_mOwningThread.AssertOwnership("ConnectionPool" " not thread-safe"
)
;
1423 }
1424
1425 Result<RefPtr<DatabaseConnection>, nsresult> GetOrCreateConnection(
1426 const Database& aDatabase);
1427
1428 uint64_t Start(const nsID& aBackgroundChildLoggingId,
1429 const nsACString& aDatabaseId, int64_t aLoggingSerialNumber,
1430 const nsTArray<nsString>& aObjectStoreNames,
1431 bool aIsWriteTransaction,
1432 TransactionDatabaseOperationBase* aTransactionOp);
1433
1434 void Dispatch(uint64_t aTransactionId, nsIRunnable* aRunnable);
1435
1436 void Finish(uint64_t aTransactionId, FinishCallback* aCallback);
1437
1438 void CloseDatabaseWhenIdle(const nsACString& aDatabaseId) {
1439 Unused << CloseDatabaseWhenIdleInternal(aDatabaseId);
1440 }
1441
1442 void WaitForDatabaseToComplete(const nsCString& aDatabaseId,
1443 nsIRunnable* aCallback);
1444
1445 void Shutdown();
1446
1447 NS_INLINE_DECL_REFCOUNTING(ConnectionPool)public: MozExternalRefCountType AddRef(void) { static_assert(
!std::is_destructible_v<ConnectionPool>, "Reference-counted class "
"ConnectionPool" " 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/indexedDB/ActorsParent.cpp"
, 1447); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
1447; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); _mOwningThread.AssertOwnership("ConnectionPool"
" not thread-safe"); ++mRefCnt; NS_LogAddRef((this), (mRefCnt
), ("ConnectionPool"), (uint32_t)(sizeof(*this))); return mRefCnt
; } MozExternalRefCountType 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/indexedDB/ActorsParent.cpp"
, 1447); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 1447
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); _mOwningThread.AssertOwnership("ConnectionPool" " not thread-safe"
); --mRefCnt; NS_LogRelease((this), (mRefCnt), ("ConnectionPool"
)); if (mRefCnt == 0) { mRefCnt = 1; delete (this); return 0;
} return mRefCnt; } using HasThreadSafeRefCnt = std::false_type
; protected: nsAutoRefCnt mRefCnt; nsAutoOwningThread _mOwningThread
; public:
1448
1449 private:
1450 ~ConnectionPool();
1451
1452 static void IdleTimerCallback(nsITimer* aTimer, void* aClosure);
1453
1454 static uint32_t SerialNumber() { return ++sSerialNumber; }
1455
1456 static uint32_t sSerialNumber;
1457
1458 void Cleanup();
1459
1460 void AdjustIdleTimer();
1461
1462 void CancelIdleTimer();
1463
1464 void CloseIdleDatabases();
1465
1466 bool ScheduleTransaction(TransactionInfo& aTransactionInfo,
1467 bool aFromQueuedTransactions);
1468
1469 void NoteFinishedTransaction(uint64_t aTransactionId);
1470
1471 void ScheduleQueuedTransactions();
1472
1473 void NoteIdleDatabase(DatabaseInfo& aDatabaseInfo);
1474
1475 void NoteClosedDatabase(DatabaseInfo& aDatabaseInfo);
1476
1477 bool MaybeFireCallback(DatabaseCompleteCallback* aCallback);
1478
1479 void PerformIdleDatabaseMaintenance(DatabaseInfo& aDatabaseInfo);
1480
1481 void CloseDatabase(DatabaseInfo& aDatabaseInfo) const;
1482
1483 bool CloseDatabaseWhenIdleInternal(const nsACString& aDatabaseId);
1484};
1485
1486class ConnectionPool::ConnectionRunnable : public Runnable {
1487 protected:
1488 DatabaseInfo& mDatabaseInfo;
1489 nsCOMPtr<nsIEventTarget> mOwningEventTarget;
1490
1491 explicit ConnectionRunnable(DatabaseInfo& aDatabaseInfo);
1492
1493 ~ConnectionRunnable() override = default;
1494};
1495
1496class ConnectionPool::IdleConnectionRunnable final : public ConnectionRunnable {
1497 const bool mNeedsCheckpoint;
1498 Atomic<bool> mInterrupted;
1499
1500 public:
1501 IdleConnectionRunnable(DatabaseInfo& aDatabaseInfo, bool aNeedsCheckpoint)
1502 : ConnectionRunnable(aDatabaseInfo), mNeedsCheckpoint(aNeedsCheckpoint) {}
1503
1504 NS_INLINE_DECL_REFCOUNTING_INHERITED(IdleConnectionRunnable,virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<IdleConnectionRunnable>, "Reference-counted class "
"IdleConnectionRunnable" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = ConnectionRunnable
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<IdleConnectionRunnable>) { NS_LogAddRef((this), (r), (
"IdleConnectionRunnable"), (uint32_t)(sizeof(*this))); } return
r; } virtual MozExternalRefCountType Release() override { nsrefcnt
r = ConnectionRunnable::Release(); if constexpr (::mozilla::
detail::ShouldLogInheritedRefcnt<IdleConnectionRunnable>
) { NS_LogRelease((this), (r), ("IdleConnectionRunnable")); }
return r; }
1505 ConnectionRunnable)virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<IdleConnectionRunnable>, "Reference-counted class "
"IdleConnectionRunnable" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = ConnectionRunnable
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<IdleConnectionRunnable>) { NS_LogAddRef((this), (r), (
"IdleConnectionRunnable"), (uint32_t)(sizeof(*this))); } return
r; } virtual MozExternalRefCountType Release() override { nsrefcnt
r = ConnectionRunnable::Release(); if constexpr (::mozilla::
detail::ShouldLogInheritedRefcnt<IdleConnectionRunnable>
) { NS_LogRelease((this), (r), ("IdleConnectionRunnable")); }
return r; }
1506
1507 void Interrupt() { mInterrupted = true; }
1508
1509 private:
1510 ~IdleConnectionRunnable() override = default;
1511
1512 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
1513};
1514
1515class ConnectionPool::CloseConnectionRunnable final
1516 : public ConnectionRunnable {
1517 public:
1518 explicit CloseConnectionRunnable(DatabaseInfo& aDatabaseInfo)
1519 : ConnectionRunnable(aDatabaseInfo) {}
1520
1521 NS_INLINE_DECL_REFCOUNTING_INHERITED(CloseConnectionRunnable,virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<CloseConnectionRunnable>, "Reference-counted class "
"CloseConnectionRunnable" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = ConnectionRunnable
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<CloseConnectionRunnable>) { NS_LogAddRef((this), (r), (
"CloseConnectionRunnable"), (uint32_t)(sizeof(*this))); } return
r; } virtual MozExternalRefCountType Release() override { nsrefcnt
r = ConnectionRunnable::Release(); if constexpr (::mozilla::
detail::ShouldLogInheritedRefcnt<CloseConnectionRunnable>
) { NS_LogRelease((this), (r), ("CloseConnectionRunnable")); }
return r; }
1522 ConnectionRunnable)virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<CloseConnectionRunnable>, "Reference-counted class "
"CloseConnectionRunnable" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = ConnectionRunnable
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<CloseConnectionRunnable>) { NS_LogAddRef((this), (r), (
"CloseConnectionRunnable"), (uint32_t)(sizeof(*this))); } return
r; } virtual MozExternalRefCountType Release() override { nsrefcnt
r = ConnectionRunnable::Release(); if constexpr (::mozilla::
detail::ShouldLogInheritedRefcnt<CloseConnectionRunnable>
) { NS_LogRelease((this), (r), ("CloseConnectionRunnable")); }
return r; }
1523
1524 private:
1525 ~CloseConnectionRunnable() override = default;
1526
1527 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
1528};
1529
1530struct ConnectionPool::DatabaseInfo final {
1531 friend class mozilla::DefaultDelete<DatabaseInfo>;
1532
1533 RefPtr<ConnectionPool> mConnectionPool;
1534 const nsCString mDatabaseId;
1535 RefPtr<DatabaseConnection> mConnection;
1536 nsClassHashtable<nsStringHashKey, TransactionInfoPair> mBlockingTransactions;
1537 nsTArray<NotNull<TransactionInfo*>> mTransactionsScheduledDuringClose;
1538 nsTArray<NotNull<TransactionInfo*>> mScheduledWriteTransactions;
1539 Maybe<TransactionInfo&> mRunningWriteTransaction;
1540 RefPtr<TaskQueue> mEventTarget;
1541 uint32_t mReadTransactionCount;
1542 uint32_t mWriteTransactionCount;
1543 bool mNeedsCheckpoint;
1544 bool mIdle;
1545 FlippedOnce<false> mCloseOnIdle;
1546 bool mClosing;
1547
1548#ifdef DEBUG1
1549 nsISerialEventTarget* mDEBUGConnectionEventTarget;
1550#endif
1551
1552 DatabaseInfo(ConnectionPool* aConnectionPool, const nsACString& aDatabaseId);
1553
1554 void AssertIsOnConnectionThread() const {
1555 MOZ_ASSERT(mDEBUGConnectionEventTarget)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDEBUGConnectionEventTarget)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDEBUGConnectionEventTarget)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mDEBUGConnectionEventTarget"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1555); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDEBUGConnectionEventTarget"
")"); do { *((volatile int*)__null) = 1555; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1556 MOZ_ASSERT(GetCurrentSerialEventTarget() == mDEBUGConnectionEventTarget)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(GetCurrentSerialEventTarget() == mDEBUGConnectionEventTarget
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(GetCurrentSerialEventTarget() == mDEBUGConnectionEventTarget
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"GetCurrentSerialEventTarget() == mDEBUGConnectionEventTarget"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1556); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetCurrentSerialEventTarget() == mDEBUGConnectionEventTarget"
")"); do { *((volatile int*)__null) = 1556; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1557 }
1558
1559 uint64_t TotalTransactionCount() const {
1560 return mReadTransactionCount + mWriteTransactionCount;
1561 }
1562
1563 private:
1564 ~DatabaseInfo();
1565
1566 DatabaseInfo(const DatabaseInfo&) = delete;
1567 DatabaseInfo& operator=(const DatabaseInfo&) = delete;
1568};
1569
1570struct ConnectionPool::DatabaseCompleteCallback final {
1571 friend class DefaultDelete<DatabaseCompleteCallback>;
1572
1573 nsCString mDatabaseId;
1574 nsCOMPtr<nsIRunnable> mCallback;
1575
1576 DatabaseCompleteCallback(const nsCString& aDatabaseIds,
1577 nsIRunnable* aCallback);
1578
1579 private:
1580 ~DatabaseCompleteCallback();
1581};
1582
1583class NS_NO_VTABLE ConnectionPool::FinishCallback : public nsIRunnable {
1584 public:
1585 // Called on the owning thread before any additional transactions are
1586 // unblocked.
1587 virtual void TransactionFinishedBeforeUnblock() = 0;
1588
1589 // Called on the owning thread after additional transactions may have been
1590 // unblocked.
1591 virtual void TransactionFinishedAfterUnblock() = 0;
1592
1593 protected:
1594 FinishCallback() = default;
1595
1596 virtual ~FinishCallback() = default;
1597};
1598
1599class ConnectionPool::FinishCallbackWrapper final : public Runnable {
1600 RefPtr<ConnectionPool> mConnectionPool;
1601 RefPtr<FinishCallback> mCallback;
1602 nsCOMPtr<nsIEventTarget> mOwningEventTarget;
1603 uint64_t mTransactionId;
1604 bool mHasRunOnce;
1605
1606 public:
1607 FinishCallbackWrapper(ConnectionPool* aConnectionPool,
1608 uint64_t aTransactionId, FinishCallback* aCallback);
1609
1610 NS_INLINE_DECL_REFCOUNTING_INHERITED(FinishCallbackWrapper, Runnable)virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<FinishCallbackWrapper>, "Reference-counted class "
"FinishCallbackWrapper" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = Runnable
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<FinishCallbackWrapper>) { NS_LogAddRef((this), (r), ("FinishCallbackWrapper"
), (uint32_t)(sizeof(*this))); } return r; } virtual MozExternalRefCountType
Release() override { nsrefcnt r = Runnable::Release(); if constexpr
(::mozilla::detail::ShouldLogInheritedRefcnt<FinishCallbackWrapper
>) { NS_LogRelease((this), (r), ("FinishCallbackWrapper"))
; } return r; }
1611
1612 private:
1613 ~FinishCallbackWrapper() override;
1614
1615 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
1616};
1617
1618class ConnectionPool::TransactionInfo final {
1619 friend class mozilla::DefaultDelete<TransactionInfo>;
1620
1621 nsTHashSet<TransactionInfo*> mBlocking;
1622 nsTArray<NotNull<TransactionInfo*>> mBlockingOrdered;
1623
1624 public:
1625 DatabaseInfo& mDatabaseInfo;
1626 const nsID mBackgroundChildLoggingId;
1627 const nsCString mDatabaseId;
1628 const uint64_t mTransactionId;
1629 const int64_t mLoggingSerialNumber;
1630 const nsTArray<nsString> mObjectStoreNames;
1631 nsTHashSet<TransactionInfo*> mBlockedOn;
1632 nsTArray<nsCOMPtr<nsIRunnable>> mQueuedRunnables;
1633 const bool mIsWriteTransaction;
1634 bool mRunning;
1635
1636#ifdef DEBUG1
1637 FlippedOnce<false> mFinished;
1638#endif
1639
1640 TransactionInfo(DatabaseInfo& aDatabaseInfo,
1641 const nsID& aBackgroundChildLoggingId,
1642 const nsACString& aDatabaseId, uint64_t aTransactionId,
1643 int64_t aLoggingSerialNumber,
1644 const nsTArray<nsString>& aObjectStoreNames,
1645 bool aIsWriteTransaction,
1646 TransactionDatabaseOperationBase* aTransactionOp);
1647
1648 void AddBlockingTransaction(TransactionInfo& aTransactionInfo);
1649
1650 void RemoveBlockingTransactions();
1651
1652 private:
1653 ~TransactionInfo();
1654
1655 void MaybeUnblock(TransactionInfo& aTransactionInfo);
1656};
1657
1658struct ConnectionPool::TransactionInfoPair final {
1659 // Multiple reading transactions can block future writes.
1660 nsTArray<NotNull<TransactionInfo*>> mLastBlockingWrites;
1661 // But only a single writing transaction can block future reads.
1662 Maybe<TransactionInfo&> mLastBlockingReads;
1663
1664#if defined(DEBUG1) || defined(NS_BUILD_REFCNT_LOGGING1)
1665 TransactionInfoPair();
1666 ~TransactionInfoPair();
1667#endif
1668};
1669
1670/*******************************************************************************
1671 * Actor class declarations
1672 ******************************************************************************/
1673
1674template <IDBCursorType CursorType>
1675class CommonOpenOpHelper;
1676template <IDBCursorType CursorType>
1677class IndexOpenOpHelper;
1678template <IDBCursorType CursorType>
1679class ObjectStoreOpenOpHelper;
1680template <IDBCursorType CursorType>
1681class OpenOpHelper;
1682
1683class DatabaseOperationBase : public Runnable,
1684 public mozIStorageProgressHandler {
1685 template <IDBCursorType CursorType>
1686 friend class OpenOpHelper;
1687
1688 protected:
1689 class AutoSetProgressHandler;
1690
1691 using UniqueIndexTable = nsTHashMap<nsUint64HashKey, bool>;
1692
1693 const nsCOMPtr<nsIEventTarget> mOwningEventTarget;
1694 const nsID mBackgroundChildLoggingId;
1695 const uint64_t mLoggingSerialNumber;
1696
1697 private:
1698 nsresult mResultCode = NS_OK;
1699 Atomic<bool> mOperationMayProceed;
1700 FlippedOnce<false> mActorDestroyed;
1701
1702 public:
1703 NS_DECL_ISUPPORTS_INHERITEDpublic: virtual nsresult QueryInterface(const nsIID& aIID
, void** aInstancePtr) override; virtual MozExternalRefCountType
AddRef(void) override; virtual MozExternalRefCountType Release
(void) override;
1704
1705 bool IsOnOwningThread() const {
1706 MOZ_ASSERT(mOwningEventTarget)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mOwningEventTarget)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mOwningEventTarget))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("mOwningEventTarget"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1706); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mOwningEventTarget"
")"); do { *((volatile int*)__null) = 1706; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1707
1708 bool current;
1709 return NS_SUCCEEDED(mOwningEventTarget->IsOnCurrentThread(&current))((bool)(__builtin_expect(!!(!NS_FAILED_impl(mOwningEventTarget
->IsOnCurrentThread(&current))), 1)))
&&
1710 current;
1711 }
1712
1713 void AssertIsOnOwningThread() const {
1714 MOZ_ASSERT(IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1714); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 1714; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1715 MOZ_ASSERT(IsOnOwningThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsOnOwningThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsOnOwningThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("IsOnOwningThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1715); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsOnOwningThread()"
")"); do { *((volatile int*)__null) = 1715; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1716 }
1717
1718 void NoteActorDestroyed() {
1719 AssertIsOnOwningThread();
1720
1721 mActorDestroyed.EnsureFlipped();
1722 mOperationMayProceed = false;
1723 }
1724
1725 bool IsActorDestroyed() const {
1726 AssertIsOnOwningThread();
1727
1728 return mActorDestroyed;
1729 }
1730
1731 // May be called on any thread, but you should call IsActorDestroyed() if
1732 // you know you're on the background thread because it is slightly faster.
1733 bool OperationMayProceed() const { return mOperationMayProceed; }
1734
1735 const nsID& BackgroundChildLoggingId() const {
1736 return mBackgroundChildLoggingId;
1737 }
1738
1739 uint64_t LoggingSerialNumber() const { return mLoggingSerialNumber; }
1740
1741 nsresult ResultCode() const { return mResultCode; }
1742
1743 void SetFailureCode(nsresult aFailureCode) {
1744 MOZ_ASSERT(NS_SUCCEEDED(mResultCode))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(mResultCode
)), 1))))>::isValid, "invalid assertion condition"); if ((
__builtin_expect(!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(mResultCode)), 1)))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("((bool)(__builtin_expect(!!(!NS_FAILED_impl(mResultCode)), 1)))"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1744); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(mResultCode)), 1)))"
")"); do { *((volatile int*)__null) = 1744; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1745 OverrideFailureCode(aFailureCode);
1746 }
1747
1748 void SetFailureCodeIfUnset(nsresult aFailureCode) {
1749 if (NS_SUCCEEDED(mResultCode)((bool)(__builtin_expect(!!(!NS_FAILED_impl(mResultCode)), 1)
))
) {
1750 OverrideFailureCode(aFailureCode);
1751 }
1752 }
1753
1754 bool HasFailed() const { return NS_FAILED(mResultCode)((bool)(__builtin_expect(!!(NS_FAILED_impl(mResultCode)), 0))
)
; }
1755
1756 protected:
1757 DatabaseOperationBase(const nsID& aBackgroundChildLoggingId,
1758 uint64_t aLoggingSerialNumber)
1759 : Runnable("dom::indexedDB::DatabaseOperationBase"),
1760 mOwningEventTarget(GetCurrentSerialEventTarget()),
1761 mBackgroundChildLoggingId(aBackgroundChildLoggingId),
1762 mLoggingSerialNumber(aLoggingSerialNumber),
1763 mOperationMayProceed(true) {
1764 AssertIsOnOwningThread();
1765 }
1766
1767 ~DatabaseOperationBase() override { MOZ_ASSERT(mActorDestroyed)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mActorDestroyed)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mActorDestroyed))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("mActorDestroyed"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1767); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mActorDestroyed"
")"); do { *((volatile int*)__null) = 1767; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
; }
1768
1769 void OverrideFailureCode(nsresult aFailureCode) {
1770 MOZ_ASSERT(NS_FAILED(aFailureCode))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(((bool)(__builtin_expect(!!(NS_FAILED_impl(aFailureCode
)), 0))))>::isValid, "invalid assertion condition"); if ((
__builtin_expect(!!(!(!!(((bool)(__builtin_expect(!!(NS_FAILED_impl
(aFailureCode)), 0)))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("((bool)(__builtin_expect(!!(NS_FAILED_impl(aFailureCode)), 0)))"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 1770); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(NS_FAILED_impl(aFailureCode)), 0)))"
")"); do { *((volatile int*)__null) = 1770; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1771
1772 mResultCode = aFailureCode;
1773 }
1774
1775 static nsAutoCString MaybeGetBindingClauseForKeyRange(
1776 const Maybe<SerializedKeyRange>& aOptionalKeyRange,
1777 const nsACString& aKeyColumnName);
1778
1779 static nsAutoCString GetBindingClauseForKeyRange(
1780 const SerializedKeyRange& aKeyRange, const nsACString& aKeyColumnName);
1781
1782 static uint64_t ReinterpretDoubleAsUInt64(double aDouble);
1783
1784 static nsresult BindKeyRangeToStatement(const SerializedKeyRange& aKeyRange,
1785 mozIStorageStatement* aStatement);
1786
1787 static nsresult BindKeyRangeToStatement(const SerializedKeyRange& aKeyRange,
1788 mozIStorageStatement* aStatement,
1789 const nsCString& aLocale);
1790
1791 static Result<IndexDataValuesAutoArray, nsresult>
1792 IndexDataValuesFromUpdateInfos(const nsTArray<IndexUpdateInfo>& aUpdateInfos,
1793 const UniqueIndexTable& aUniqueIndexTable);
1794
1795 static nsresult InsertIndexTableRows(
1796 DatabaseConnection* aConnection, IndexOrObjectStoreId aObjectStoreId,
1797 const Key& aObjectStoreKey, const nsTArray<IndexDataValue>& aIndexValues);
1798
1799 static nsresult DeleteIndexDataTableRows(
1800 DatabaseConnection* aConnection, const Key& aObjectStoreKey,
1801 const nsTArray<IndexDataValue>& aIndexValues);
1802
1803 static nsresult DeleteObjectStoreDataTableRowsWithIndexes(
1804 DatabaseConnection* aConnection, IndexOrObjectStoreId aObjectStoreId,
1805 const Maybe<SerializedKeyRange>& aKeyRange);
1806
1807 static nsresult UpdateIndexValues(
1808 DatabaseConnection* aConnection, IndexOrObjectStoreId aObjectStoreId,
1809 const Key& aObjectStoreKey, const nsTArray<IndexDataValue>& aIndexValues);
1810
1811 static Result<bool, nsresult> ObjectStoreHasIndexes(
1812 DatabaseConnection& aConnection, IndexOrObjectStoreId aObjectStoreId);
1813
1814 private:
1815 template <typename KeyTransformation>
1816 static nsresult MaybeBindKeyToStatement(
1817 const Key& aKey, mozIStorageStatement* aStatement,
1818 const nsACString& aParameterName,
1819 const KeyTransformation& aKeyTransformation);
1820
1821 template <typename KeyTransformation>
1822 static nsresult BindTransformedKeyRangeToStatement(
1823 const SerializedKeyRange& aKeyRange, mozIStorageStatement* aStatement,
1824 const KeyTransformation& aKeyTransformation);
1825
1826 // Not to be overridden by subclasses.
1827 NS_DECL_MOZISTORAGEPROGRESSHANDLERvirtual nsresult OnProgress(mozIStorageConnection *aConnection
, bool *_retval) override;
1828};
1829
1830class MOZ_STACK_CLASS DatabaseOperationBase::AutoSetProgressHandler final {
1831 Maybe<mozIStorageConnection&> mConnection;
1832#ifdef DEBUG1
1833 DatabaseOperationBase* mDEBUGDatabaseOp;
1834#endif
1835
1836 public:
1837 AutoSetProgressHandler();
1838
1839 ~AutoSetProgressHandler();
1840
1841 nsresult Register(mozIStorageConnection& aConnection,
1842 DatabaseOperationBase* aDatabaseOp);
1843
1844 void Unregister();
1845};
1846
1847class TransactionDatabaseOperationBase : public DatabaseOperationBase {
1848 enum class InternalState {
1849 Initial,
1850 DatabaseWork,
1851 SendingPreprocess,
1852 WaitingForContinue,
1853 SendingResults,
1854 Completed
1855 };
1856
1857 InitializedOnce<const NotNull<SafeRefPtr<TransactionBase>>> mTransaction;
1858 // Unique request id within the context of the transaction, allocated by the
1859 // transaction in the content process starting from 0. Values less than 0 are
1860 // impossible and forbidden. Used to support the explicit commit() request.
1861 const int64_t mRequestId;
1862 InternalState mInternalState = InternalState::Initial;
1863 bool mWaitingForContinue = false;
1864 const bool mTransactionIsAborted;
1865
1866 protected:
1867 const int64_t mTransactionLoggingSerialNumber;
1868
1869#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED1
1870 protected:
1871 // A check only enables when the diagnostic assert turns on. It assumes the
1872 // mUpdateRefcountFunction is a nullptr because the previous
1873 // StartTransactionOp failed on the connection thread and the next write
1874 // operation (e.g. ObjectstoreAddOrPutRequestOp) doesn't have enough time to
1875 // catch up the failure information.
1876 bool mAssumingPreviousOperationFail = false;
1877#endif
1878
1879 public:
1880 void AssertIsOnConnectionThread() const
1881#ifdef DEBUG1
1882 ;
1883#else
1884 {
1885 }
1886#endif
1887
1888 uint64_t StartOnConnectionPool(const nsID& aBackgroundChildLoggingId,
1889 const nsACString& aDatabaseId,
1890 int64_t aLoggingSerialNumber,
1891 const nsTArray<nsString>& aObjectStoreNames,
1892 bool aIsWriteTransaction);
1893
1894 void DispatchToConnectionPool();
1895
1896 TransactionBase& Transaction() { return **mTransaction; }
1897
1898 const TransactionBase& Transaction() const { return **mTransaction; }
1899
1900 bool IsWaitingForContinue() const {
1901 AssertIsOnOwningThread();
1902
1903 return mWaitingForContinue;
1904 }
1905
1906 void NoteContinueReceived();
1907
1908 int64_t TransactionLoggingSerialNumber() const {
1909 return mTransactionLoggingSerialNumber;
1910 }
1911
1912 // May be overridden by subclasses if they need to perform work on the
1913 // background thread before being dispatched. Returning false will kill the
1914 // child actors and prevent dispatch.
1915 virtual bool Init(TransactionBase& aTransaction);
1916
1917 // This callback will be called on the background thread before releasing the
1918 // final reference to this request object. Subclasses may perform any
1919 // additional cleanup here but must always call the base class implementation.
1920 virtual void Cleanup();
1921
1922 protected:
1923 TransactionDatabaseOperationBase(SafeRefPtr<TransactionBase> aTransaction,
1924 int64_t aRequestId);
1925
1926 TransactionDatabaseOperationBase(SafeRefPtr<TransactionBase> aTransaction,
1927 const int64_t aRequestId,
1928 uint64_t aLoggingSerialNumber);
1929
1930 ~TransactionDatabaseOperationBase() override;
1931
1932 virtual void RunOnConnectionThread();
1933
1934 // Must be overridden in subclasses. Called on the target thread to allow the
1935 // subclass to perform necessary database or file operations. A successful
1936 // return value will trigger a SendSuccessResult callback on the background
1937 // thread while a failure value will trigger a SendFailureResult callback.
1938 virtual nsresult DoDatabaseWork(DatabaseConnection* aConnection) = 0;
1939
1940 // May be overriden in subclasses. Called on the background thread to decide
1941 // if the subclass needs to send any preprocess info to the child actor.
1942 virtual bool HasPreprocessInfo();
1943
1944 // May be overriden in subclasses. Called on the background thread to allow
1945 // the subclass to serialize its preprocess info and send it to the child
1946 // actor. A successful return value will trigger a wait for a
1947 // NoteContinueReceived callback on the background thread while a failure
1948 // value will trigger a SendFailureResult callback.
1949 virtual nsresult SendPreprocessInfo();
1950
1951 // Must be overridden in subclasses. Called on the background thread to allow
1952 // the subclass to serialize its results and send them to the child actor. A
1953 // failed return value will trigger a SendFailureResult callback.
1954 virtual nsresult SendSuccessResult() = 0;
1955
1956 // Must be overridden in subclasses. Called on the background thread to allow
1957 // the subclass to send its failure code. Returning false will cause the
1958 // transaction to be aborted with aResultCode. Returning true will not cause
1959 // the transaction to be aborted.
1960 virtual bool SendFailureResult(nsresult aResultCode) = 0;
1961
1962#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED1
1963 auto MakeAutoSavepointCleanupHandler(DatabaseConnection& aConnection) {
1964 return [this, &aConnection](const auto) {
1965 if (!aConnection.GetUpdateRefcountFunction()) {
1966 mAssumingPreviousOperationFail = true;
1967 }
1968 };
1969 }
1970#endif
1971
1972 private:
1973 void SendToConnectionPool();
1974
1975 void SendPreprocess();
1976
1977 void SendResults();
1978
1979 void SendPreprocessInfoOrResults(bool aSendPreprocessInfo);
1980
1981 // Not to be overridden by subclasses.
1982 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
1983};
1984
1985class Factory final : public PBackgroundIDBFactoryParent,
1986 public AtomicSafeRefCounted<Factory> {
1987 nsCString mSystemLocale;
1988 RefPtr<DatabaseLoggingInfo> mLoggingInfo;
1989
1990#ifdef DEBUG1
1991 bool mActorDestroyed;
1992#endif
1993
1994 // Reference counted.
1995 ~Factory() override;
1996
1997 public:
1998 [[nodiscard]] static SafeRefPtr<Factory> Create(
1999 const LoggingInfo& aLoggingInfo, const nsACString& aSystemLocale);
2000
2001 DatabaseLoggingInfo* GetLoggingInfo() const {
2002 AssertIsOnBackgroundThread();
2003 MOZ_ASSERT(mLoggingInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mLoggingInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mLoggingInfo))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("mLoggingInfo", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2003); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mLoggingInfo"
")"); do { *((volatile int*)__null) = 2003; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2004
2005 return mLoggingInfo;
2006 }
2007
2008 const nsCString& GetSystemLocale() const { return mSystemLocale; }
2009
2010 MOZ_DECLARE_REFCOUNTED_TYPENAME(mozilla::dom::indexedDB::Factory)const char* typeName() const { return "mozilla::dom::indexedDB::Factory"
; } size_t typeSize() const { return sizeof(*this); }
2011 MOZ_INLINE_DECL_SAFEREFCOUNTING_INHERITED(Factory, AtomicSafeRefCounted)template <typename T, ::mozilla::detail::RefCountAtomicity
Atomicity> friend class ::mozilla::detail::SafeRefCounted
; virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<Factory>, "Reference-counted class "
"Factory" " should not have a public destructor. " "Make this class's destructor non-public"
); nsrefcnt r = AtomicSafeRefCounted::AddRef(); if constexpr (
::mozilla::detail::ShouldLogInheritedRefcnt<Factory>) {
NS_LogAddRef((this), (r), ("Factory"), (uint32_t)(sizeof(*this
))); } return r; } virtual MozExternalRefCountType Release() override
{ nsrefcnt r = AtomicSafeRefCounted::Release(); if constexpr
(::mozilla::detail::ShouldLogInheritedRefcnt<Factory>)
{ NS_LogRelease((this), (r), ("Factory")); } return r; }
19
Calling 'SafeRefCounted::Release'
29
Returning; memory was released
30
Taking true branch
31
Use of memory after it is freed
2012
2013 // Only constructed in Create().
2014 Factory(RefPtr<DatabaseLoggingInfo> aLoggingInfo,
2015 const nsACString& aSystemLocale);
2016
2017 // IPDL methods are only called by IPDL.
2018 void ActorDestroy(ActorDestroyReason aWhy) override;
2019
2020 mozilla::ipc::IPCResult RecvDeleteMe() override;
2021
2022 PBackgroundIDBFactoryRequestParent* AllocPBackgroundIDBFactoryRequestParent(
2023 const FactoryRequestParams& aParams) override;
2024
2025 mozilla::ipc::IPCResult RecvPBackgroundIDBFactoryRequestConstructor(
2026 PBackgroundIDBFactoryRequestParent* aActor,
2027 const FactoryRequestParams& aParams) override;
2028
2029 bool DeallocPBackgroundIDBFactoryRequestParent(
2030 PBackgroundIDBFactoryRequestParent* aActor) override;
2031
2032 mozilla::ipc::IPCResult RecvGetDatabases(
2033 const PersistenceType& aPersistenceType,
2034 const PrincipalInfo& aPrincipalInfo,
2035 GetDatabasesResolver&& aResolve) override;
2036
2037 private:
2038 Maybe<ContentParentId> GetContentParentId() const;
2039};
2040
2041class WaitForTransactionsHelper final : public Runnable {
2042 const nsCString mDatabaseId;
2043 nsCOMPtr<nsIRunnable> mCallback;
2044
2045 enum class State { Initial = 0, WaitingForTransactions, Complete } mState;
2046
2047 public:
2048 WaitForTransactionsHelper(const nsACString& aDatabaseId,
2049 nsIRunnable* aCallback)
2050 : Runnable("dom::indexedDB::WaitForTransactionsHelper"),
2051 mDatabaseId(aDatabaseId),
2052 mCallback(aCallback),
2053 mState(State::Initial) {
2054 AssertIsOnBackgroundThread();
2055 MOZ_ASSERT(!aDatabaseId.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!aDatabaseId.IsEmpty())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!aDatabaseId.IsEmpty()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!aDatabaseId.IsEmpty()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2055); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aDatabaseId.IsEmpty()"
")"); do { *((volatile int*)__null) = 2055; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2056 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/indexedDB/ActorsParent.cpp"
, 2056); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCallback" ")"
); do { *((volatile int*)__null) = 2056; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2057 }
2058
2059 void WaitForTransactions();
2060
2061 NS_INLINE_DECL_REFCOUNTING_INHERITED(WaitForTransactionsHelper, Runnable)virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<WaitForTransactionsHelper>, "Reference-counted class "
"WaitForTransactionsHelper" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = Runnable
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<WaitForTransactionsHelper>) { NS_LogAddRef((this), (r)
, ("WaitForTransactionsHelper"), (uint32_t)(sizeof(*this))); }
return r; } virtual MozExternalRefCountType Release() override
{ nsrefcnt r = Runnable::Release(); if constexpr (::mozilla::
detail::ShouldLogInheritedRefcnt<WaitForTransactionsHelper
>) { NS_LogRelease((this), (r), ("WaitForTransactionsHelper"
)); } return r; }
2062
2063 private:
2064 ~WaitForTransactionsHelper() override {
2065 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/indexedDB/ActorsParent.cpp"
, 2065); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mCallback"
")"); do { *((volatile int*)__null) = 2065; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2066 MOZ_ASSERT(mState == State::Complete)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mState == State::Complete)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mState == State::Complete)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("mState == State::Complete"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2066); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mState == State::Complete"
")"); do { *((volatile int*)__null) = 2066; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2067 }
2068
2069 void MaybeWaitForTransactions();
2070
2071 void CallCallback();
2072
2073 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
2074};
2075
2076class Database final
2077 : public PBackgroundIDBDatabaseParent,
2078 public SupportsCheckedUnsafePtr<CheckIf<DiagnosticAssertEnabled>>,
2079 public AtomicSafeRefCounted<Database> {
2080 friend class VersionChangeTransaction;
2081
2082 class StartTransactionOp;
2083 class UnmapBlobCallback;
2084
2085 private:
2086 SafeRefPtr<Factory> mFactory;
2087 SafeRefPtr<FullDatabaseMetadata> mMetadata;
2088 SafeRefPtr<DatabaseFileManager> mFileManager;
2089 RefPtr<DirectoryLock> mDirectoryLock;
2090 nsTHashSet<TransactionBase*> mTransactions;
2091 nsTHashMap<nsIDHashKey, SafeRefPtr<DatabaseFileInfo>> mMappedBlobs;
2092 RefPtr<DatabaseConnection> mConnection;
2093 const PrincipalInfo mPrincipalInfo;
2094 const Maybe<ContentParentId> mOptionalContentParentId;
2095 // XXX Consider changing this to ClientMetadata.
2096 const quota::OriginMetadata mOriginMetadata;
2097 const nsCString mId;
2098 const nsString mFilePath;
2099 const Maybe<const CipherKey> mKey;
2100 int64_t mDirectoryLockId;
2101 const uint32_t mTelemetryId;
2102 const PersistenceType mPersistenceType;
2103 const bool mInPrivateBrowsing;
2104 FlippedOnce<false> mClosed;
2105 FlippedOnce<false> mInvalidated;
2106 FlippedOnce<false> mActorWasAlive;
2107 FlippedOnce<false> mActorDestroyed;
2108 nsCOMPtr<nsIEventTarget> mBackgroundThread;
2109#ifdef DEBUG1
2110 bool mAllBlobsUnmapped;
2111#endif
2112
2113 public:
2114 // Created by OpenDatabaseOp.
2115 Database(SafeRefPtr<Factory> aFactory, const PrincipalInfo& aPrincipalInfo,
2116 const Maybe<ContentParentId>& aOptionalContentParentId,
2117 const quota::OriginMetadata& aOriginMetadata, uint32_t aTelemetryId,
2118 SafeRefPtr<FullDatabaseMetadata> aMetadata,
2119 SafeRefPtr<DatabaseFileManager> aFileManager,
2120 RefPtr<DirectoryLock> aDirectoryLock, bool aInPrivateBrowsing,
2121 const Maybe<const CipherKey>& aMaybeKey);
2122
2123 void AssertIsOnConnectionThread() const {
2124#ifdef DEBUG1
2125 if (mConnection) {
2126 MOZ_ASSERT(mConnection)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mConnection)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mConnection))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mConnection", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2126); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mConnection"
")"); do { *((volatile int*)__null) = 2126; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2127 mConnection->AssertIsOnConnectionThread();
2128 } else {
2129 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/indexedDB/ActorsParent.cpp"
, 2129); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()"
")"); do { *((volatile int*)__null) = 2129; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2130 MOZ_ASSERT(!IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2130); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 2130; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2131 MOZ_ASSERT(mInvalidated)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInvalidated)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mInvalidated))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("mInvalidated", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2131); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mInvalidated"
")"); do { *((volatile int*)__null) = 2131; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2132 }
2133#endif
2134 }
2135
2136 NS_IMETHOD_(MozExternalRefCountType)virtual MozExternalRefCountType AddRef() override {
2137 return AtomicSafeRefCounted<Database>::AddRef();
2138 }
2139 NS_IMETHOD_(MozExternalRefCountType)virtual MozExternalRefCountType Release() override {
2140 return AtomicSafeRefCounted<Database>::Release();
2141 }
2142
2143 MOZ_DECLARE_REFCOUNTED_TYPENAME(mozilla::dom::indexedDB::Database)const char* typeName() const { return "mozilla::dom::indexedDB::Database"
; } size_t typeSize() const { return sizeof(*this); }
2144
2145 void Invalidate();
2146
2147 bool IsOwnedByProcess(ContentParentId aContentParentId) const {
2148 return mOptionalContentParentId &&
2149 mOptionalContentParentId.value() == aContentParentId;
2150 }
2151
2152 const quota::OriginMetadata& OriginMetadata() const {
2153 return mOriginMetadata;
2154 }
2155
2156 const nsCString& Id() const { return mId; }
2157
2158 Maybe<DirectoryLock&> MaybeDirectoryLockRef() const {
2159 AssertIsOnBackgroundThread();
2160
2161 return ToMaybeRef(mDirectoryLock.get());
2162 }
2163
2164 int64_t DirectoryLockId() const { return mDirectoryLockId; }
2165
2166 uint32_t TelemetryId() const { return mTelemetryId; }
2167
2168 PersistenceType Type() const { return mPersistenceType; }
2169
2170 const nsString& FilePath() const { return mFilePath; }
2171
2172 DatabaseFileManager& GetFileManager() const { return *mFileManager; }
2173
2174 MovingNotNull<SafeRefPtr<DatabaseFileManager>> GetFileManagerPtr() const {
2175 return WrapMovingNotNull(mFileManager.clonePtr());
2176 }
2177
2178 const FullDatabaseMetadata& Metadata() const {
2179 MOZ_ASSERT(mMetadata)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mMetadata)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mMetadata))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mMetadata", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2179); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mMetadata" ")"
); do { *((volatile int*)__null) = 2179; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2180 return *mMetadata;
2181 }
2182
2183 SafeRefPtr<FullDatabaseMetadata> MetadataPtr() const {
2184 MOZ_ASSERT(mMetadata)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mMetadata)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mMetadata))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mMetadata", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2184); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mMetadata" ")"
); do { *((volatile int*)__null) = 2184; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2185 return mMetadata.clonePtr();
2186 }
2187
2188 PBackgroundParent* GetBackgroundParent() const {
2189 AssertIsOnBackgroundThread();
2190 MOZ_ASSERT(!IsActorDestroyed())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsActorDestroyed())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsActorDestroyed()))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("!IsActorDestroyed()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2190); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsActorDestroyed()"
")"); do { *((volatile int*)__null) = 2190; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2191
2192 return Manager()->Manager();
2193 }
2194
2195 DatabaseLoggingInfo* GetLoggingInfo() const {
2196 AssertIsOnBackgroundThread();
2197 MOZ_ASSERT(mFactory)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mFactory)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mFactory))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mFactory", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2197); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFactory" ")"
); do { *((volatile int*)__null) = 2197; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2198
2199 return mFactory->GetLoggingInfo();
2200 }
2201
2202 bool RegisterTransaction(TransactionBase& aTransaction);
2203
2204 void UnregisterTransaction(TransactionBase& aTransaction);
2205
2206 void SetActorAlive();
2207
2208 void MapBlob(const IPCBlob& aIPCBlob, SafeRefPtr<DatabaseFileInfo> aFileInfo);
2209
2210 bool IsActorAlive() const {
2211 AssertIsOnBackgroundThread();
2212
2213 return mActorWasAlive && !mActorDestroyed;
2214 }
2215
2216 bool IsActorDestroyed() const {
2217 AssertIsOnBackgroundThread();
2218
2219 return mActorWasAlive && mActorDestroyed;
2220 }
2221
2222 bool IsClosed() const {
2223 AssertIsOnBackgroundThread();
2224
2225 return mClosed;
2226 }
2227
2228 bool IsInvalidated() const {
2229 AssertIsOnBackgroundThread();
2230
2231 return mInvalidated;
2232 }
2233
2234 nsresult EnsureConnection();
2235
2236 DatabaseConnection* GetConnection() const {
2237#ifdef DEBUG1
2238 if (mConnection) {
2239 mConnection->AssertIsOnConnectionThread();
2240 }
2241#endif
2242
2243 return mConnection;
2244 }
2245
2246 void Stringify(nsACString& aResult) const;
2247
2248 bool IsInPrivateBrowsing() const {
2249 AssertIsOnBackgroundThread();
2250 return mInPrivateBrowsing;
2251 }
2252
2253 const Maybe<const CipherKey>& MaybeKeyRef() const {
2254 // This can be called on any thread, as it is const.
2255 MOZ_ASSERT(mKey.isSome() == mInPrivateBrowsing)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mKey.isSome() == mInPrivateBrowsing)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mKey.isSome() == mInPrivateBrowsing
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"mKey.isSome() == mInPrivateBrowsing", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2255); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mKey.isSome() == mInPrivateBrowsing"
")"); do { *((volatile int*)__null) = 2255; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2256 return mKey;
2257 }
2258
2259 ~Database() override {
2260 MOZ_ASSERT(mClosed)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mClosed)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mClosed))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mClosed", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2260); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mClosed" ")"
); do { *((volatile int*)__null) = 2260; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2261 MOZ_ASSERT_IF(mActorWasAlive, mActorDestroyed)do { if (mActorWasAlive) { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(mActorDestroyed)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(mActorDestroyed))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("mActorDestroyed", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2261); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mActorDestroyed"
")"); do { *((volatile int*)__null) = 2261; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2262
2263 NS_ProxyRelease("ReleaseIDBFactory", mBackgroundThread.get(),
2264 mFactory.forget());
2265 }
2266
2267 private:
2268 [[nodiscard]] SafeRefPtr<DatabaseFileInfo> GetBlob(const IPCBlob& aIPCBlob);
2269
2270 void UnmapBlob(const nsID& aID);
2271
2272 void UnmapAllBlobs();
2273
2274 bool CloseInternal();
2275
2276 void MaybeCloseConnection();
2277
2278 void ConnectionClosedCallback();
2279
2280 void CleanupMetadata();
2281
2282 // IPDL methods are only called by IPDL.
2283 void ActorDestroy(ActorDestroyReason aWhy) override;
2284
2285 PBackgroundIDBDatabaseFileParent* AllocPBackgroundIDBDatabaseFileParent(
2286 const IPCBlob& aIPCBlob) override;
2287
2288 bool DeallocPBackgroundIDBDatabaseFileParent(
2289 PBackgroundIDBDatabaseFileParent* aActor) override;
2290
2291 already_AddRefed<PBackgroundIDBTransactionParent>
2292 AllocPBackgroundIDBTransactionParent(
2293 const nsTArray<nsString>& aObjectStoreNames, const Mode& aMode,
2294 const Durability& aDurability) override;
2295
2296 mozilla::ipc::IPCResult RecvPBackgroundIDBTransactionConstructor(
2297 PBackgroundIDBTransactionParent* aActor,
2298 nsTArray<nsString>&& aObjectStoreNames, const Mode& aMode,
2299 const Durability& aDurability) override;
2300
2301 mozilla::ipc::IPCResult RecvDeleteMe() override;
2302
2303 mozilla::ipc::IPCResult RecvBlocked() override;
2304
2305 mozilla::ipc::IPCResult RecvClose() override;
2306
2307 template <typename T>
2308 static bool InvalidateAll(const nsTBaseHashSet<nsPtrHashKey<T>>& aTable);
2309};
2310
2311class Database::StartTransactionOp final
2312 : public TransactionDatabaseOperationBase {
2313 friend class Database;
2314
2315 private:
2316 explicit StartTransactionOp(SafeRefPtr<TransactionBase> aTransaction)
2317 : TransactionDatabaseOperationBase(std::move(aTransaction),
2318 /* aRequestId */ 0,
2319 /* aLoggingSerialNumber */ 0) {}
2320
2321 ~StartTransactionOp() override = default;
2322
2323 void RunOnConnectionThread() override;
2324
2325 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
2326
2327 nsresult SendSuccessResult() override;
2328
2329 bool SendFailureResult(nsresult aResultCode) override;
2330
2331 void Cleanup() override;
2332};
2333
2334class Database::UnmapBlobCallback final
2335 : public RemoteLazyInputStreamParentCallback {
2336 SafeRefPtr<Database> mDatabase;
2337 nsCOMPtr<nsISerialEventTarget> mBackgroundThread;
2338
2339 public:
2340 explicit UnmapBlobCallback(SafeRefPtr<Database> aDatabase)
2341 : mDatabase(std::move(aDatabase)),
2342 mBackgroundThread(GetCurrentSerialEventTarget()) {
2343 AssertIsOnBackgroundThread();
2344 }
2345
2346 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Database::UnmapBlobCallback, override)public: MozExternalRefCountType AddRef(void) override { static_assert
(!std::is_destructible_v<Database::UnmapBlobCallback>, "Reference-counted class "
"Database::UnmapBlobCallback" " 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/indexedDB/ActorsParent.cpp"
, 2346); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
2346; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this
), (count), ("Database::UnmapBlobCallback"), (uint32_t)(sizeof
(*this))); return (nsrefcnt)count; } MozExternalRefCountType Release
(void) override { 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/indexedDB/ActorsParent.cpp"
, 2346); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 2346
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); nsrefcnt count = --mRefCnt; NS_LogRelease((this), (
count), ("Database::UnmapBlobCallback")); if (count == 0) { delete
(this); return 0; } return count; } using HasThreadSafeRefCnt
= std::true_type; protected: ::mozilla::ThreadSafeAutoRefCnt
mRefCnt; public:
2347
2348 void ActorDestroyed(const nsID& aID) override {
2349 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2349); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2349; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2350 mBackgroundThread->Dispatch(NS_NewRunnableFunction(
2351 "UnmapBlobCallback", [aID, database = std::move(mDatabase)] {
2352 AssertIsOnBackgroundThread();
2353 database->UnmapBlob(aID);
2354 }));
2355 }
2356
2357 private:
2358 ~UnmapBlobCallback() = default;
2359};
2360
2361/**
2362 * In coordination with IDBDatabase's mFileActors weak-map on the child side, a
2363 * long-lived mapping from a child process's live Blobs to their corresponding
2364 * DatabaseFileInfo in our owning database. Assists in avoiding redundant IPC
2365 * traffic and disk storage. This includes both:
2366 * - Blobs retrieved from this database and sent to the child that do not need
2367 * to be written to disk because they already exist on disk in this database's
2368 * files directory.
2369 * - Blobs retrieved from other databases or from anywhere else that will need
2370 * to be written to this database's files directory. In this case we will
2371 * hold a reference to its BlobImpl in mBlobImpl until we have successfully
2372 * written the Blob to disk.
2373 *
2374 * Relevant Blob context: Blobs sent from the parent process to child processes
2375 * are automatically linked back to their source BlobImpl when the child process
2376 * references the Blob via IPC. This is done using the internal IPCBlob
2377 * inputStream actor ID to DatabaseFileInfo mapping. However, when getting an
2378 * actor in the child process for sending an in-child-created Blob to the
2379 * parent process, there is (currently) no Blob machinery to automatically
2380 * establish and reuse a long-lived Actor. As a result, without IDB's weak-map
2381 * cleverness, a memory-backed Blob repeatedly sent from the child to the parent
2382 * would appear as a different Blob each time, requiring the Blob data to be
2383 * sent over IPC each time as well as potentially needing to be written to disk
2384 * each time.
2385 *
2386 * This object remains alive as long as there is an active child actor or an
2387 * ObjectStoreAddOrPutRequestOp::StoredFileInfo for a queued or active add/put
2388 * op is holding a reference to us.
2389 */
2390class DatabaseFile final : public PBackgroundIDBDatabaseFileParent {
2391 // mBlobImpl's ownership lifecycle:
2392 // - Initialized on the background thread at creation time. Then
2393 // responsibility is handed off to the connection thread.
2394 // - Checked and used by the connection thread to generate a stream to write
2395 // the blob to disk by an add/put operation.
2396 // - Cleared on the connection thread once the file has successfully been
2397 // written to disk.
2398 InitializedOnce<const RefPtr<BlobImpl>> mBlobImpl;
2399 const SafeRefPtr<DatabaseFileInfo> mFileInfo;
2400
2401 public:
2402 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::dom::indexedDB::DatabaseFile)public: MozExternalRefCountType AddRef(void) { static_assert(
!std::is_destructible_v<mozilla::dom::indexedDB::DatabaseFile
>, "Reference-counted class " "mozilla::dom::indexedDB::DatabaseFile"
" 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/indexedDB/ActorsParent.cpp"
, 2402); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
2402; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); nsrefcnt count = ++mRefCnt; NS_LogAddRef((this
), (count), ("mozilla::dom::indexedDB::DatabaseFile"), (uint32_t
)(sizeof(*this))); return (nsrefcnt)count; } MozExternalRefCountType
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/indexedDB/ActorsParent.cpp"
, 2402); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 2402
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); nsrefcnt count = --mRefCnt; NS_LogRelease((this), (
count), ("mozilla::dom::indexedDB::DatabaseFile")); if (count
== 0) { delete (this); return 0; } return count; } using HasThreadSafeRefCnt
= std::true_type; protected: ::mozilla::ThreadSafeAutoRefCnt
mRefCnt; public:
;
2403
2404 const DatabaseFileInfo& GetFileInfo() const {
2405 AssertIsOnBackgroundThread();
2406
2407 return *mFileInfo;
2408 }
2409
2410 SafeRefPtr<DatabaseFileInfo> GetFileInfoPtr() const {
2411 AssertIsOnBackgroundThread();
2412
2413 return mFileInfo.clonePtr();
2414 }
2415
2416 /**
2417 * If mBlobImpl is non-null (implying the contents of this file have not yet
2418 * been written to disk), then return an input stream. Otherwise, if mBlobImpl
2419 * is null (because the contents have been written to disk), returns null.
2420 */
2421 [[nodiscard]] nsCOMPtr<nsIInputStream> GetInputStream(ErrorResult& rv) const;
2422
2423 /**
2424 * To be called upon successful copying of the stream GetInputStream()
2425 * returned so that we won't try and redundantly write the file to disk in the
2426 * future. This is a separate step from GetInputStream() because
2427 * the write could fail due to quota errors that happen now but that might
2428 * not happen in a future attempt.
2429 */
2430 void WriteSucceededClearBlobImpl() {
2431 MOZ_ASSERT(!IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2431); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 2431; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2432
2433 MOZ_ASSERT(*mBlobImpl)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(*mBlobImpl)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(*mBlobImpl))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("*mBlobImpl", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2433); AnnotateMozCrashReason("MOZ_ASSERT" "(" "*mBlobImpl"
")"); do { *((volatile int*)__null) = 2433; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2434 mBlobImpl.destroy();
2435 }
2436
2437 public:
2438 // Called when sending to the child.
2439 explicit DatabaseFile(SafeRefPtr<DatabaseFileInfo> aFileInfo)
2440 : mBlobImpl{nullptr}, mFileInfo(std::move(aFileInfo)) {
2441 AssertIsOnBackgroundThread();
2442 MOZ_ASSERT(mFileInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mFileInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mFileInfo))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mFileInfo", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2442); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileInfo" ")"
); do { *((volatile int*)__null) = 2442; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2443 }
2444
2445 // Called when receiving from the child.
2446 DatabaseFile(RefPtr<BlobImpl> aBlobImpl,
2447 SafeRefPtr<DatabaseFileInfo> aFileInfo)
2448 : mBlobImpl(std::move(aBlobImpl)), mFileInfo(std::move(aFileInfo)) {
2449 AssertIsOnBackgroundThread();
2450 MOZ_ASSERT(*mBlobImpl)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(*mBlobImpl)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(*mBlobImpl))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("*mBlobImpl", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2450); AnnotateMozCrashReason("MOZ_ASSERT" "(" "*mBlobImpl"
")"); do { *((volatile int*)__null) = 2450; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2451 MOZ_ASSERT(mFileInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mFileInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mFileInfo))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mFileInfo", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2451); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileInfo" ")"
); do { *((volatile int*)__null) = 2451; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2452 }
2453
2454 private:
2455 ~DatabaseFile() override = default;
2456
2457 void ActorDestroy(ActorDestroyReason aWhy) override {
2458 AssertIsOnBackgroundThread();
2459 }
2460};
2461
2462nsCOMPtr<nsIInputStream> DatabaseFile::GetInputStream(ErrorResult& rv) const {
2463 // We should only be called from our DB connection thread, not the background
2464 // thread.
2465 MOZ_ASSERT(!IsOnBackgroundThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsOnBackgroundThread()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2465); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsOnBackgroundThread()"
")"); do { *((volatile int*)__null) = 2465; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2466
2467 // If we were constructed without a BlobImpl, or WriteSucceededClearBlobImpl
2468 // was already called, return nullptr.
2469 if (!mBlobImpl || !*mBlobImpl) {
2470 return nullptr;
2471 }
2472
2473 nsCOMPtr<nsIInputStream> inputStream;
2474 (*mBlobImpl)->CreateInputStream(getter_AddRefs(inputStream), rv);
2475 if (rv.Failed()) {
2476 return nullptr;
2477 }
2478
2479 return inputStream;
2480}
2481
2482class TransactionBase : public AtomicSafeRefCounted<TransactionBase> {
2483 friend class CursorBase;
2484
2485 template <IDBCursorType CursorType>
2486 friend class Cursor;
2487
2488 class CommitOp;
2489
2490 protected:
2491 using Mode = IDBTransaction::Mode;
2492 using Durability = IDBTransaction::Durability;
2493
2494 private:
2495 const SafeRefPtr<Database> mDatabase;
2496 nsTArray<SafeRefPtr<FullObjectStoreMetadata>>
2497 mModifiedAutoIncrementObjectStoreMetadataArray;
2498 LazyInitializedOnceNotNull<const uint64_t> mTransactionId;
2499 const nsCString mDatabaseId;
2500 const int64_t mLoggingSerialNumber;
2501 uint64_t mActiveRequestCount;
2502 Atomic<bool> mInvalidatedOnAnyThread;
2503 const Mode mMode;
2504 const Durability mDurability; // TODO: See bug 1883045
2505 FlippedOnce<false> mInitialized;
2506 FlippedOnce<false> mHasBeenActiveOnConnectionThread;
2507 FlippedOnce<false> mActorDestroyed;
2508 FlippedOnce<false> mInvalidated;
2509
2510 protected:
2511 nsresult mResultCode;
2512 FlippedOnce<false> mCommitOrAbortReceived;
2513 FlippedOnce<false> mCommittedOrAborted;
2514 FlippedOnce<false> mForceAborted;
2515 LazyInitializedOnce<const Maybe<int64_t>> mLastRequestBeforeCommit;
2516 Maybe<int64_t> mLastFailedRequest;
2517
2518 public:
2519 void AssertIsOnConnectionThread() const {
2520 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2520); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2520; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2521 mDatabase->AssertIsOnConnectionThread();
2522 }
2523
2524 bool IsActorDestroyed() const {
2525 AssertIsOnBackgroundThread();
2526
2527 return mActorDestroyed;
2528 }
2529
2530 // Must be called on the background thread.
2531 bool IsInvalidated() const {
2532 MOZ_ASSERT(IsOnBackgroundThread(), "Use IsInvalidatedOnAnyThread()")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsOnBackgroundThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsOnBackgroundThread()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("IsOnBackgroundThread()"
" (" "Use IsInvalidatedOnAnyThread()" ")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2532); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsOnBackgroundThread()"
") (" "Use IsInvalidatedOnAnyThread()" ")"); do { *((volatile
int*)__null) = 2532; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2533 MOZ_ASSERT_IF(mInvalidated, NS_FAILED(mResultCode))do { if (mInvalidated) { do { static_assert( mozilla::detail::
AssertionConditionType<decltype(((bool)(__builtin_expect(!
!(NS_FAILED_impl(mResultCode)), 0))))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(((bool)(__builtin_expect(!!(
NS_FAILED_impl(mResultCode)), 0)))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("((bool)(__builtin_expect(!!(NS_FAILED_impl(mResultCode)), 0)))"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2533); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(NS_FAILED_impl(mResultCode)), 0)))"
")"); do { *((volatile int*)__null) = 2533; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2534
2535 return mInvalidated;
2536 }
2537
2538 // May be called on any thread, but is more expensive than IsInvalidated().
2539 bool IsInvalidatedOnAnyThread() const { return mInvalidatedOnAnyThread; }
2540
2541 void Init(const uint64_t aTransactionId) {
2542 AssertIsOnBackgroundThread();
2543 MOZ_ASSERT(aTransactionId)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aTransactionId)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aTransactionId))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("aTransactionId"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2543); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aTransactionId"
")"); do { *((volatile int*)__null) = 2543; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2544
2545 mTransactionId.init(aTransactionId);
2546 mInitialized.Flip();
2547 }
2548
2549 void SetActiveOnConnectionThread() {
2550 AssertIsOnConnectionThread();
2551 mHasBeenActiveOnConnectionThread.Flip();
2552 }
2553
2554 MOZ_DECLARE_REFCOUNTED_TYPENAME(mozilla::dom::indexedDB::TransactionBase)const char* typeName() const { return "mozilla::dom::indexedDB::TransactionBase"
; } size_t typeSize() const { return sizeof(*this); }
2555
2556 void Abort(nsresult aResultCode, bool aForce);
2557
2558 uint64_t TransactionId() const { return *mTransactionId; }
2559
2560 const nsACString& DatabaseId() const { return mDatabaseId; }
2561
2562 Mode GetMode() const { return mMode; }
2563
2564 Durability GetDurability() const { return mDurability; }
2565
2566 const Database& GetDatabase() const {
2567 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2567); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2567; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2568
2569 return *mDatabase;
2570 }
2571
2572 Database& GetMutableDatabase() const {
2573 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2573); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2573; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2574
2575 return *mDatabase;
2576 }
2577
2578 SafeRefPtr<Database> GetDatabasePtr() const {
2579 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2579); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2579; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2580
2581 return mDatabase.clonePtr();
2582 }
2583
2584 DatabaseLoggingInfo* GetLoggingInfo() const {
2585 AssertIsOnBackgroundThread();
2586 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2586); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2586; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2587
2588 return mDatabase->GetLoggingInfo();
2589 }
2590
2591 int64_t LoggingSerialNumber() const { return mLoggingSerialNumber; }
2592
2593 bool IsAborted() const {
2594 AssertIsOnBackgroundThread();
2595
2596 return NS_FAILED(mResultCode)((bool)(__builtin_expect(!!(NS_FAILED_impl(mResultCode)), 0))
)
;
2597 }
2598
2599 [[nodiscard]] SafeRefPtr<FullObjectStoreMetadata> GetMetadataForObjectStoreId(
2600 IndexOrObjectStoreId aObjectStoreId) const;
2601
2602 [[nodiscard]] SafeRefPtr<FullIndexMetadata> GetMetadataForIndexId(
2603 FullObjectStoreMetadata& aObjectStoreMetadata,
2604 IndexOrObjectStoreId aIndexId) const;
2605
2606 PBackgroundParent* GetBackgroundParent() const {
2607 AssertIsOnBackgroundThread();
2608 MOZ_ASSERT(!IsActorDestroyed())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!IsActorDestroyed())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsActorDestroyed()))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("!IsActorDestroyed()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2608); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsActorDestroyed()"
")"); do { *((volatile int*)__null) = 2608; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2609
2610 return GetDatabase().GetBackgroundParent();
2611 }
2612
2613 void NoteModifiedAutoIncrementObjectStore(
2614 const SafeRefPtr<FullObjectStoreMetadata>& aMetadata);
2615
2616 void ForgetModifiedAutoIncrementObjectStore(
2617 FullObjectStoreMetadata& aMetadata);
2618
2619 void NoteActiveRequest();
2620
2621 void NoteFinishedRequest(int64_t aRequestId, nsresult aResultCode);
2622
2623 void Invalidate();
2624
2625 virtual ~TransactionBase();
2626
2627 protected:
2628 TransactionBase(SafeRefPtr<Database> aDatabase, Mode aMode,
2629 Durability aDurability);
2630
2631 void NoteActorDestroyed() {
2632 AssertIsOnBackgroundThread();
2633
2634 mActorDestroyed.Flip();
2635 }
2636
2637#ifdef DEBUG1
2638 // Only called by VersionChangeTransaction.
2639 void FakeActorDestroyed() { mActorDestroyed.EnsureFlipped(); }
2640#endif
2641
2642 mozilla::ipc::IPCResult RecvCommit(IProtocol* aActor,
2643 const Maybe<int64_t> aLastRequest);
2644
2645 mozilla::ipc::IPCResult RecvAbort(IProtocol* aActor, nsresult aResultCode);
2646
2647 void MaybeCommitOrAbort() {
2648 AssertIsOnBackgroundThread();
2649
2650 // If we've already committed or aborted then there's nothing else to do.
2651 if (mCommittedOrAborted) {
2652 return;
2653 }
2654
2655 // If there are active requests then we have to wait for those requests to
2656 // complete (see NoteFinishedRequest).
2657 if (mActiveRequestCount) {
2658 return;
2659 }
2660
2661 // If we haven't yet received a commit or abort message then there could be
2662 // additional requests coming so we should wait unless we're being forced to
2663 // abort.
2664 if (!mCommitOrAbortReceived && !mForceAborted) {
2665 return;
2666 }
2667
2668 CommitOrAbort();
2669 }
2670
2671 PBackgroundIDBRequestParent* AllocRequest(const int64_t aRequestId,
2672 RequestParams&& aParams,
2673 bool aTrustParams);
2674
2675 bool StartRequest(PBackgroundIDBRequestParent* aActor);
2676
2677 bool DeallocRequest(PBackgroundIDBRequestParent* aActor);
2678
2679 already_AddRefed<PBackgroundIDBCursorParent> AllocCursor(
2680 const OpenCursorParams& aParams, bool aTrustParams);
2681
2682 bool StartCursor(PBackgroundIDBCursorParent* aActor, const int64_t aRequestId,
2683 const OpenCursorParams& aParams);
2684
2685 virtual void UpdateMetadata(nsresult aResult) {}
2686
2687 virtual void SendCompleteNotification(nsresult aResult) = 0;
2688
2689 private:
2690 bool VerifyRequestParams(const RequestParams& aParams) const;
2691
2692 bool VerifyRequestParams(const SerializedKeyRange& aParams) const;
2693
2694 bool VerifyRequestParams(const ObjectStoreAddPutParams& aParams) const;
2695
2696 bool VerifyRequestParams(const Maybe<SerializedKeyRange>& aParams) const;
2697
2698 void CommitOrAbort();
2699};
2700
2701class TransactionBase::CommitOp final : public DatabaseOperationBase,
2702 public ConnectionPool::FinishCallback {
2703 friend class TransactionBase;
2704
2705 SafeRefPtr<TransactionBase> mTransaction;
2706 nsresult mResultCode; ///< TODO: There is also a mResultCode in
2707 ///< DatabaseOperationBase. Is there a reason not to
2708 ///< use that? At least a more specific name should be
2709 ///< given to this one.
2710
2711 private:
2712 CommitOp(SafeRefPtr<TransactionBase> aTransaction, nsresult aResultCode);
2713
2714 ~CommitOp() override = default;
2715
2716 // Writes new autoIncrement counts to database.
2717 nsresult WriteAutoIncrementCounts();
2718
2719 // Updates counts after a database activity has finished.
2720 void CommitOrRollbackAutoIncrementCounts();
2721
2722 void AssertForeignKeyConsistency(DatabaseConnection* aConnection)
2723#ifdef DEBUG1
2724 ;
2725#else
2726 {
2727 }
2728#endif
2729
2730 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
2731
2732 void TransactionFinishedBeforeUnblock() override;
2733
2734 void TransactionFinishedAfterUnblock() override;
2735
2736 public:
2737 // We need to declare all of nsISupports, because FinishCallback has
2738 // a pure-virtual nsISupports declaration.
2739 NS_DECL_ISUPPORTS_INHERITEDpublic: virtual nsresult QueryInterface(const nsIID& aIID
, void** aInstancePtr) override; virtual MozExternalRefCountType
AddRef(void) override; virtual MozExternalRefCountType Release
(void) override;
2740};
2741
2742class NormalTransaction final : public TransactionBase,
2743 public PBackgroundIDBTransactionParent {
2744 nsTArray<SafeRefPtr<FullObjectStoreMetadata>> mObjectStores;
2745
2746 // Reference counted.
2747 ~NormalTransaction() override = default;
2748
2749 bool IsSameProcessActor();
2750
2751 // Only called by TransactionBase.
2752 void SendCompleteNotification(nsresult aResult) override;
2753
2754 // IPDL methods are only called by IPDL.
2755 void ActorDestroy(ActorDestroyReason aWhy) override;
2756
2757 mozilla::ipc::IPCResult RecvDeleteMe() override;
2758
2759 mozilla::ipc::IPCResult RecvCommit(
2760 const Maybe<int64_t>& aLastRequest) override;
2761
2762 mozilla::ipc::IPCResult RecvAbort(const nsresult& aResultCode) override;
2763
2764 PBackgroundIDBRequestParent* AllocPBackgroundIDBRequestParent(
2765 const int64_t& aRequestId, const RequestParams& aParams) override;
2766
2767 mozilla::ipc::IPCResult RecvPBackgroundIDBRequestConstructor(
2768 PBackgroundIDBRequestParent* aActor, const int64_t& aRequestId,
2769 const RequestParams& aParams) override;
2770
2771 bool DeallocPBackgroundIDBRequestParent(
2772 PBackgroundIDBRequestParent* aActor) override;
2773
2774 already_AddRefed<PBackgroundIDBCursorParent> AllocPBackgroundIDBCursorParent(
2775 const int64_t& aRequestId, const OpenCursorParams& aParams) override;
2776
2777 mozilla::ipc::IPCResult RecvPBackgroundIDBCursorConstructor(
2778 PBackgroundIDBCursorParent* aActor, const int64_t& aRequestId,
2779 const OpenCursorParams& aParams) override;
2780
2781 public:
2782 // This constructor is only called by Database.
2783 NormalTransaction(
2784 SafeRefPtr<Database> aDatabase, TransactionBase::Mode aMode,
2785 TransactionBase::Durability aDurability,
2786 nsTArray<SafeRefPtr<FullObjectStoreMetadata>>&& aObjectStores);
2787
2788 MOZ_INLINE_DECL_SAFEREFCOUNTING_INHERITED(NormalTransaction, TransactionBase)template <typename T, ::mozilla::detail::RefCountAtomicity
Atomicity> friend class ::mozilla::detail::SafeRefCounted
; virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<NormalTransaction>, "Reference-counted class "
"NormalTransaction" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = TransactionBase
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<NormalTransaction>) { NS_LogAddRef((this), (r), ("NormalTransaction"
), (uint32_t)(sizeof(*this))); } return r; } virtual MozExternalRefCountType
Release() override { nsrefcnt r = TransactionBase::Release()
; if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt<
NormalTransaction>) { NS_LogRelease((this), (r), ("NormalTransaction"
)); } return r; }
2789};
2790
2791class VersionChangeTransaction final
2792 : public TransactionBase,
2793 public PBackgroundIDBVersionChangeTransactionParent {
2794 friend class OpenDatabaseOp;
2795
2796 RefPtr<OpenDatabaseOp> mOpenDatabaseOp;
2797 SafeRefPtr<FullDatabaseMetadata> mOldMetadata;
2798
2799 FlippedOnce<false> mActorWasAlive;
2800
2801 public:
2802 // Only called by OpenDatabaseOp.
2803 explicit VersionChangeTransaction(OpenDatabaseOp* aOpenDatabaseOp);
2804
2805 MOZ_INLINE_DECL_SAFEREFCOUNTING_INHERITED(VersionChangeTransaction,template <typename T, ::mozilla::detail::RefCountAtomicity
Atomicity> friend class ::mozilla::detail::SafeRefCounted
; virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<VersionChangeTransaction>, "Reference-counted class "
"VersionChangeTransaction" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = TransactionBase
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<VersionChangeTransaction>) { NS_LogAddRef((this), (r),
("VersionChangeTransaction"), (uint32_t)(sizeof(*this))); } return
r; } virtual MozExternalRefCountType Release() override { nsrefcnt
r = TransactionBase::Release(); if constexpr (::mozilla::detail
::ShouldLogInheritedRefcnt<VersionChangeTransaction>) {
NS_LogRelease((this), (r), ("VersionChangeTransaction")); } return
r; }
2806 TransactionBase)template <typename T, ::mozilla::detail::RefCountAtomicity
Atomicity> friend class ::mozilla::detail::SafeRefCounted
; virtual MozExternalRefCountType AddRef() override { static_assert
(!std::is_destructible_v<VersionChangeTransaction>, "Reference-counted class "
"VersionChangeTransaction" " should not have a public destructor. "
"Make this class's destructor non-public"); nsrefcnt r = TransactionBase
::AddRef(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<VersionChangeTransaction>) { NS_LogAddRef((this), (r),
("VersionChangeTransaction"), (uint32_t)(sizeof(*this))); } return
r; } virtual MozExternalRefCountType Release() override { nsrefcnt
r = TransactionBase::Release(); if constexpr (::mozilla::detail
::ShouldLogInheritedRefcnt<VersionChangeTransaction>) {
NS_LogRelease((this), (r), ("VersionChangeTransaction")); } return
r; }
2807
2808 private:
2809 // Reference counted.
2810 ~VersionChangeTransaction() override;
2811
2812 bool IsSameProcessActor();
2813
2814 // Only called by OpenDatabaseOp.
2815 bool CopyDatabaseMetadata();
2816
2817 void SetActorAlive();
2818
2819 // Only called by TransactionBase.
2820 void UpdateMetadata(nsresult aResult) override;
2821
2822 // Only called by TransactionBase.
2823 void SendCompleteNotification(nsresult aResult) override;
2824
2825 // IPDL methods are only called by IPDL.
2826 void ActorDestroy(ActorDestroyReason aWhy) override;
2827
2828 mozilla::ipc::IPCResult RecvDeleteMe() override;
2829
2830 mozilla::ipc::IPCResult RecvCommit(
2831 const Maybe<int64_t>& aLastRequest) override;
2832
2833 mozilla::ipc::IPCResult RecvAbort(const nsresult& aResultCode) override;
2834
2835 mozilla::ipc::IPCResult RecvCreateObjectStore(
2836 const ObjectStoreMetadata& aMetadata) override;
2837
2838 mozilla::ipc::IPCResult RecvDeleteObjectStore(
2839 const IndexOrObjectStoreId& aObjectStoreId) override;
2840
2841 mozilla::ipc::IPCResult RecvRenameObjectStore(
2842 const IndexOrObjectStoreId& aObjectStoreId,
2843 const nsAString& aName) override;
2844
2845 mozilla::ipc::IPCResult RecvCreateIndex(
2846 const IndexOrObjectStoreId& aObjectStoreId,
2847 const IndexMetadata& aMetadata) override;
2848
2849 mozilla::ipc::IPCResult RecvDeleteIndex(
2850 const IndexOrObjectStoreId& aObjectStoreId,
2851 const IndexOrObjectStoreId& aIndexId) override;
2852
2853 mozilla::ipc::IPCResult RecvRenameIndex(
2854 const IndexOrObjectStoreId& aObjectStoreId,
2855 const IndexOrObjectStoreId& aIndexId, const nsAString& aName) override;
2856
2857 PBackgroundIDBRequestParent* AllocPBackgroundIDBRequestParent(
2858 const int64_t& aRequestId, const RequestParams& aParams) override;
2859
2860 mozilla::ipc::IPCResult RecvPBackgroundIDBRequestConstructor(
2861 PBackgroundIDBRequestParent* aActor, const int64_t& aRequestId,
2862 const RequestParams& aParams) override;
2863
2864 bool DeallocPBackgroundIDBRequestParent(
2865 PBackgroundIDBRequestParent* aActor) override;
2866
2867 already_AddRefed<PBackgroundIDBCursorParent> AllocPBackgroundIDBCursorParent(
2868 const int64_t& aRequestId, const OpenCursorParams& aParams) override;
2869
2870 mozilla::ipc::IPCResult RecvPBackgroundIDBCursorConstructor(
2871 PBackgroundIDBCursorParent* aActor, const int64_t& aRequestId,
2872 const OpenCursorParams& aParams) override;
2873};
2874
2875class FactoryOp
2876 : public DatabaseOperationBase,
2877 public SupportsCheckedUnsafePtr<CheckIf<DiagnosticAssertEnabled>> {
2878 public:
2879 struct MaybeBlockedDatabaseInfo final {
2880 SafeRefPtr<Database> mDatabase;
2881 bool mBlocked;
2882
2883 MaybeBlockedDatabaseInfo(MaybeBlockedDatabaseInfo&&) = default;
2884 MaybeBlockedDatabaseInfo& operator=(MaybeBlockedDatabaseInfo&&) = default;
2885
2886 MOZ_IMPLICIT MaybeBlockedDatabaseInfo(SafeRefPtr<Database> aDatabase)
2887 : mDatabase(std::move(aDatabase)), mBlocked(false) {
2888 MOZ_ASSERT(mDatabase)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabase)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabase))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mDatabase", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 2888); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabase" ")"
); do { *((volatile int*)__null) = 2888; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2889
2890 MOZ_COUNT_CTOR(FactoryOp::MaybeBlockedDatabaseInfo)do { static_assert(std::is_class_v<FactoryOp::MaybeBlockedDatabaseInfo
>, "Token '" "FactoryOp::MaybeBlockedDatabaseInfo" "' is not a class type."
); static_assert(!std::is_base_of<nsISupports, FactoryOp::
MaybeBlockedDatabaseInfo>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "FactoryOp::MaybeBlockedDatabaseInfo"
, sizeof(*this)); } while (0)
;
2891 }
2892
2893 ~MaybeBlockedDatabaseInfo() {
2894 MOZ_COUNT_DTOR(FactoryOp::MaybeBlockedDatabaseInfo)do { static_assert(std::is_class_v<FactoryOp::MaybeBlockedDatabaseInfo
>, "Token '" "FactoryOp::MaybeBlockedDatabaseInfo" "' is not a class type."
); static_assert(!std::is_base_of<nsISupports, FactoryOp::
MaybeBlockedDatabaseInfo>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogDtor((void*)this, "FactoryOp::MaybeBlockedDatabaseInfo"
, sizeof(*this)); } while (0)
;
2895 }
2896
2897 bool operator==(const Database* aOther) const {
2898 return mDatabase == aOther;
2899 }
2900
2901 Database* operator->() const& MOZ_NO_ADDREF_RELEASE_ON_RETURN {
2902 return mDatabase.unsafeGetRawPtr();
2903 }
2904 };
2905
2906 protected:
2907 enum class State {
2908 // Just created on the PBackground thread, dispatched to the current thread.
2909 // Next step is either SendingResults if opening initialization failed, or
2910 // DirectoryOpenPending if the opening initialization succeeded.
2911 Initial,
2912
2913 // Waiting for directory open allowed on the PBackground thread. The next
2914 // step is either SendingResults if directory lock failed to acquire, or
2915 // DirectoryWorkOpen if the factory operation is not tied up to a specific
2916 // database, or DatabaseOpenPending otherwise.
2917 DirectoryOpenPending,
2918
2919 // Waiting to do/doing directory work on the QuotaManager IO thread. Its
2920 // next step is DirectoryWorkDone if directory work was successful or
2921 // SendingResults if directory work failed.
2922 DirectoryWorkOpen,
2923
2924 // Checking if database work can be started. If the database is not blocked
2925 // by other factory operations then the next step is DatabaseWorkOpen.
2926 // Otherwise the next step is DatabaseOpenPending.
2927 DirectoryWorkDone,
2928
2929 // Waiting for database open allowed on the PBackground thread. The next
2930 // step is DatabaseWorkOpen.
2931 DatabaseOpenPending,
2932
2933 // Waiting to do/doing work on the QuotaManager IO thread. Its next step is
2934 // either BeginVersionChange if the requested version doesn't match the
2935 // existing database version or SendingResults if the versions match.
2936 DatabaseWorkOpen,
2937
2938 // Starting a version change transaction or deleting a database on the
2939 // PBackground thread. We need to notify other databases that a version
2940 // change is about to happen, and maybe tell the request that a version
2941 // change has been blocked. If databases are notified then the next step is
2942 // WaitingForOtherDatabasesToClose. Otherwise the next step is
2943 // WaitingForTransactionsToComplete.
2944 BeginVersionChange,
2945
2946 // Waiting for other databases to close on the PBackground thread. This
2947 // state may persist until all databases are closed. The next state is
2948 // WaitingForTransactionsToComplete.
2949 WaitingForOtherDatabasesToClose,
2950
2951 // Waiting for all transactions that could interfere with this operation to
2952 // complete on the PBackground thread. Next state is
2953 // DatabaseWorkVersionChange.
2954 WaitingForTransactionsToComplete,
2955
2956 // Waiting to do/doing work on the "work thread". This involves waiting for
2957 // the VersionChangeOp (OpenDatabaseOp and DeleteDatabaseOp each have a
2958 // different implementation) to do its work. Eventually the state will
2959 // transition to SendingResults.
2960 DatabaseWorkVersionChange,
2961
2962 // Waiting to send/sending results on the PBackground thread. Next step is
2963 // Completed.
2964 SendingResults,
2965
2966 // All done.
2967 Completed
2968 };
2969
2970 // Must be released on the background thread!
2971 SafeRefPtr<Factory> mFactory;
2972
2973 Maybe<ContentParentId> mContentParentId;
2974
2975 // Must be released on the main thread!
2976 RefPtr<DirectoryLock> mDirectoryLock;
2977
2978 nsTArray<NotNull<RefPtr<FactoryOp>>> mBlocking;
2979 nsTArray<NotNull<RefPtr<FactoryOp>>> mBlockedOn;
2980
2981 nsTArray<MaybeBlockedDatabaseInfo> mMaybeBlockedDatabases;
2982
2983 const PrincipalInfo mPrincipalInfo;
2984 OriginMetadata mOriginMetadata;
2985 Maybe<nsString> mDatabaseName;
2986 Maybe<nsCString> mDatabaseId;
2987 Maybe<nsString> mDatabaseFilePath;
2988 int64_t mDirectoryLockId;
2989 const PersistenceType mPersistenceType;
2990 State mState;
2991 bool mWaitingForPermissionRetry;
2992 bool mEnforcingQuota;
2993 const bool mDeleting;
2994 FlippedOnce<false> mInPrivateBrowsing;
2995
2996 public:
2997 const nsACString& Origin() const {
2998 AssertIsOnOwningThread();
2999
3000 return mOriginMetadata.mOrigin;
3001 }
3002
3003 const Maybe<nsString>& DatabaseNameRef() const {
3004 AssertIsOnOwningThread();
3005
3006 return mDatabaseName;
3007 }
3008
3009 bool DatabaseFilePathIsKnown() const {
3010 AssertIsOnOwningThread();
3011
3012 return mDatabaseFilePath.isSome();
3013 }
3014
3015 const nsAString& DatabaseFilePath() const {
3016 AssertIsOnOwningThread();
3017 MOZ_ASSERT(mDatabaseFilePath)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mDatabaseFilePath)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mDatabaseFilePath))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("mDatabaseFilePath"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3017); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mDatabaseFilePath"
")"); do { *((volatile int*)__null) = 3017; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3018
3019 return mDatabaseFilePath.ref();
3020 }
3021
3022 void NoteDatabaseBlocked(Database* aDatabase);
3023
3024 void NoteDatabaseClosed(Database* aDatabase);
3025
3026#ifdef DEBUG1
3027 bool HasBlockedDatabases() const { return !mMaybeBlockedDatabases.IsEmpty(); }
3028#endif
3029
3030 void StringifyState(nsACString& aResult) const;
3031
3032 void Stringify(nsACString& aResult) const;
3033
3034 protected:
3035 FactoryOp(SafeRefPtr<Factory> aFactory,
3036 const Maybe<ContentParentId>& aContentParentId,
3037 const PersistenceType aPersistenceType,
3038 const PrincipalInfo& aPrincipalInfo,
3039 const Maybe<nsString>& aDatabaseName, bool aDeleting);
3040
3041 ~FactoryOp() override {
3042 // Normally this would be out-of-line since it is a virtual function but
3043 // MSVC 2010 fails to link for some reason if it is not inlined here...
3044 MOZ_ASSERT_IF(OperationMayProceed(),do { if (OperationMayProceed()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(mState == State::
Initial || mState == State::Completed)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mState == State::Initial || mState
== State::Completed))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("mState == State::Initial || mState == State::Completed", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3045); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mState == State::Initial || mState == State::Completed"
")"); do { *((volatile int*)__null) = 3045; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3045 mState == State::Initial || mState == State::Completed)do { if (OperationMayProceed()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(mState == State::
Initial || mState == State::Completed)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mState == State::Initial || mState
== State::Completed))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("mState == State::Initial || mState == State::Completed", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3045); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mState == State::Initial || mState == State::Completed"
")"); do { *((volatile int*)__null) = 3045; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3046 }
3047
3048 nsresult Open();
3049
3050 nsresult DirectoryOpen();
3051
3052 nsresult DirectoryWorkDone();
3053
3054 nsresult SendToIOThread();
3055
3056 void WaitForTransactions();
3057
3058 void CleanupMetadata();
3059
3060 void FinishSendResults();
3061
3062 nsresult SendVersionChangeMessages(DatabaseActorInfo* aDatabaseActorInfo,
3063 Maybe<Database&> aOpeningDatabase,
3064 uint64_t aOldVersion,
3065 const Maybe<uint64_t>& aNewVersion);
3066
3067 // Methods that subclasses must implement.
3068 virtual nsresult DoDirectoryWork() = 0;
3069
3070 virtual nsresult DatabaseOpen() = 0;
3071
3072 virtual nsresult DoDatabaseWork() = 0;
3073
3074 virtual nsresult BeginVersionChange() = 0;
3075
3076 virtual bool AreActorsAlive() = 0;
3077
3078 virtual nsresult DispatchToWorkThread() = 0;
3079
3080 // Should only be called by Run().
3081 virtual void SendResults() = 0;
3082
3083 // Common nsIRunnable implementation that subclasses may not override.
3084 NS_IMETHODvirtual nsresult
3085 Run() final;
3086
3087 void DirectoryLockAcquired(DirectoryLock* aLock);
3088
3089 void DirectoryLockFailed();
3090
3091 virtual void SendBlockedNotification() = 0;
3092
3093 private:
3094 // Test whether this FactoryOp needs to wait for the given op.
3095 bool MustWaitFor(const FactoryOp& aExistingOp);
3096
3097 void AddBlockingOp(FactoryOp& aOp) {
3098 AssertIsOnOwningThread();
3099
3100 mBlocking.AppendElement(WrapNotNull(&aOp));
3101 }
3102
3103 void AddBlockedOnOp(FactoryOp& aOp) {
3104 AssertIsOnOwningThread();
3105
3106 mBlockedOn.AppendElement(WrapNotNull(&aOp));
3107 }
3108
3109 void MaybeUnblock(FactoryOp& aOp) {
3110 AssertIsOnOwningThread();
3111
3112 mBlockedOn.RemoveElement(&aOp);
3113 if (mBlockedOn.IsEmpty()) {
3114 MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(this))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(NS_DispatchToCurrentThread(this))), 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(NS_DispatchToCurrentThread(this))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3114); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(NS_DispatchToCurrentThread(this))" ")");
do { *((volatile int*)__null) = 3114; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3115 }
3116 }
3117};
3118
3119class FactoryRequestOp : public FactoryOp,
3120 public PBackgroundIDBFactoryRequestParent {
3121 protected:
3122 const CommonFactoryRequestParams mCommonParams;
3123
3124 FactoryRequestOp(SafeRefPtr<Factory> aFactory,
3125 const Maybe<ContentParentId>& aContentParentId,
3126 const CommonFactoryRequestParams& aCommonParams,
3127 bool aDeleting)
3128 : FactoryOp(std::move(aFactory), aContentParentId,
3129 aCommonParams.metadata().persistenceType(),
3130 aCommonParams.principalInfo(),
3131 Some(aCommonParams.metadata().name()), aDeleting),
3132 mCommonParams(aCommonParams) {}
3133
3134 nsresult DoDirectoryWork() override;
3135
3136 // IPDL methods.
3137 void ActorDestroy(ActorDestroyReason aWhy) override;
3138};
3139
3140class OpenDatabaseOp final : public FactoryRequestOp {
3141 friend class Database;
3142 friend class VersionChangeTransaction;
3143
3144 class VersionChangeOp;
3145
3146 SafeRefPtr<FullDatabaseMetadata> mMetadata;
3147
3148 uint64_t mRequestedVersion;
3149 SafeRefPtr<DatabaseFileManager> mFileManager;
3150
3151 SafeRefPtr<Database> mDatabase;
3152 SafeRefPtr<VersionChangeTransaction> mVersionChangeTransaction;
3153
3154 // This is only set while a VersionChangeOp is live. It holds a strong
3155 // reference to its OpenDatabaseOp object so this is a weak pointer to avoid
3156 // cycles.
3157 VersionChangeOp* mVersionChangeOp;
3158
3159 uint32_t mTelemetryId;
3160
3161 public:
3162 OpenDatabaseOp(SafeRefPtr<Factory> aFactory,
3163 const Maybe<ContentParentId>& aContentParentId,
3164 const CommonFactoryRequestParams& aParams);
3165
3166 private:
3167 ~OpenDatabaseOp() override { MOZ_ASSERT(!mVersionChangeOp)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mVersionChangeOp)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!mVersionChangeOp))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("!mVersionChangeOp"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3167); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mVersionChangeOp"
")"); do { *((volatile int*)__null) = 3167; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
; }
3168
3169 nsresult LoadDatabaseInformation(mozIStorageConnection& aConnection);
3170
3171 nsresult SendUpgradeNeeded();
3172
3173 void EnsureDatabaseActor();
3174
3175 nsresult EnsureDatabaseActorIsAlive();
3176
3177 mozilla::Result<DatabaseSpec, nsresult> MetadataToSpec() const;
3178
3179 void AssertMetadataConsistency(const FullDatabaseMetadata& aMetadata)
3180#ifdef DEBUG1
3181 ;
3182#else
3183 {
3184 }
3185#endif
3186
3187 void ConnectionClosedCallback();
3188
3189 void ActorDestroy(ActorDestroyReason aWhy) override;
3190
3191 nsresult DatabaseOpen() override;
3192
3193 nsresult DoDatabaseWork() override;
3194
3195 nsresult BeginVersionChange() override;
3196
3197 bool AreActorsAlive() override;
3198
3199 void SendBlockedNotification() override;
3200
3201 nsresult DispatchToWorkThread() override;
3202
3203 void SendResults() override;
3204
3205 static nsresult UpdateLocaleAwareIndex(mozIStorageConnection& aConnection,
3206 const IndexMetadata& aIndexMetadata,
3207 const nsCString& aLocale);
3208};
3209
3210class OpenDatabaseOp::VersionChangeOp final
3211 : public TransactionDatabaseOperationBase {
3212 friend class OpenDatabaseOp;
3213
3214 RefPtr<OpenDatabaseOp> mOpenDatabaseOp;
3215 const uint64_t mRequestedVersion;
3216 uint64_t mPreviousVersion;
3217
3218 private:
3219 explicit VersionChangeOp(OpenDatabaseOp* aOpenDatabaseOp)
3220 : TransactionDatabaseOperationBase(
3221 aOpenDatabaseOp->mVersionChangeTransaction.clonePtr(),
3222 /* aRequestId */ 0, aOpenDatabaseOp->LoggingSerialNumber()),
3223 mOpenDatabaseOp(aOpenDatabaseOp),
3224 mRequestedVersion(aOpenDatabaseOp->mRequestedVersion),
3225 mPreviousVersion(
3226 aOpenDatabaseOp->mMetadata->mCommonMetadata.version()) {
3227 MOZ_ASSERT(aOpenDatabaseOp)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aOpenDatabaseOp)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aOpenDatabaseOp))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("aOpenDatabaseOp"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3227); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOpenDatabaseOp"
")"); do { *((volatile int*)__null) = 3227; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3228 MOZ_ASSERT(mRequestedVersion)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mRequestedVersion)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mRequestedVersion))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("mRequestedVersion"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3228); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mRequestedVersion"
")"); do { *((volatile int*)__null) = 3228; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3229 }
3230
3231 ~VersionChangeOp() override { MOZ_ASSERT(!mOpenDatabaseOp)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mOpenDatabaseOp)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!mOpenDatabaseOp))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!mOpenDatabaseOp"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3231); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mOpenDatabaseOp"
")"); do { *((volatile int*)__null) = 3231; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
; }
3232
3233 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3234
3235 nsresult SendSuccessResult() override;
3236
3237 bool SendFailureResult(nsresult aResultCode) override;
3238
3239 void Cleanup() override;
3240};
3241
3242class DeleteDatabaseOp final : public FactoryRequestOp {
3243 class VersionChangeOp;
3244
3245 nsString mDatabaseDirectoryPath;
3246 nsString mDatabaseFilenameBase;
3247 uint64_t mPreviousVersion;
3248
3249 public:
3250 DeleteDatabaseOp(SafeRefPtr<Factory> aFactory,
3251 const Maybe<ContentParentId>& aContentParentId,
3252 const CommonFactoryRequestParams& aParams)
3253 : FactoryRequestOp(std::move(aFactory), aContentParentId, aParams,
3254 /* aDeleting */ true),
3255 mPreviousVersion(0) {}
3256
3257 private:
3258 ~DeleteDatabaseOp() override = default;
3259
3260 void LoadPreviousVersion(nsIFile& aDatabaseFile);
3261
3262 nsresult DatabaseOpen() override;
3263
3264 nsresult DoDatabaseWork() override;
3265
3266 nsresult BeginVersionChange() override;
3267
3268 bool AreActorsAlive() override;
3269
3270 void SendBlockedNotification() override;
3271
3272 nsresult DispatchToWorkThread() override;
3273
3274 void SendResults() override;
3275};
3276
3277class DeleteDatabaseOp::VersionChangeOp final : public DatabaseOperationBase {
3278 friend class DeleteDatabaseOp;
3279
3280 RefPtr<DeleteDatabaseOp> mDeleteDatabaseOp;
3281
3282 private:
3283 explicit VersionChangeOp(DeleteDatabaseOp* aDeleteDatabaseOp)
3284 : DatabaseOperationBase(aDeleteDatabaseOp->BackgroundChildLoggingId(),
3285 aDeleteDatabaseOp->LoggingSerialNumber()),
3286 mDeleteDatabaseOp(aDeleteDatabaseOp) {
3287 MOZ_ASSERT(aDeleteDatabaseOp)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aDeleteDatabaseOp)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aDeleteDatabaseOp))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("aDeleteDatabaseOp"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3287); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDeleteDatabaseOp"
")"); do { *((volatile int*)__null) = 3287; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3288 MOZ_ASSERT(!aDeleteDatabaseOp->mDatabaseDirectoryPath.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!aDeleteDatabaseOp->mDatabaseDirectoryPath.IsEmpty
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(!aDeleteDatabaseOp->mDatabaseDirectoryPath.IsEmpty
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("!aDeleteDatabaseOp->mDatabaseDirectoryPath.IsEmpty()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3288); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aDeleteDatabaseOp->mDatabaseDirectoryPath.IsEmpty()"
")"); do { *((volatile int*)__null) = 3288; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3289 }
3290
3291 ~VersionChangeOp() override = default;
3292
3293 nsresult RunOnIOThread();
3294
3295 void RunOnOwningThread();
3296
3297 NS_DECL_NSIRUNNABLEvirtual nsresult Run(void) override;
3298};
3299
3300class GetDatabasesOp final : public FactoryOp {
3301 nsTHashMap<nsStringHashKey, DatabaseMetadata> mDatabaseMetadataTable;
3302 nsTArray<DatabaseMetadata> mDatabaseMetadataArray;
3303 Factory::GetDatabasesResolver mResolver;
3304
3305 public:
3306 GetDatabasesOp(SafeRefPtr<Factory> aFactory,
3307 const Maybe<ContentParentId>& aContentParentId,
3308 const PersistenceType aPersistenceType,
3309 const PrincipalInfo& aPrincipalInfo,
3310 Factory::GetDatabasesResolver&& aResolver)
3311 : FactoryOp(std::move(aFactory), aContentParentId, aPersistenceType,
3312 aPrincipalInfo, Nothing(), /* aDeleting */ false),
3313 mResolver(std::move(aResolver)) {}
3314
3315 private:
3316 ~GetDatabasesOp() override = default;
3317
3318 nsresult DatabasesNotAvailable();
3319
3320 nsresult DoDirectoryWork() override;
3321
3322 nsresult DatabaseOpen() override;
3323
3324 nsresult DoDatabaseWork() override;
3325
3326 nsresult BeginVersionChange() override;
3327
3328 bool AreActorsAlive() override;
3329
3330 void SendBlockedNotification() override;
3331
3332 nsresult DispatchToWorkThread() override;
3333
3334 void SendResults() override;
3335};
3336
3337class VersionChangeTransactionOp : public TransactionDatabaseOperationBase {
3338 public:
3339 void Cleanup() override;
3340
3341 protected:
3342 explicit VersionChangeTransactionOp(
3343 SafeRefPtr<VersionChangeTransaction> aTransaction)
3344 : TransactionDatabaseOperationBase(std::move(aTransaction),
3345 /* aRequestId */ 0) {}
3346
3347 ~VersionChangeTransactionOp() override = default;
3348
3349 private:
3350 nsresult SendSuccessResult() override;
3351
3352 bool SendFailureResult(nsresult aResultCode) override;
3353};
3354
3355class CreateObjectStoreOp final : public VersionChangeTransactionOp {
3356 friend class VersionChangeTransaction;
3357
3358 const ObjectStoreMetadata mMetadata;
3359
3360 private:
3361 // Only created by VersionChangeTransaction.
3362 CreateObjectStoreOp(SafeRefPtr<VersionChangeTransaction> aTransaction,
3363 const ObjectStoreMetadata& aMetadata)
3364 : VersionChangeTransactionOp(std::move(aTransaction)),
3365 mMetadata(aMetadata) {
3366 MOZ_ASSERT(aMetadata.id())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aMetadata.id())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aMetadata.id()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("aMetadata.id()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3366); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aMetadata.id()"
")"); do { *((volatile int*)__null) = 3366; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3367 }
3368
3369 ~CreateObjectStoreOp() override = default;
3370
3371 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3372};
3373
3374class DeleteObjectStoreOp final : public VersionChangeTransactionOp {
3375 friend class VersionChangeTransaction;
3376
3377 const SafeRefPtr<FullObjectStoreMetadata> mMetadata;
3378 const bool mIsLastObjectStore;
3379
3380 private:
3381 // Only created by VersionChangeTransaction.
3382 DeleteObjectStoreOp(SafeRefPtr<VersionChangeTransaction> aTransaction,
3383 SafeRefPtr<FullObjectStoreMetadata> aMetadata,
3384 const bool aIsLastObjectStore)
3385 : VersionChangeTransactionOp(std::move(aTransaction)),
3386 mMetadata(std::move(aMetadata)),
3387 mIsLastObjectStore(aIsLastObjectStore) {
3388 MOZ_ASSERT(mMetadata->mCommonMetadata.id())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mMetadata->mCommonMetadata.id())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mMetadata->mCommonMetadata
.id()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("mMetadata->mCommonMetadata.id()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3388); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mMetadata->mCommonMetadata.id()"
")"); do { *((volatile int*)__null) = 3388; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3389 }
3390
3391 ~DeleteObjectStoreOp() override = default;
3392
3393 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3394};
3395
3396class RenameObjectStoreOp final : public VersionChangeTransactionOp {
3397 friend class VersionChangeTransaction;
3398
3399 const int64_t mId;
3400 const nsString mNewName;
3401
3402 private:
3403 // Only created by VersionChangeTransaction.
3404 RenameObjectStoreOp(SafeRefPtr<VersionChangeTransaction> aTransaction,
3405 FullObjectStoreMetadata& aMetadata)
3406 : VersionChangeTransactionOp(std::move(aTransaction)),
3407 mId(aMetadata.mCommonMetadata.id()),
3408 mNewName(aMetadata.mCommonMetadata.name()) {
3409 MOZ_ASSERT(mId)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mId)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(mId))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("mId", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3409); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mId" ")"); do
{ *((volatile int*)__null) = 3409; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
3410 }
3411
3412 ~RenameObjectStoreOp() override = default;
3413
3414 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3415};
3416
3417class CreateIndexOp final : public VersionChangeTransactionOp {
3418 friend class VersionChangeTransaction;
3419
3420 class UpdateIndexDataValuesFunction;
3421
3422 const IndexMetadata mMetadata;
3423 Maybe<UniqueIndexTable> mMaybeUniqueIndexTable;
3424 const SafeRefPtr<DatabaseFileManager> mFileManager;
3425 const nsCString mDatabaseId;
3426 const IndexOrObjectStoreId mObjectStoreId;
3427
3428 private:
3429 // Only created by VersionChangeTransaction.
3430 CreateIndexOp(SafeRefPtr<VersionChangeTransaction> aTransaction,
3431 IndexOrObjectStoreId aObjectStoreId,
3432 const IndexMetadata& aMetadata);
3433
3434 ~CreateIndexOp() override = default;
3435
3436 nsresult InsertDataFromObjectStore(DatabaseConnection* aConnection);
3437
3438 nsresult InsertDataFromObjectStoreInternal(
3439 DatabaseConnection* aConnection) const;
3440
3441 bool Init(TransactionBase& aTransaction) override;
3442
3443 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3444};
3445
3446class CreateIndexOp::UpdateIndexDataValuesFunction final
3447 : public mozIStorageFunction {
3448 RefPtr<CreateIndexOp> mOp;
3449 RefPtr<DatabaseConnection> mConnection;
3450 const NotNull<SafeRefPtr<Database>> mDatabase;
3451
3452 public:
3453 UpdateIndexDataValuesFunction(CreateIndexOp* aOp,
3454 DatabaseConnection* aConnection,
3455 SafeRefPtr<Database> aDatabase)
3456 : mOp(aOp),
3457 mConnection(aConnection),
3458 mDatabase(WrapNotNull(std::move(aDatabase))) {
3459 MOZ_ASSERT(aOp)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aOp)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(aOp))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("aOp", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3459); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOp" ")"); do
{ *((volatile int*)__null) = 3459; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
3460 MOZ_ASSERT(aConnection)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aConnection)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aConnection))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aConnection", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3460); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aConnection"
")"); do { *((volatile int*)__null) = 3460; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3461 aConnection->AssertIsOnConnectionThread();
3462 }
3463
3464 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:
3465
3466 private:
3467 ~UpdateIndexDataValuesFunction() = default;
3468
3469 NS_DECL_MOZISTORAGEFUNCTIONvirtual nsresult OnFunctionCall(mozIStorageValueArray *aFunctionArguments
, nsIVariant **_retval) override;
3470};
3471
3472class DeleteIndexOp final : public VersionChangeTransactionOp {
3473 friend class VersionChangeTransaction;
3474
3475 const IndexOrObjectStoreId mObjectStoreId;
3476 const IndexOrObjectStoreId mIndexId;
3477 const bool mUnique;
3478 const bool mIsLastIndex;
3479
3480 private:
3481 // Only created by VersionChangeTransaction.
3482 DeleteIndexOp(SafeRefPtr<VersionChangeTransaction> aTransaction,
3483 IndexOrObjectStoreId aObjectStoreId,
3484 IndexOrObjectStoreId aIndexId, const bool aUnique,
3485 const bool aIsLastIndex);
3486
3487 ~DeleteIndexOp() override = default;
3488
3489 nsresult RemoveReferencesToIndex(
3490 DatabaseConnection* aConnection, const Key& aObjectDataKey,
3491 nsTArray<IndexDataValue>& aIndexValues) const;
3492
3493 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3494};
3495
3496class RenameIndexOp final : public VersionChangeTransactionOp {
3497 friend class VersionChangeTransaction;
3498
3499 const IndexOrObjectStoreId mObjectStoreId;
3500 const IndexOrObjectStoreId mIndexId;
3501 const nsString mNewName;
3502
3503 private:
3504 // Only created by VersionChangeTransaction.
3505 RenameIndexOp(SafeRefPtr<VersionChangeTransaction> aTransaction,
3506 FullIndexMetadata& aMetadata,
3507 IndexOrObjectStoreId aObjectStoreId)
3508 : VersionChangeTransactionOp(std::move(aTransaction)),
3509 mObjectStoreId(aObjectStoreId),
3510 mIndexId(aMetadata.mCommonMetadata.id()),
3511 mNewName(aMetadata.mCommonMetadata.name()) {
3512 MOZ_ASSERT(mIndexId)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mIndexId)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mIndexId))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("mIndexId", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3512); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mIndexId" ")"
); do { *((volatile int*)__null) = 3512; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3513 }
3514
3515 ~RenameIndexOp() override = default;
3516
3517 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3518};
3519
3520class NormalTransactionOp : public TransactionDatabaseOperationBase,
3521 public PBackgroundIDBRequestParent {
3522#ifdef DEBUG1
3523 bool mResponseSent;
3524#endif
3525
3526 public:
3527 void Cleanup() override;
3528
3529 protected:
3530 NormalTransactionOp(SafeRefPtr<TransactionBase> aTransaction,
3531 const int64_t aRequestId)
3532 : TransactionDatabaseOperationBase(std::move(aTransaction), aRequestId)
3533#ifdef DEBUG1
3534 ,
3535 mResponseSent(false)
3536#endif
3537 {
3538 }
3539
3540 ~NormalTransactionOp() override = default;
3541
3542 // An overload of DatabaseOperationBase's function that can avoid doing extra
3543 // work on non-versionchange transactions.
3544 mozilla::Result<bool, nsresult> ObjectStoreHasIndexes(
3545 DatabaseConnection& aConnection, IndexOrObjectStoreId aObjectStoreId,
3546 bool aMayHaveIndexes);
3547
3548 virtual mozilla::Result<PreprocessParams, nsresult> GetPreprocessParams();
3549
3550 // Subclasses use this override to set the IPDL response value.
3551 virtual void GetResponse(RequestResponse& aResponse,
3552 size_t* aResponseSize) = 0;
3553
3554 private:
3555 nsresult SendPreprocessInfo() override;
3556
3557 nsresult SendSuccessResult() override;
3558
3559 bool SendFailureResult(nsresult aResultCode) override;
3560
3561 // IPDL methods.
3562 void ActorDestroy(ActorDestroyReason aWhy) override;
3563
3564 mozilla::ipc::IPCResult RecvContinue(
3565 const PreprocessResponse& aResponse) final;
3566};
3567
3568class ObjectStoreAddOrPutRequestOp final : public NormalTransactionOp {
3569 friend class TransactionBase;
3570
3571 using PersistenceType = mozilla::dom::quota::PersistenceType;
3572
3573 class StoredFileInfo final {
3574 InitializedOnce<const NotNull<SafeRefPtr<DatabaseFileInfo>>> mFileInfo;
3575 // Either nothing, a file actor or a non-Blob-backed inputstream to write to
3576 // disk.
3577 using FileActorOrInputStream =
3578 Variant<Nothing, RefPtr<DatabaseFile>, nsCOMPtr<nsIInputStream>>;
3579 InitializedOnce<const FileActorOrInputStream> mFileActorOrInputStream;
3580#ifdef DEBUG1
3581 const StructuredCloneFileBase::FileType mType;
3582#endif
3583 void EnsureCipherKey();
3584 void AssertInvariants() const;
3585
3586 StoredFileInfo(SafeRefPtr<DatabaseFileInfo> aFileInfo,
3587 RefPtr<DatabaseFile> aFileActor);
3588
3589 StoredFileInfo(SafeRefPtr<DatabaseFileInfo> aFileInfo,
3590 nsCOMPtr<nsIInputStream> aInputStream);
3591
3592 public:
3593#if defined(NS_BUILD_REFCNT_LOGGING1)
3594 // Only for MOZ_COUNT_CTOR.
3595 StoredFileInfo(StoredFileInfo&& aOther)
3596 : mFileInfo{std::move(aOther.mFileInfo)},
3597 mFileActorOrInputStream{std::move(aOther.mFileActorOrInputStream)}
3598# ifdef DEBUG1
3599 ,
3600 mType{aOther.mType}
3601# endif
3602 {
3603 MOZ_COUNT_CTOR(ObjectStoreAddOrPutRequestOp::StoredFileInfo)do { static_assert(std::is_class_v<ObjectStoreAddOrPutRequestOp
::StoredFileInfo>, "Token '" "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, ObjectStoreAddOrPutRequestOp::StoredFileInfo>
::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
, sizeof(*this)); } while (0)
;
3604 }
3605#else
3606 StoredFileInfo(StoredFileInfo&&) = default;
3607#endif
3608
3609 static StoredFileInfo CreateForBlob(SafeRefPtr<DatabaseFileInfo> aFileInfo,
3610 RefPtr<DatabaseFile> aFileActor);
3611 static StoredFileInfo CreateForStructuredClone(
3612 SafeRefPtr<DatabaseFileInfo> aFileInfo,
3613 nsCOMPtr<nsIInputStream> aInputStream);
3614
3615#if defined(DEBUG1) || defined(NS_BUILD_REFCNT_LOGGING1)
3616 ~StoredFileInfo() {
3617 AssertIsOnBackgroundThread();
3618 AssertInvariants();
3619
3620 MOZ_COUNT_DTOR(ObjectStoreAddOrPutRequestOp::StoredFileInfo)do { static_assert(std::is_class_v<ObjectStoreAddOrPutRequestOp
::StoredFileInfo>, "Token '" "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, ObjectStoreAddOrPutRequestOp::StoredFileInfo>
::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogDtor((void*)this, "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
, sizeof(*this)); } while (0)
;
3621 }
3622#endif
3623
3624 bool IsValid() const { return static_cast<bool>(mFileInfo); }
3625
3626 const DatabaseFileInfo& GetFileInfo() const { return **mFileInfo; }
3627
3628 bool ShouldCompress() const;
3629
3630 void NotifyWriteSucceeded() const;
3631
3632 using InputStreamResult =
3633 mozilla::Result<nsCOMPtr<nsIInputStream>, nsresult>;
3634 InputStreamResult GetInputStream();
3635
3636 void Serialize(nsString& aText) const;
3637 };
3638 class SCInputStream;
3639
3640 ObjectStoreAddPutParams mParams;
3641 Maybe<UniqueIndexTable> mUniqueIndexTable;
3642
3643 // This must be non-const so that we can update the mNextAutoIncrementId field
3644 // if we are modifying an autoIncrement objectStore.
3645 SafeRefPtr<FullObjectStoreMetadata> mMetadata;
3646
3647 nsTArray<StoredFileInfo> mStoredFileInfos;
3648
3649 Key mResponse;
3650 const OriginMetadata mOriginMetadata;
3651 const PersistenceType mPersistenceType;
3652 const bool mOverwrite;
3653 bool mObjectStoreMayHaveIndexes;
3654 bool mDataOverThreshold;
3655
3656 private:
3657 // Only created by TransactionBase.
3658 ObjectStoreAddOrPutRequestOp(SafeRefPtr<TransactionBase> aTransaction,
3659 const int64_t aRequestId,
3660 RequestParams&& aParams);
3661
3662 ~ObjectStoreAddOrPutRequestOp() override = default;
3663
3664 nsresult RemoveOldIndexDataValues(DatabaseConnection* aConnection);
3665
3666 bool Init(TransactionBase& aTransaction) override;
3667
3668 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3669
3670 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override;
3671
3672 void Cleanup() override;
3673};
3674
3675void ObjectStoreAddOrPutRequestOp::StoredFileInfo::AssertInvariants() const {
3676 // The only allowed types are eStructuredClone, eBlob and eMutableFile.
3677 MOZ_ASSERT(StructuredCloneFileBase::eStructuredClone == mType ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(StructuredCloneFileBase::eStructuredClone == mType ||
StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase
::eMutableFile == mType)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(StructuredCloneFileBase::eStructuredClone
== mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase
::eMutableFile == mType))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("StructuredCloneFileBase::eStructuredClone == mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase::eMutableFile == mType"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3679); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StructuredCloneFileBase::eStructuredClone == mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase::eMutableFile == mType"
")"); do { *((volatile int*)__null) = 3679; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
3678 StructuredCloneFileBase::eBlob == mType ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(StructuredCloneFileBase::eStructuredClone == mType ||
StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase
::eMutableFile == mType)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(StructuredCloneFileBase::eStructuredClone
== mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase
::eMutableFile == mType))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("StructuredCloneFileBase::eStructuredClone == mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase::eMutableFile == mType"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3679); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StructuredCloneFileBase::eStructuredClone == mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase::eMutableFile == mType"
")"); do { *((volatile int*)__null) = 3679; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
3679 StructuredCloneFileBase::eMutableFile == mType)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(StructuredCloneFileBase::eStructuredClone == mType ||
StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase
::eMutableFile == mType)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(StructuredCloneFileBase::eStructuredClone
== mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase
::eMutableFile == mType))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("StructuredCloneFileBase::eStructuredClone == mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase::eMutableFile == mType"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3679); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StructuredCloneFileBase::eStructuredClone == mType || StructuredCloneFileBase::eBlob == mType || StructuredCloneFileBase::eMutableFile == mType"
")"); do { *((volatile int*)__null) = 3679; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3680
3681 // mFileInfo and a file actor in mFileActorOrInputStream are present until
3682 // the object is moved away, but an inputStream in mFileActorOrInputStream
3683 // can be released early.
3684 MOZ_ASSERT_IF(static_cast<bool>(mFileActorOrInputStream) &&do { if (static_cast<bool>(mFileActorOrInputStream) &&
mFileActorOrInputStream->is<RefPtr<DatabaseFile>>
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(static_cast<bool>(mFileInfo))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(static_cast<bool>(mFileInfo)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("static_cast<bool>(mFileInfo)"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3686); AnnotateMozCrashReason("MOZ_ASSERT" "(" "static_cast<bool>(mFileInfo)"
")"); do { *((volatile int*)__null) = 3686; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3685 mFileActorOrInputStream->is<RefPtr<DatabaseFile>>(),do { if (static_cast<bool>(mFileActorOrInputStream) &&
mFileActorOrInputStream->is<RefPtr<DatabaseFile>>
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(static_cast<bool>(mFileInfo))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(static_cast<bool>(mFileInfo)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("static_cast<bool>(mFileInfo)"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3686); AnnotateMozCrashReason("MOZ_ASSERT" "(" "static_cast<bool>(mFileInfo)"
")"); do { *((volatile int*)__null) = 3686; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3686 static_cast<bool>(mFileInfo))do { if (static_cast<bool>(mFileActorOrInputStream) &&
mFileActorOrInputStream->is<RefPtr<DatabaseFile>>
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(static_cast<bool>(mFileInfo))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(static_cast<bool>(mFileInfo)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("static_cast<bool>(mFileInfo)"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3686); AnnotateMozCrashReason("MOZ_ASSERT" "(" "static_cast<bool>(mFileInfo)"
")"); do { *((volatile int*)__null) = 3686; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3687
3688 if (mFileInfo) {
3689 // In a non-moved StoredFileInfo, one of the following is true:
3690 // - This was an overflow structured clone (eStructuredClone) and
3691 // storedFileInfo.mFileActorOrInputStream CAN be a non-nullptr input
3692 // stream (but that might have been release by ReleaseInputStream).
3693 MOZ_ASSERT_IF(do { if (StructuredCloneFileBase::eStructuredClone == mType) {
do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mFileActorOrInputStream || (mFileActorOrInputStream
->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>()))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(!mFileActorOrInputStream || (mFileActorOrInputStream->is
<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>())))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3697); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
")"); do { *((volatile int*)__null) = 3697; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3694 StructuredCloneFileBase::eStructuredClone == mType,do { if (StructuredCloneFileBase::eStructuredClone == mType) {
do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mFileActorOrInputStream || (mFileActorOrInputStream
->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>()))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(!mFileActorOrInputStream || (mFileActorOrInputStream->is
<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>())))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3697); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
")"); do { *((volatile int*)__null) = 3697; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3695 !mFileActorOrInputStream ||do { if (StructuredCloneFileBase::eStructuredClone == mType) {
do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mFileActorOrInputStream || (mFileActorOrInputStream
->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>()))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(!mFileActorOrInputStream || (mFileActorOrInputStream->is
<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>())))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3697); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
")"); do { *((volatile int*)__null) = 3697; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3696 (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() &&do { if (StructuredCloneFileBase::eStructuredClone == mType) {
do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mFileActorOrInputStream || (mFileActorOrInputStream
->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>()))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(!mFileActorOrInputStream || (mFileActorOrInputStream->is
<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>())))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3697); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
")"); do { *((volatile int*)__null) = 3697; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3697 mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>()))do { if (StructuredCloneFileBase::eStructuredClone == mType) {
do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mFileActorOrInputStream || (mFileActorOrInputStream
->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>()))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(!mFileActorOrInputStream || (mFileActorOrInputStream->is
<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream
->as<nsCOMPtr<nsIInputStream>>())))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3697); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mFileActorOrInputStream || (mFileActorOrInputStream->is<nsCOMPtr<nsIInputStream>>() && mFileActorOrInputStream->as<nsCOMPtr<nsIInputStream>>())"
")"); do { *((volatile int*)__null) = 3697; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3698
3699 // - This is a reference to a Blob (eBlob) that may or may not have
3700 // already been written to disk. storedFileInfo.mFileActorOrInputStream
3701 // MUST be a non-null file actor, but its GetInputStream may return
3702 // nullptr (so don't assert on that).
3703 MOZ_ASSERT_IF(StructuredCloneFileBase::eBlob == mType,do { if (StructuredCloneFileBase::eBlob == mType) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(mFileActorOrInputStream
->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream
->as<RefPtr<DatabaseFile>>())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mFileActorOrInputStream->
is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream
->as<RefPtr<DatabaseFile>>()))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()"
")"); do { *((volatile int*)__null) = 3705; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3704 mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() &&do { if (StructuredCloneFileBase::eBlob == mType) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(mFileActorOrInputStream
->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream
->as<RefPtr<DatabaseFile>>())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mFileActorOrInputStream->
is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream
->as<RefPtr<DatabaseFile>>()))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()"
")"); do { *((volatile int*)__null) = 3705; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3705 mFileActorOrInputStream->as<RefPtr<DatabaseFile>>())do { if (StructuredCloneFileBase::eBlob == mType) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(mFileActorOrInputStream
->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream
->as<RefPtr<DatabaseFile>>())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mFileActorOrInputStream->
is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream
->as<RefPtr<DatabaseFile>>()))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileActorOrInputStream->is<RefPtr<DatabaseFile>>() && mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()"
")"); do { *((volatile int*)__null) = 3705; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3706
3707 // - It's a mutable file (eMutableFile). No writing will be performed,
3708 // and storedFileInfo.mFileActorOrInputStream is Nothing.
3709 MOZ_ASSERT_IF(StructuredCloneFileBase::eMutableFile == mType,do { if (StructuredCloneFileBase::eMutableFile == mType) { do
{ static_assert( mozilla::detail::AssertionConditionType<
decltype(mFileActorOrInputStream->is<Nothing>())>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(mFileActorOrInputStream->is<Nothing>()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mFileActorOrInputStream->is<Nothing>()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3710); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileActorOrInputStream->is<Nothing>()"
")"); do { *((volatile int*)__null) = 3710; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
3710 mFileActorOrInputStream->is<Nothing>())do { if (StructuredCloneFileBase::eMutableFile == mType) { do
{ static_assert( mozilla::detail::AssertionConditionType<
decltype(mFileActorOrInputStream->is<Nothing>())>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(mFileActorOrInputStream->is<Nothing>()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mFileActorOrInputStream->is<Nothing>()"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3710); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFileActorOrInputStream->is<Nothing>()"
")"); do { *((volatile int*)__null) = 3710; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3711 }
3712}
3713
3714void ObjectStoreAddOrPutRequestOp::StoredFileInfo::EnsureCipherKey() {
3715 const auto& fileInfo = GetFileInfo();
3716 const auto& fileManager = fileInfo.Manager();
3717
3718 // No need to generate cipher keys if we are not in PBM
3719 if (!fileManager.IsInPrivateBrowsingMode()) {
3720 return;
3721 }
3722
3723 nsCString keyId;
3724 keyId.AppendInt(fileInfo.Id());
3725
3726 fileManager.MutableCipherKeyManagerRef().Ensure(keyId);
3727}
3728
3729ObjectStoreAddOrPutRequestOp::StoredFileInfo::StoredFileInfo(
3730 SafeRefPtr<DatabaseFileInfo> aFileInfo, RefPtr<DatabaseFile> aFileActor)
3731 : mFileInfo{WrapNotNull(std::move(aFileInfo))},
3732 mFileActorOrInputStream{std::move(aFileActor)}
3733#ifdef DEBUG1
3734 ,
3735 mType{StructuredCloneFileBase::eBlob}
3736#endif
3737{
3738 AssertIsOnBackgroundThread();
3739 AssertInvariants();
3740
3741 EnsureCipherKey();
3742 MOZ_COUNT_CTOR(ObjectStoreAddOrPutRequestOp::StoredFileInfo)do { static_assert(std::is_class_v<ObjectStoreAddOrPutRequestOp
::StoredFileInfo>, "Token '" "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, ObjectStoreAddOrPutRequestOp::StoredFileInfo>
::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
, sizeof(*this)); } while (0)
;
3743}
3744
3745ObjectStoreAddOrPutRequestOp::StoredFileInfo::StoredFileInfo(
3746 SafeRefPtr<DatabaseFileInfo> aFileInfo,
3747 nsCOMPtr<nsIInputStream> aInputStream)
3748 : mFileInfo{WrapNotNull(std::move(aFileInfo))},
3749 mFileActorOrInputStream{std::move(aInputStream)}
3750#ifdef DEBUG1
3751 ,
3752 mType{StructuredCloneFileBase::eStructuredClone}
3753#endif
3754{
3755 AssertIsOnBackgroundThread();
3756 AssertInvariants();
3757
3758 EnsureCipherKey();
3759 MOZ_COUNT_CTOR(ObjectStoreAddOrPutRequestOp::StoredFileInfo)do { static_assert(std::is_class_v<ObjectStoreAddOrPutRequestOp
::StoredFileInfo>, "Token '" "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
"' is not a class type."); static_assert(!std::is_base_of<
nsISupports, ObjectStoreAddOrPutRequestOp::StoredFileInfo>
::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "ObjectStoreAddOrPutRequestOp::StoredFileInfo"
, sizeof(*this)); } while (0)
;
3760}
3761
3762ObjectStoreAddOrPutRequestOp::StoredFileInfo
3763ObjectStoreAddOrPutRequestOp::StoredFileInfo::CreateForBlob(
3764 SafeRefPtr<DatabaseFileInfo> aFileInfo, RefPtr<DatabaseFile> aFileActor) {
3765 return {std::move(aFileInfo), std::move(aFileActor)};
3766}
3767
3768ObjectStoreAddOrPutRequestOp::StoredFileInfo
3769ObjectStoreAddOrPutRequestOp::StoredFileInfo::CreateForStructuredClone(
3770 SafeRefPtr<DatabaseFileInfo> aFileInfo,
3771 nsCOMPtr<nsIInputStream> aInputStream) {
3772 return {std::move(aFileInfo), std::move(aInputStream)};
3773}
3774
3775bool ObjectStoreAddOrPutRequestOp::StoredFileInfo::ShouldCompress() const {
3776 // Must not be called after moving.
3777 MOZ_ASSERT(IsValid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsValid())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsValid()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("IsValid()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3777); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsValid()" ")"
); do { *((volatile int*)__null) = 3777; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3778
3779 // Compression is only necessary for eStructuredClone, i.e. when
3780 // mFileActorOrInputStream stored an input stream. However, this is only
3781 // called after GetInputStream, when mFileActorOrInputStream has been
3782 // cleared, which is only possible for this type.
3783 const bool res = !mFileActorOrInputStream;
3784 MOZ_ASSERT(res == (StructuredCloneFileBase::eStructuredClone == mType))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(res == (StructuredCloneFileBase::eStructuredClone ==
mType))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(res == (StructuredCloneFileBase::eStructuredClone ==
mType)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("res == (StructuredCloneFileBase::eStructuredClone == mType)"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3784); AnnotateMozCrashReason("MOZ_ASSERT" "(" "res == (StructuredCloneFileBase::eStructuredClone == mType)"
")"); do { *((volatile int*)__null) = 3784; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3785 return res;
3786}
3787
3788void ObjectStoreAddOrPutRequestOp::StoredFileInfo::NotifyWriteSucceeded()
3789 const {
3790 MOZ_ASSERT(IsValid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsValid())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsValid()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("IsValid()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3790); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsValid()" ")"
); do { *((volatile int*)__null) = 3790; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3791
3792 // For eBlob, clear the blob implementation.
3793 if (mFileActorOrInputStream &&
3794 mFileActorOrInputStream->is<RefPtr<DatabaseFile>>()) {
3795 mFileActorOrInputStream->as<RefPtr<DatabaseFile>>()
3796 ->WriteSucceededClearBlobImpl();
3797 }
3798
3799 // For the other types, no action is necessary.
3800}
3801
3802ObjectStoreAddOrPutRequestOp::StoredFileInfo::InputStreamResult
3803ObjectStoreAddOrPutRequestOp::StoredFileInfo::GetInputStream() {
3804 if (!mFileActorOrInputStream) {
3805 MOZ_ASSERT(StructuredCloneFileBase::eStructuredClone == mType)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(StructuredCloneFileBase::eStructuredClone == mType)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(StructuredCloneFileBase::eStructuredClone == mType))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("StructuredCloneFileBase::eStructuredClone == mType"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3805); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StructuredCloneFileBase::eStructuredClone == mType"
")"); do { *((volatile int*)__null) = 3805; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3806 return nsCOMPtr<nsIInputStream>{};
3807 }
3808
3809 // For the different cases, see also the comments in AssertInvariants.
3810 return mFileActorOrInputStream->match(
3811 [](const Nothing&) -> InputStreamResult {
3812 return nsCOMPtr<nsIInputStream>{};
3813 },
3814 [](const RefPtr<DatabaseFile>& databaseActor) -> InputStreamResult {
3815 ErrorResult rv;
3816 auto inputStream = databaseActor->GetInputStream(rv);
3817 if (NS_WARN_IF(rv.Failed())NS_warn_if_impl(rv.Failed(), "rv.Failed()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3817)
) {
3818 return Err(rv.StealNSResult());
3819 }
3820
3821 return inputStream;
3822 },
3823 [this](const nsCOMPtr<nsIInputStream>& inputStream) -> InputStreamResult {
3824 auto res = inputStream;
3825 // destroy() clears the inputStream parameter, so we needed to make a
3826 // copy before
3827 mFileActorOrInputStream.destroy();
3828 AssertInvariants();
3829 return res;
3830 });
3831}
3832
3833void ObjectStoreAddOrPutRequestOp::StoredFileInfo::Serialize(
3834 nsString& aText) const {
3835 AssertInvariants();
3836 MOZ_ASSERT(IsValid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsValid())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsValid()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("IsValid()", "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 3836); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsValid()" ")"
); do { *((volatile int*)__null) = 3836; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3837
3838 const int64_t id = (*mFileInfo)->Id();
3839
3840 auto structuredCloneHandler = [&aText, id](const nsCOMPtr<nsIInputStream>&) {
3841 // eStructuredClone
3842 aText.Append('.');
3843 aText.AppendInt(id);
3844 };
3845
3846 // If mFileActorOrInputStream was moved, we had an inputStream before.
3847 if (!mFileActorOrInputStream) {
3848 structuredCloneHandler(nullptr);
3849 return;
3850 }
3851
3852 // This encoding is parsed in DeserializeStructuredCloneFile.
3853 mFileActorOrInputStream->match(
3854 [&aText, id](const Nothing&) {
3855 // eMutableFile
3856 aText.AppendInt(-id);
3857 },
3858 [&aText, id](const RefPtr<DatabaseFile>&) {
3859 // eBlob
3860 aText.AppendInt(id);
3861 },
3862 structuredCloneHandler);
3863}
3864
3865class ObjectStoreAddOrPutRequestOp::SCInputStream final
3866 : public nsIInputStream {
3867 const JSStructuredCloneData& mData;
3868 JSStructuredCloneData::Iterator mIter;
3869
3870 public:
3871 explicit SCInputStream(const JSStructuredCloneData& aData)
3872 : mData(aData), mIter(aData.Start()) {}
3873
3874 private:
3875 virtual ~SCInputStream() = default;
3876
3877 NS_DECL_THREADSAFE_ISUPPORTSpublic: virtual nsresult QueryInterface(const nsIID& aIID
, void** aInstancePtr) override; virtual MozExternalRefCountType
AddRef(void) override; virtual MozExternalRefCountType Release
(void) override; using HasThreadSafeRefCnt = std::true_type; protected
: ::mozilla::ThreadSafeAutoRefCnt mRefCnt; nsAutoOwningThread
_mOwningThread; public:
3878 NS_DECL_NSIINPUTSTREAMvirtual nsresult Close(void) override; virtual nsresult Available
(uint64_t *_retval) override; virtual nsresult StreamStatus(void
) override; virtual nsresult Read(char * aBuf, uint32_t aCount
, uint32_t *_retval) override; virtual nsresult ReadSegments(
nsWriteSegmentFun aWriter, void * aClosure, uint32_t aCount, uint32_t
*_retval) override; virtual nsresult IsNonBlocking(bool *_retval
) override;
3879};
3880
3881class ObjectStoreGetRequestOp final : public NormalTransactionOp {
3882 friend class TransactionBase;
3883
3884 const IndexOrObjectStoreId mObjectStoreId;
3885 SafeRefPtr<Database> mDatabase;
3886 const Maybe<SerializedKeyRange> mOptionalKeyRange;
3887 AutoTArray<StructuredCloneReadInfoParent, 1> mResponse;
3888 PBackgroundParent* mBackgroundParent;
3889 uint32_t mPreprocessInfoCount;
3890 const uint32_t mLimit;
3891 const bool mGetAll;
3892
3893 private:
3894 // Only created by TransactionBase.
3895 ObjectStoreGetRequestOp(SafeRefPtr<TransactionBase> aTransaction,
3896 const int64_t aRequestId,
3897 const RequestParams& aParams, bool aGetAll);
3898
3899 ~ObjectStoreGetRequestOp() override = default;
3900
3901 template <typename T>
3902 mozilla::Result<T, nsresult> ConvertResponse(
3903 StructuredCloneReadInfoParent&& aInfo);
3904
3905 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3906
3907 bool HasPreprocessInfo() override;
3908
3909 mozilla::Result<PreprocessParams, nsresult> GetPreprocessParams() override;
3910
3911 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override;
3912};
3913
3914class ObjectStoreGetKeyRequestOp final : public NormalTransactionOp {
3915 friend class TransactionBase;
3916
3917 const IndexOrObjectStoreId mObjectStoreId;
3918 const Maybe<SerializedKeyRange> mOptionalKeyRange;
3919 const uint32_t mLimit;
3920 const bool mGetAll;
3921 nsTArray<Key> mResponse;
3922
3923 private:
3924 // Only created by TransactionBase.
3925 ObjectStoreGetKeyRequestOp(SafeRefPtr<TransactionBase> aTransaction,
3926 const int64_t aRequestId,
3927 const RequestParams& aParams, bool aGetAll);
3928
3929 ~ObjectStoreGetKeyRequestOp() override = default;
3930
3931 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3932
3933 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override;
3934};
3935
3936class ObjectStoreDeleteRequestOp final : public NormalTransactionOp {
3937 friend class TransactionBase;
3938
3939 const ObjectStoreDeleteParams mParams;
3940 ObjectStoreDeleteResponse mResponse;
3941 bool mObjectStoreMayHaveIndexes;
3942
3943 private:
3944 ObjectStoreDeleteRequestOp(SafeRefPtr<TransactionBase> aTransaction,
3945 const int64_t aRequestId,
3946 const ObjectStoreDeleteParams& aParams);
3947
3948 ~ObjectStoreDeleteRequestOp() override = default;
3949
3950 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3951
3952 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override {
3953 aResponse = std::move(mResponse);
3954 *aResponseSize = 0;
3955 }
3956};
3957
3958class ObjectStoreClearRequestOp final : public NormalTransactionOp {
3959 friend class TransactionBase;
3960
3961 const ObjectStoreClearParams mParams;
3962 ObjectStoreClearResponse mResponse;
3963 bool mObjectStoreMayHaveIndexes;
3964
3965 private:
3966 ObjectStoreClearRequestOp(SafeRefPtr<TransactionBase> aTransaction,
3967 const int64_t aRequestId,
3968 const ObjectStoreClearParams& aParams);
3969
3970 ~ObjectStoreClearRequestOp() override = default;
3971
3972 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3973
3974 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override {
3975 aResponse = std::move(mResponse);
3976 *aResponseSize = 0;
3977 }
3978};
3979
3980class ObjectStoreCountRequestOp final : public NormalTransactionOp {
3981 friend class TransactionBase;
3982
3983 const ObjectStoreCountParams mParams;
3984 ObjectStoreCountResponse mResponse;
3985
3986 private:
3987 ObjectStoreCountRequestOp(SafeRefPtr<TransactionBase> aTransaction,
3988 const int64_t aRequestId,
3989 const ObjectStoreCountParams& aParams)
3990 : NormalTransactionOp(std::move(aTransaction), aRequestId),
3991 mParams(aParams) {}
3992
3993 ~ObjectStoreCountRequestOp() override = default;
3994
3995 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
3996
3997 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override {
3998 aResponse = std::move(mResponse);
3999 *aResponseSize = sizeof(uint64_t);
4000 }
4001};
4002
4003class IndexRequestOpBase : public NormalTransactionOp {
4004 protected:
4005 const SafeRefPtr<FullIndexMetadata> mMetadata;
4006
4007 protected:
4008 IndexRequestOpBase(SafeRefPtr<TransactionBase> aTransaction,
4009 const int64_t aRequestId, const RequestParams& aParams)
4010 : NormalTransactionOp(std::move(aTransaction), aRequestId),
4011 mMetadata(IndexMetadataForParams(Transaction(), aParams)) {}
4012
4013 ~IndexRequestOpBase() override = default;
4014
4015 private:
4016 static SafeRefPtr<FullIndexMetadata> IndexMetadataForParams(
4017 const TransactionBase& aTransaction, const RequestParams& aParams);
4018};
4019
4020class IndexGetRequestOp final : public IndexRequestOpBase {
4021 friend class TransactionBase;
4022
4023 SafeRefPtr<Database> mDatabase;
4024 const Maybe<SerializedKeyRange> mOptionalKeyRange;
4025 AutoTArray<StructuredCloneReadInfoParent, 1> mResponse;
4026 PBackgroundParent* mBackgroundParent;
4027 const uint32_t mLimit;
4028 const bool mGetAll;
4029
4030 private:
4031 // Only created by TransactionBase.
4032 IndexGetRequestOp(SafeRefPtr<TransactionBase> aTransaction,
4033 const int64_t aRequestId, const RequestParams& aParams,
4034 bool aGetAll);
4035
4036 ~IndexGetRequestOp() override = default;
4037
4038 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
4039
4040 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override;
4041};
4042
4043class IndexGetKeyRequestOp final : public IndexRequestOpBase {
4044 friend class TransactionBase;
4045
4046 const Maybe<SerializedKeyRange> mOptionalKeyRange;
4047 AutoTArray<Key, 1> mResponse;
4048 const uint32_t mLimit;
4049 const bool mGetAll;
4050
4051 private:
4052 // Only created by TransactionBase.
4053 IndexGetKeyRequestOp(SafeRefPtr<TransactionBase> aTransaction,
4054 const int64_t aRequestId, const RequestParams& aParams,
4055 bool aGetAll);
4056
4057 ~IndexGetKeyRequestOp() override = default;
4058
4059 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
4060
4061 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override;
4062};
4063
4064class IndexCountRequestOp final : public IndexRequestOpBase {
4065 friend class TransactionBase;
4066
4067 const IndexCountParams mParams;
4068 IndexCountResponse mResponse;
4069
4070 private:
4071 // Only created by TransactionBase.
4072 IndexCountRequestOp(SafeRefPtr<TransactionBase> aTransaction,
4073 const int64_t aRequestId, const RequestParams& aParams)
4074 : IndexRequestOpBase(std::move(aTransaction), aRequestId, aParams),
4075 mParams(aParams.get_IndexCountParams()) {}
4076
4077 ~IndexCountRequestOp() override = default;
4078
4079 nsresult DoDatabaseWork(DatabaseConnection* aConnection) override;
4080
4081 void GetResponse(RequestResponse& aResponse, size_t* aResponseSize) override {
4082 aResponse = std::move(mResponse);
4083 *aResponseSize = sizeof(uint64_t);
4084 }
4085};
4086
4087template <IDBCursorType CursorType>
4088class Cursor;
4089
4090constexpr IDBCursorType ToKeyOnlyType(const IDBCursorType aType) {
4091 MOZ_ASSERT(aType == IDBCursorType::ObjectStore ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aType == IDBCursorType::ObjectStore || aType == IDBCursorType
::ObjectStoreKey || aType == IDBCursorType::Index || aType ==
IDBCursorType::IndexKey)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aType == IDBCursorType::ObjectStore
|| aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType
::Index || aType == IDBCursorType::IndexKey))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 4093); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
")"); do { *((volatile int*)__null) = 4093; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4092 aType == IDBCursorType::ObjectStoreKey ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aType == IDBCursorType::ObjectStore || aType == IDBCursorType
::ObjectStoreKey || aType == IDBCursorType::Index || aType ==
IDBCursorType::IndexKey)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aType == IDBCursorType::ObjectStore
|| aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType
::Index || aType == IDBCursorType::IndexKey))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 4093); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
")"); do { *((volatile int*)__null) = 4093; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4093 aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aType == IDBCursorType::ObjectStore || aType == IDBCursorType
::ObjectStoreKey || aType == IDBCursorType::Index || aType ==
IDBCursorType::IndexKey)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aType == IDBCursorType::ObjectStore
|| aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType
::Index || aType == IDBCursorType::IndexKey))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 4093); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
")"); do { *((volatile int*)__null) = 4093; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4094 switch (aType) {
4095 case IDBCursorType::ObjectStore:
4096 [[fallthrough]];
4097 case IDBCursorType::ObjectStoreKey:
4098 return IDBCursorType::ObjectStoreKey;
4099 case IDBCursorType::Index:
4100 [[fallthrough]];
4101 case IDBCursorType::IndexKey:
4102 return IDBCursorType::IndexKey;
4103 }
4104}
4105
4106template <IDBCursorType CursorType>
4107using CursorPosition = CursorData<ToKeyOnlyType(CursorType)>;
4108
4109#ifdef DEBUG1
4110constexpr indexedDB::OpenCursorParams::Type ToOpenCursorParamsType(
4111 const IDBCursorType aType) {
4112 MOZ_ASSERT(aType == IDBCursorType::ObjectStore ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aType == IDBCursorType::ObjectStore || aType == IDBCursorType
::ObjectStoreKey || aType == IDBCursorType::Index || aType ==
IDBCursorType::IndexKey)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aType == IDBCursorType::ObjectStore
|| aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType
::Index || aType == IDBCursorType::IndexKey))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 4114); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
")"); do { *((volatile int*)__null) = 4114; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4113 aType == IDBCursorType::ObjectStoreKey ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aType == IDBCursorType::ObjectStore || aType == IDBCursorType
::ObjectStoreKey || aType == IDBCursorType::Index || aType ==
IDBCursorType::IndexKey)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aType == IDBCursorType::ObjectStore
|| aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType
::Index || aType == IDBCursorType::IndexKey))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 4114); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
")"); do { *((volatile int*)__null) = 4114; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4114 aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aType == IDBCursorType::ObjectStore || aType == IDBCursorType
::ObjectStoreKey || aType == IDBCursorType::Index || aType ==
IDBCursorType::IndexKey)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aType == IDBCursorType::ObjectStore
|| aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType
::Index || aType == IDBCursorType::IndexKey))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
, "/var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB/ActorsParent.cpp"
, 4114); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aType == IDBCursorType::ObjectStore || aType == IDBCursorType::ObjectStoreKey || aType == IDBCursorType::Index || aType == IDBCursorType::IndexKey"
")"); do { *((volatile int*)__null) = 4114; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4115 switch (aType) {
4116 case IDBCursorType::ObjectStore:
4117 return indexedDB::OpenCursorParams::TObjectStoreOpenCursorParams;
4118 case IDBCursorType::ObjectStoreKey:
4119 return indexedDB::OpenCursorParams::TObjectStoreOpenKeyCursorParams;
4120 case IDBCursorType::Index:
4121