summaryrefslogtreecommitdiffstats
path: root/security/sandbox/chromium-shim/base/threading
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /security/sandbox/chromium-shim/base/threading
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'security/sandbox/chromium-shim/base/threading')
-rw-r--r--security/sandbox/chromium-shim/base/threading/platform_thread_linux.cpp69
-rw-r--r--security/sandbox/chromium-shim/base/threading/scoped_blocking_call.h47
2 files changed, 116 insertions, 0 deletions
diff --git a/security/sandbox/chromium-shim/base/threading/platform_thread_linux.cpp b/security/sandbox/chromium-shim/base/threading/platform_thread_linux.cpp
new file mode 100644
index 0000000000..aed65a06bd
--- /dev/null
+++ b/security/sandbox/chromium-shim/base/threading/platform_thread_linux.cpp
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// This is a cut down version of Chromium source file base/threading/platform_thread_linux.h
+// with only the functions required. It also has a dummy implementation of
+// SetCurrentThreadPriorityForPlatform, which should not be called.
+
+#include "base/threading/platform_thread.h"
+
+#include "base/threading/platform_thread_internal_posix.h"
+
+#include "mozilla/Assertions.h"
+
+namespace base {
+namespace internal {
+
+namespace {
+const struct sched_param kRealTimePrio = {8};
+} // namespace
+
+const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
+ {ThreadPriority::BACKGROUND, 10},
+ {ThreadPriority::NORMAL, 0},
+ {ThreadPriority::DISPLAY, -8},
+ {ThreadPriority::REALTIME_AUDIO, -10},
+};
+
+
+Optional<bool> CanIncreaseCurrentThreadPriorityForPlatform(
+ ThreadPriority priority) {
+ MOZ_CRASH();
+}
+
+bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
+ MOZ_CRASH();
+}
+
+Optional<ThreadPriority> GetCurrentThreadPriorityForPlatform() {
+ int maybe_sched_rr = 0;
+ struct sched_param maybe_realtime_prio = {0};
+ if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
+ &maybe_realtime_prio) == 0 &&
+ maybe_sched_rr == SCHED_RR &&
+ maybe_realtime_prio.sched_priority == kRealTimePrio.sched_priority) {
+ return base::make_optional(ThreadPriority::REALTIME_AUDIO);
+ }
+ return base::nullopt;
+}
+
+} // namespace internal
+
+void InitThreading() {}
+
+void TerminateOnThread() {}
+
+size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
+#if !defined(THREAD_SANITIZER)
+ return 0;
+#else
+ // ThreadSanitizer bloats the stack heavily. Evidence has been that the
+ // default stack size isn't enough for some browser tests.
+ return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux).
+#endif
+}
+
+} // namespace base
diff --git a/security/sandbox/chromium-shim/base/threading/scoped_blocking_call.h b/security/sandbox/chromium-shim/base/threading/scoped_blocking_call.h
new file mode 100644
index 0000000000..519850d34a
--- /dev/null
+++ b/security/sandbox/chromium-shim/base/threading/scoped_blocking_call.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// This is a dummy version of Chromium source file
+// base/threading/scoped_blocking_call.h
+// To provide to a dummy ScopedBlockingCall class. This prevents dependency
+// creep and we don't use the rest of the blocking call checking.
+
+#ifndef BASE_THREADING_SCOPED_BLOCKING_CALL_H
+#define BASE_THREADING_SCOPED_BLOCKING_CALL_H
+
+#include "base/base_export.h"
+#include "base/location.h"
+
+namespace base {
+
+enum class BlockingType {
+ // The call might block (e.g. file I/O that might hit in memory cache).
+ MAY_BLOCK,
+ // The call will definitely block (e.g. cache already checked and now pinging
+ // server synchronously).
+ WILL_BLOCK
+};
+
+class BASE_EXPORT ScopedBlockingCall {
+ public:
+ ScopedBlockingCall(const Location& from_here, BlockingType blocking_type) {};
+ ~ScopedBlockingCall() {};
+};
+
+namespace internal {
+
+class BASE_EXPORT ScopedBlockingCallWithBaseSyncPrimitives {
+ public:
+ ScopedBlockingCallWithBaseSyncPrimitives(const Location& from_here,
+ BlockingType blocking_type) {}
+ ~ScopedBlockingCallWithBaseSyncPrimitives() {};
+};
+
+} // namespace internal
+
+} // namespace base
+
+#endif // BASE_THREADING_SCOPED_BLOCKING_CALL_H