summaryrefslogtreecommitdiffstats
path: root/xpcom
diff options
context:
space:
mode:
Diffstat (limited to 'xpcom')
-rw-r--r--xpcom/base/CycleCollectedJSContext.cpp26
-rw-r--r--xpcom/base/ErrorList.h16
-rw-r--r--xpcom/base/nsCrashOnException.cpp11
-rw-r--r--xpcom/base/nsCycleCollector.cpp14
-rw-r--r--xpcom/base/nsCycleCollectorTraceJSHelpers.cpp2
-rw-r--r--xpcom/base/nsDebugImpl.cpp22
-rw-r--r--xpcom/base/nsObjCExceptions.h15
-rw-r--r--xpcom/build/XPCOMInit.cpp3
-rw-r--r--xpcom/build/nsXULAppAPI.h11
-rw-r--r--xpcom/glue/nsThreadUtils.cpp8
-rw-r--r--xpcom/io/SpecialSystemDirectory.cpp43
-rw-r--r--xpcom/io/SpecialSystemDirectory.h3
-rw-r--r--xpcom/io/nsLocalFileWin.cpp13
-rw-r--r--xpcom/moz.build1
-rw-r--r--xpcom/rust/nsstring/Cargo.toml8
-rw-r--r--xpcom/rust/nsstring/gtest/Cargo.toml12
-rw-r--r--xpcom/rust/nsstring/gtest/Test.cpp131
-rw-r--r--xpcom/rust/nsstring/gtest/moz.build12
-rw-r--r--xpcom/rust/nsstring/gtest/test.rs112
-rw-r--r--xpcom/rust/nsstring/src/lib.rs853
-rw-r--r--xpcom/system/moz.build5
-rw-r--r--xpcom/system/nsIXULRuntime.idl2
-rw-r--r--xpcom/tests/gtest/TestDeadlockDetector.cpp14
-rw-r--r--xpcom/tests/gtest/TestPLDHash.cpp15
-rw-r--r--xpcom/tests/gtest/TestSTLWrappers.cpp14
-rw-r--r--xpcom/threads/HangMonitor.cpp13
-rw-r--r--xpcom/threads/nsThread.cpp79
-rw-r--r--xpcom/threads/nsThread.h10
28 files changed, 23 insertions, 1445 deletions
diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp
index 87e123078..4af8fe4dd 100644
--- a/xpcom/base/CycleCollectedJSContext.cpp
+++ b/xpcom/base/CycleCollectedJSContext.cpp
@@ -82,10 +82,6 @@
#include "nsJSUtils.h"
#include "nsWrapperCache.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
-
#include "nsIException.h"
#include "nsIPlatformInfo.h"
#include "nsThread.h"
@@ -539,10 +535,6 @@ CycleCollectedJSContext::Initialize(JSContext* aParentContext,
JS_SetSweepZoneCallback(mJSContext, XPCStringConvert::ClearZoneCache);
JS::SetBuildIdOp(mJSContext, GetBuildId);
JS::SetWarningReporter(mJSContext, MozCrashWarningReporter);
-#ifdef MOZ_CRASHREPORTER
- js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback(
- CrashReporter::AnnotateOOMAllocationSize);
-#endif
static js::DOMCallbacks DOMcallbacks = {
InstanceClassHasProtoAtDepth
@@ -1607,16 +1599,6 @@ CycleCollectedJSContext::AnnotateAndSetOutOfMemory(OOMState* aStatePtr,
MOZ_ASSERT(mJSContext);
*aStatePtr = aNewState;
-#ifdef MOZ_CRASHREPORTER
- CrashReporter::AnnotateCrashReport(aStatePtr == &mOutOfMemoryState
- ? NS_LITERAL_CSTRING("JSOutOfMemory")
- : NS_LITERAL_CSTRING("JSLargeAllocationFailure"),
- aNewState == OOMState::Reporting
- ? NS_LITERAL_CSTRING("Reporting")
- : aNewState == OOMState::Reported
- ? NS_LITERAL_CSTRING("Reported")
- : NS_LITERAL_CSTRING("Recovered"));
-#endif
}
void
@@ -1630,14 +1612,6 @@ CycleCollectedJSContext::OnGC(JSGCStatus aStatus)
mZonesWaitingForGC.Clear();
break;
case JSGC_END: {
-#ifdef MOZ_CRASHREPORTER
- if (mOutOfMemoryState == OOMState::Reported) {
- AnnotateAndSetOutOfMemory(&mOutOfMemoryState, OOMState::Recovered);
- }
- if (mLargeAllocationFailureState == OOMState::Reported) {
- AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Recovered);
- }
-#endif
// Do any deferred finalization of native objects.
FinalizeDeferredThings(JS::WasIncrementalGC(mJSContext) ? FinalizeIncrementally :
diff --git a/xpcom/base/ErrorList.h b/xpcom/base/ErrorList.h
index cfa461fe4..5ab4bfa29 100644
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -327,13 +327,15 @@
ERROR(NS_NET_STATUS_WRITING, FAILURE(9)),
/* nsISocketTransport */
- ERROR(NS_NET_STATUS_RESOLVING_HOST, FAILURE(3)),
- ERROR(NS_NET_STATUS_RESOLVED_HOST, FAILURE(11)),
- ERROR(NS_NET_STATUS_CONNECTING_TO, FAILURE(7)),
- ERROR(NS_NET_STATUS_CONNECTED_TO, FAILURE(4)),
- ERROR(NS_NET_STATUS_SENDING_TO, FAILURE(5)),
- ERROR(NS_NET_STATUS_WAITING_FOR, FAILURE(10)),
- ERROR(NS_NET_STATUS_RECEIVING_FROM, FAILURE(6)),
+ ERROR(NS_NET_STATUS_RESOLVING_HOST, FAILURE(3)),
+ ERROR(NS_NET_STATUS_RESOLVED_HOST, FAILURE(11)),
+ ERROR(NS_NET_STATUS_CONNECTING_TO, FAILURE(7)),
+ ERROR(NS_NET_STATUS_CONNECTED_TO, FAILURE(4)),
+ ERROR(NS_NET_STATUS_TLS_HANDSHAKE_STARTING, FAILURE(12)),
+ ERROR(NS_NET_STATUS_TLS_HANDSHAKE_ENDED, FAILURE(13)),
+ ERROR(NS_NET_STATUS_SENDING_TO, FAILURE(5)),
+ ERROR(NS_NET_STATUS_WAITING_FOR, FAILURE(10)),
+ ERROR(NS_NET_STATUS_RECEIVING_FROM, FAILURE(6)),
/* nsIInterceptedChannel */
/* Generic error for non-specific failures during service worker interception */
diff --git a/xpcom/base/nsCrashOnException.cpp b/xpcom/base/nsCrashOnException.cpp
index 0f8042531..06c48738f 100644
--- a/xpcom/base/nsCrashOnException.cpp
+++ b/xpcom/base/nsCrashOnException.cpp
@@ -8,22 +8,11 @@
#include "nsCOMPtr.h"
#include "nsServiceManagerUtils.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsICrashReporter.h"
-#endif
-
namespace mozilla {
static int
ReportException(EXCEPTION_POINTERS* aExceptionInfo)
{
-#ifdef MOZ_CRASHREPORTER
- nsCOMPtr<nsICrashReporter> cr =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- if (cr) {
- cr->WriteMinidumpForException(aExceptionInfo);
- }
-#endif
return EXCEPTION_EXECUTE_HANDLER;
}
diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp
index ca7057628..b2c15a1dd 100644
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -188,10 +188,6 @@
#include "mozilla/Telemetry.h"
#include "mozilla/ThreadLocal.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
-
using namespace mozilla;
//#define COLLECT_TIME_DEBUG
@@ -2690,7 +2686,7 @@ public:
void* aClosure) const override
{
const JS::Value& val = aValue->unbarrieredGet();
- if (val.isMarkable() && ValueIsGrayCCThing(val)) {
+ if (val.isGCThing() && ValueIsGrayCCThing(val)) {
MOZ_ASSERT(!js::gc::IsInsideNursery(val.toGCThing()));
mCollector->GetJSPurpleBuffer()->mValues.InfallibleAppend(val);
}
@@ -3150,14 +3146,6 @@ nsCycleCollector::ScanWhiteNodes(bool aFullySynchGraphBuild)
}
if (pi->mInternalRefs > pi->mRefCount) {
-#ifdef MOZ_CRASHREPORTER
- const char* piName = "Unknown";
- if (pi->mParticipant) {
- piName = pi->mParticipant->ClassName();
- }
- nsPrintfCString msg("More references to an object than its refcount, for class %s", piName);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CycleCollector"), msg);
-#endif
MOZ_CRASH();
}
diff --git a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp
index eb06a389c..7c48002e3 100644
--- a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp
+++ b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp
@@ -36,7 +36,7 @@ void
TraceCallbackFunc::Trace(JS::Heap<JS::Value>* aPtr, const char* aName,
void* aClosure) const
{
- if (aPtr->unbarrieredGet().isMarkable()) {
+ if (aPtr->unbarrieredGet().isGCThing()) {
mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure);
}
}
diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp
index 36288d203..96487acda 100644
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -11,9 +11,6 @@
#include "nsDebugImpl.h"
#include "nsDebug.h"
-#ifdef MOZ_CRASHREPORTER
-# include "nsExceptionHandler.h"
-#endif
#include "nsString.h"
#include "nsXULAppAPI.h"
#include "prprf.h"
@@ -380,22 +377,6 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
return;
case NS_DEBUG_ABORT: {
-#if defined(MOZ_CRASHREPORTER)
- // Updating crash annotations in the child causes us to do IPC. This can
- // really cause trouble if we're asserting from within IPC code. So we
- // have to do without the annotations in that case.
- if (XRE_IsParentProcess()) {
- // Don't include the PID in the crash report annotation to
- // allow faceting on crash-stats.mozilla.org.
- nsCString note("xpcom_runtime_abort(");
- note += nonPIDBuf.buffer;
- note += ")";
- CrashReporter::AppendAppNotesToCrashReport(note);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"),
- nsDependentCString(nonPIDBuf.buffer));
- }
-#endif // MOZ_CRASHREPORTER
-
#if defined(DEBUG) && defined(_WIN32)
RealBreak();
#endif
@@ -600,8 +581,5 @@ NS_ErrorAccordingToNSPR()
void
NS_ABORT_OOM(size_t aSize)
{
-#if defined(MOZ_CRASHREPORTER)
- CrashReporter::AnnotateOOMAllocationSize(aSize);
-#endif
MOZ_CRASH("OOM");
}
diff --git a/xpcom/base/nsObjCExceptions.h b/xpcom/base/nsObjCExceptions.h
index e63c92af5..b3ed532ec 100644
--- a/xpcom/base/nsObjCExceptions.h
+++ b/xpcom/base/nsObjCExceptions.h
@@ -17,12 +17,6 @@
#import <ExceptionHandling/NSExceptionHandler.h>
#endif
-#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus)
-#include "nsICrashReporter.h"
-#include "nsCOMPtr.h"
-#include "nsServiceManagerUtils.h"
-#endif
-
#include <unistd.h>
#include <signal.h>
#include "nsError.h"
@@ -47,15 +41,6 @@ nsObjCExceptionLog(NSException* aException)
NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]",
[aException name], [aException reason]);
-#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus)
- // Attach exception info to the crash report.
- nsCOMPtr<nsICrashReporter> crashReporter =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- if (crashReporter) {
- crashReporter->AppendObjCExceptionInfoToAppNotes(static_cast<void*>(aException));
- }
-#endif
-
#ifdef DEBUG
@try {
// Try to get stack information out of the exception. 10.5 returns the stack
diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp
index c72ea48d7..6ead5cdc7 100644
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -111,7 +111,6 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);
#include "SpecialSystemDirectory.h"
#if defined(XP_WIN)
-#include "mozilla/WindowsVersion.h"
#include "nsWindowsRegKey.h"
#endif
@@ -584,8 +583,6 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
NS_StartupLocalFile();
- StartupSpecialSystemDirectory();
-
nsDirectoryService::RealInit();
bool value;
diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h
index 426a58f06..aae248ca1 100644
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -426,17 +426,6 @@ XRE_API(const char*,
XRE_API(void,
XRE_SetProcessType, (const char* aProcessTypeString))
-#if defined(MOZ_CRASHREPORTER)
-// Used in the "master" parent process hosting the crash server
-XRE_API(bool,
- XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump,
- uint32_t* aSequence))
-
-// Used in child processes.
-XRE_API(bool,
- XRE_SetRemoteExceptionHandler, (const char* aPipe))
-#endif
-
namespace mozilla {
namespace gmp {
class GMPLoader;
diff --git a/xpcom/glue/nsThreadUtils.cpp b/xpcom/glue/nsThreadUtils.cpp
index 287ada7be..2f2383fd8 100644
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -20,15 +20,10 @@
#ifdef XP_WIN
#include <windows.h>
-#include "mozilla/WindowsVersion.h"
-using mozilla::IsVistaOrLater;
#elif defined(XP_MACOSX)
#include <sys/resource.h>
#endif
-#include <pratom.h>
-#include <prthread.h>
-
using namespace mozilla;
#ifndef XPCOM_GLUE_AVOID_NSPR
@@ -443,8 +438,7 @@ nsThreadPoolNaming::SetThreadPoolName(const nsACString& aPoolName,
nsAutoLowPriorityIO::nsAutoLowPriorityIO()
{
#if defined(XP_WIN)
- lowIOPrioritySet = IsVistaOrLater() &&
- SetThreadPriority(GetCurrentThread(),
+ lowIOPrioritySet = SetThreadPriority(GetCurrentThread(),
THREAD_MODE_BACKGROUND_BEGIN);
#elif defined(XP_MACOSX)
oldPriority = getiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD);
diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp
index 9ce8eb85b..ab65d38f9 100644
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -12,7 +12,6 @@
#if defined(XP_WIN)
#include <windows.h>
-#include <shlobj.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -20,9 +19,6 @@
#include <shlobj.h>
#include <knownfolders.h>
#include <guiddef.h>
-#include "mozilla/WindowsVersion.h"
-
-using mozilla::IsWin7OrLater;
#elif defined(XP_UNIX)
@@ -51,40 +47,17 @@ using mozilla::IsWin7OrLater;
#endif
#endif
-#ifdef XP_WIN
-typedef HRESULT (WINAPI* nsGetKnownFolderPath)(GUID& rfid,
- DWORD dwFlags,
- HANDLE hToken,
- PWSTR* ppszPath);
-
-static nsGetKnownFolderPath gGetKnownFolderPath = nullptr;
-#endif
-
-void
-StartupSpecialSystemDirectory()
-{
-#if defined (XP_WIN)
- // SHGetKnownFolderPath is only available on Windows Vista
- // so that we need to use GetProcAddress to get the pointer.
- HMODULE hShell32DLLInst = GetModuleHandleW(L"shell32.dll");
- if (hShell32DLLInst) {
- gGetKnownFolderPath = (nsGetKnownFolderPath)
- GetProcAddress(hShell32DLLInst, "SHGetKnownFolderPath");
- }
-#endif
-}
-
#if defined (XP_WIN)
static nsresult
GetKnownFolder(GUID* aGuid, nsIFile** aFile)
{
- if (!aGuid || !gGetKnownFolderPath) {
+ if (!aGuid) {
return NS_ERROR_FAILURE;
}
PWSTR path = nullptr;
- gGetKnownFolderPath(*aGuid, 0, nullptr, &path);
+ SHGetKnownFolderPath(*aGuid, 0, nullptr, &path);
if (!path) {
return NS_ERROR_FAILURE;
@@ -139,19 +112,13 @@ SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, DWORD aMode,
}
/*
- * Check to see if we're on Win7 and up, and if so, returns the default
- * save-to location for the Windows Library passed in through aFolderId.
- * Otherwise falls back on pre-win7 GetWindowsFolder.
+ * Return the default save-to location for the Windows Library passed in
+ * through aFolderId.
*/
static nsresult
GetLibrarySaveToPath(int aFallbackFolderId, REFKNOWNFOLDERID aFolderId,
nsIFile** aFile)
{
- // Skip off checking for library support if the os is Vista or lower.
- if (!IsWin7OrLater()) {
- return GetWindowsFolder(aFallbackFolderId, aFile);
- }
-
RefPtr<IShellLibrary> shellLib;
RefPtr<IShellItem> savePath;
HRESULT hr =
@@ -740,8 +707,6 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
}
#if defined(MOZ_CONTENT_SANDBOX)
case Win_LocalAppdataLow: {
- // This should only really fail on versions pre-Vista, in which case this
- // shouldn't have been used in the first place.
GUID localAppDataLowGuid = FOLDERID_LocalAppDataLow;
return GetKnownFolder(&localAppDataLowGuid, aFile);
}
diff --git a/xpcom/io/SpecialSystemDirectory.h b/xpcom/io/SpecialSystemDirectory.h
index dd3d88379..7c7f8fa42 100644
--- a/xpcom/io/SpecialSystemDirectory.h
+++ b/xpcom/io/SpecialSystemDirectory.h
@@ -16,9 +16,6 @@
#include "prenv.h"
#endif
-extern void StartupSpecialSystemDirectory();
-
-
enum SystemDirectories {
OS_DriveDirectory = 1,
OS_TemporaryDirectory = 2,
diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp
index 3a7e570f5..66e267807 100644
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -7,7 +7,6 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/UniquePtrExtensions.h"
-#include "mozilla/WindowsVersion.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
@@ -1970,13 +1969,11 @@ nsLocalFile::CopySingleFile(nsIFile* aSourceFile, nsIFile* aDestParent,
// So we only use COPY_FILE_NO_BUFFERING when we have a remote drive.
int copyOK;
DWORD dwCopyFlags = COPY_FILE_ALLOW_DECRYPTED_DESTINATION;
- if (IsVistaOrLater()) {
- bool path1Remote, path2Remote;
- if (!IsRemoteFilePath(filePath.get(), path1Remote) ||
- !IsRemoteFilePath(destPath.get(), path2Remote) ||
- path1Remote || path2Remote) {
- dwCopyFlags |= COPY_FILE_NO_BUFFERING;
- }
+ bool path1Remote, path2Remote;
+ if (!IsRemoteFilePath(filePath.get(), path1Remote) ||
+ !IsRemoteFilePath(destPath.get(), path2Remote) ||
+ path1Remote || path2Remote) {
+ dwCopyFlags |= COPY_FILE_NO_BUFFERING;
}
if (!move) {
diff --git a/xpcom/moz.build b/xpcom/moz.build
index 45a83c5c8..fe94edfce 100644
--- a/xpcom/moz.build
+++ b/xpcom/moz.build
@@ -31,7 +31,6 @@ if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_DEBUG']:
TEST_DIRS += [
'tests',
- 'rust/nsstring/gtest',
]
# Can't build internal xptcall tests that use symbols which are not exported.
diff --git a/xpcom/rust/nsstring/Cargo.toml b/xpcom/rust/nsstring/Cargo.toml
deleted file mode 100644
index d86a1ad26..000000000
--- a/xpcom/rust/nsstring/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "nsstring"
-version = "0.1.0"
-authors = ["nobody@mozilla.com"]
-license = "MPL-2.0"
-description = "Rust bindings to xpcom string types"
-
-[dependencies]
diff --git a/xpcom/rust/nsstring/gtest/Cargo.toml b/xpcom/rust/nsstring/gtest/Cargo.toml
deleted file mode 100644
index 44897ec98..000000000
--- a/xpcom/rust/nsstring/gtest/Cargo.toml
+++ /dev/null
@@ -1,12 +0,0 @@
-[package]
-name = "nsstring-gtest"
-version = "0.1.0"
-authors = ["nobody@mozilla.com"]
-license = "MPL-2.0"
-description = "Tests for rust bindings to xpcom string types"
-
-[dependencies]
-nsstring = { path = "../" }
-
-[lib]
-path = "test.rs"
diff --git a/xpcom/rust/nsstring/gtest/Test.cpp b/xpcom/rust/nsstring/gtest/Test.cpp
deleted file mode 100644
index 93d2ee1d7..000000000
--- a/xpcom/rust/nsstring/gtest/Test.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-#include "gtest/gtest.h"
-#include <stdint.h>
-#include "nsString.h"
-
-extern "C" {
- // This function is called by the rust code in test.rs if a non-fatal test
- // failure occurs.
- void GTest_ExpectFailure(const char* aMessage) {
- EXPECT_STREQ(aMessage, "");
- }
-}
-
-#define SIZE_ALIGN_CHECK(Clazz) \
- extern "C" void Rust_Test_ReprSizeAlign_##Clazz(size_t* size, size_t* align); \
- TEST(RustNsString, ReprSizeAlign_##Clazz) { \
- size_t size, align; \
- Rust_Test_ReprSizeAlign_##Clazz(&size, &align); \
- EXPECT_EQ(size, sizeof(Clazz)); \
- EXPECT_EQ(align, alignof(Clazz)); \
- }
-
-SIZE_ALIGN_CHECK(nsString)
-SIZE_ALIGN_CHECK(nsCString)
-SIZE_ALIGN_CHECK(nsFixedString)
-SIZE_ALIGN_CHECK(nsFixedCString)
-
-#define MEMBER_CHECK(Clazz, Member) \
- extern "C" void Rust_Test_Member_##Clazz##_##Member(size_t* size, \
- size_t* align, \
- size_t* offset); \
- TEST(RustNsString, ReprMember_##Clazz##_##Member) { \
- class Hack : public Clazz { \
- public: \
- static void RunTest() { \
- size_t size, align, offset; \
- Rust_Test_Member_##Clazz##_##Member(&size, &align, &offset); \
- EXPECT_EQ(size, sizeof(mozilla::DeclVal<Hack>().Member)); \
- EXPECT_EQ(size, alignof(decltype(mozilla::DeclVal<Hack>().Member))); \
- EXPECT_EQ(offset, offsetof(Hack, Member)); \
- } \
- }; \
- static_assert(sizeof(Clazz) == sizeof(Hack), "Hack matches class"); \
- Hack::RunTest(); \
- }
-
-MEMBER_CHECK(nsString, mData)
-MEMBER_CHECK(nsString, mLength)
-MEMBER_CHECK(nsString, mFlags)
-MEMBER_CHECK(nsCString, mData)
-MEMBER_CHECK(nsCString, mLength)
-MEMBER_CHECK(nsCString, mFlags)
-MEMBER_CHECK(nsFixedString, mFixedCapacity)
-MEMBER_CHECK(nsFixedString, mFixedBuf)
-MEMBER_CHECK(nsFixedCString, mFixedCapacity)
-MEMBER_CHECK(nsFixedCString, mFixedBuf)
-
-extern "C" void Rust_Test_NsStringFlags(uint32_t* f_none,
- uint32_t* f_terminated,
- uint32_t* f_voided,
- uint32_t* f_shared,
- uint32_t* f_owned,
- uint32_t* f_fixed,
- uint32_t* f_literal,
- uint32_t* f_class_fixed);
-TEST(RustNsString, NsStringFlags) {
- uint32_t f_none, f_terminated, f_voided, f_shared, f_owned, f_fixed, f_literal, f_class_fixed;
- Rust_Test_NsStringFlags(&f_none, &f_terminated,
- &f_voided, &f_shared,
- &f_owned, &f_fixed,
- &f_literal, &f_class_fixed);
- EXPECT_EQ(f_none, nsAString::F_NONE);
- EXPECT_EQ(f_none, nsACString::F_NONE);
- EXPECT_EQ(f_terminated, nsAString::F_TERMINATED);
- EXPECT_EQ(f_terminated, nsACString::F_TERMINATED);
- EXPECT_EQ(f_voided, nsAString::F_VOIDED);
- EXPECT_EQ(f_voided, nsACString::F_VOIDED);
- EXPECT_EQ(f_shared, nsAString::F_SHARED);
- EXPECT_EQ(f_shared, nsACString::F_SHARED);
- EXPECT_EQ(f_owned, nsAString::F_OWNED);
- EXPECT_EQ(f_owned, nsACString::F_OWNED);
- EXPECT_EQ(f_fixed, nsAString::F_FIXED);
- EXPECT_EQ(f_fixed, nsACString::F_FIXED);
- EXPECT_EQ(f_literal, nsAString::F_LITERAL);
- EXPECT_EQ(f_literal, nsACString::F_LITERAL);
- EXPECT_EQ(f_class_fixed, nsAString::F_CLASS_FIXED);
- EXPECT_EQ(f_class_fixed, nsACString::F_CLASS_FIXED);
-}
-
-extern "C" void Rust_StringFromCpp(const nsACString* aCStr, const nsAString* aStr);
-TEST(RustNsString, StringFromCpp) {
- nsAutoCString foo;
- foo.AssignASCII("Hello, World!");
-
- nsAutoString bar;
- bar.AssignASCII("Hello, World!");
-
- Rust_StringFromCpp(&foo, &bar);
-}
-
-extern "C" void Rust_AssignFromRust(nsACString* aCStr, nsAString* aStr);
-TEST(RustNsString, AssignFromRust) {
- nsAutoCString cs;
- nsAutoString s;
- Rust_AssignFromRust(&cs, &s);
- EXPECT_TRUE(cs.EqualsASCII("Hello, World!"));
- EXPECT_TRUE(s.EqualsASCII("Hello, World!"));
-}
-
-extern "C" {
- void Cpp_AssignFromCpp(nsACString* aCStr, nsAString* aStr) {
- aCStr->AssignASCII("Hello, World!");
- aStr->AssignASCII("Hello, World!");
- }
-}
-extern "C" void Rust_AssignFromCpp();
-TEST(RustNsString, AssignFromCpp) {
- Rust_AssignFromCpp();
-}
-extern "C" void Rust_FixedAssignFromCpp();
-TEST(RustNsString, FixedAssignFromCpp) {
- Rust_FixedAssignFromCpp();
-}
-extern "C" void Rust_AutoAssignFromCpp();
-TEST(RustNsString, AutoAssignFromCpp) {
- Rust_AutoAssignFromCpp();
-}
-
-extern "C" void Rust_StringWrite();
-TEST(RustNsString, StringWrite) {
- Rust_StringWrite();
-}
diff --git a/xpcom/rust/nsstring/gtest/moz.build b/xpcom/rust/nsstring/gtest/moz.build
deleted file mode 100644
index 5bed9e57e..000000000
--- a/xpcom/rust/nsstring/gtest/moz.build
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-if CONFIG['MOZ_RUST']:
- UNIFIED_SOURCES += [
- 'Test.cpp'
- ]
-
-FINAL_LIBRARY = 'xul-gtest'
diff --git a/xpcom/rust/nsstring/gtest/test.rs b/xpcom/rust/nsstring/gtest/test.rs
deleted file mode 100644
index 2968a1be7..000000000
--- a/xpcom/rust/nsstring/gtest/test.rs
+++ /dev/null
@@ -1,112 +0,0 @@
-#![allow(non_snake_case)]
-
-#[macro_use]
-extern crate nsstring;
-
-use std::fmt::Write;
-use std::ffi::CString;
-use std::os::raw::c_char;
-use nsstring::*;
-
-fn nonfatal_fail(msg: String) {
- extern "C" {
- fn GTest_ExpectFailure(message: *const c_char);
- }
- unsafe {
- GTest_ExpectFailure(CString::new(msg).unwrap().as_ptr());
- }
-}
-
-/// This macro checks if the two arguments are equal, and causes a non-fatal
-/// GTest test failure if they are not.
-macro_rules! expect_eq {
- ($x:expr, $y:expr) => {
- match (&$x, &$y) {
- (x, y) => if *x != *y {
- nonfatal_fail(format!("check failed: (`{:?}` == `{:?}`) at {}:{}",
- x, y, file!(), line!()))
- }
- }
- }
-}
-
-#[no_mangle]
-pub extern fn Rust_StringFromCpp(cs: *const nsACString, s: *const nsAString) {
- unsafe {
- expect_eq!(&*cs, "Hello, World!");
- expect_eq!(&*s, "Hello, World!");
- }
-}
-
-#[no_mangle]
-pub extern fn Rust_AssignFromRust(cs: *mut nsACString, s: *mut nsAString) {
- unsafe {
- (*cs).assign(&nsCString::from("Hello, World!"));
- expect_eq!(&*cs, "Hello, World!");
- (*s).assign(&nsString::from("Hello, World!"));
- expect_eq!(&*s, "Hello, World!");
- }
-}
-
-extern "C" {
- fn Cpp_AssignFromCpp(cs: *mut nsACString, s: *mut nsAString);
-}
-
-#[no_mangle]
-pub extern fn Rust_AssignFromCpp() {
- let mut cs = nsCString::new();
- let mut s = nsString::new();
- unsafe {
- Cpp_AssignFromCpp(&mut *cs, &mut *s);
- }
- expect_eq!(cs, "Hello, World!");
- expect_eq!(s, "Hello, World!");
-}
-
-#[no_mangle]
-pub extern fn Rust_FixedAssignFromCpp() {
- let mut cs_buf: [u8; 64] = [0; 64];
- let cs_buf_ptr = &cs_buf as *const _ as usize;
- let mut s_buf: [u16; 64] = [0; 64];
- let s_buf_ptr = &s_buf as *const _ as usize;
- let mut cs = nsFixedCString::new(&mut cs_buf);
- let mut s = nsFixedString::new(&mut s_buf);
- unsafe {
- Cpp_AssignFromCpp(&mut *cs, &mut *s);
- }
- expect_eq!(cs, "Hello, World!");
- expect_eq!(s, "Hello, World!");
- expect_eq!(cs.as_ptr() as usize, cs_buf_ptr);
- expect_eq!(s.as_ptr() as usize, s_buf_ptr);
-}
-
-#[no_mangle]
-pub extern fn Rust_AutoAssignFromCpp() {
- ns_auto_cstring!(cs);
- ns_auto_string!(s);
- unsafe {
- Cpp_AssignFromCpp(&mut *cs, &mut *s);
- }
- expect_eq!(cs, "Hello, World!");
- expect_eq!(s, "Hello, World!");
-}
-
-#[no_mangle]
-pub extern fn Rust_StringWrite() {
- ns_auto_cstring!(cs);
- ns_auto_string!(s);
-
- write!(s, "a").unwrap();
- write!(cs, "a").unwrap();
- expect_eq!(s, "a");
- expect_eq!(cs, "a");
- write!(s, "bc").unwrap();
- write!(cs, "bc").unwrap();
- expect_eq!(s, "abc");
- expect_eq!(cs, "abc");
- write!(s, "{}", 123).unwrap();
- write!(cs, "{}", 123).unwrap();
- expect_eq!(s, "abc123");
- expect_eq!(cs, "abc123");
-}
-
diff --git a/xpcom/rust/nsstring/src/lib.rs b/xpcom/rust/nsstring/src/lib.rs
deleted file mode 100644
index cd518f3c5..000000000
--- a/xpcom/rust/nsstring/src/lib.rs
+++ /dev/null
@@ -1,853 +0,0 @@
-//! This module provides rust bindings for the XPCOM string types.
-//!
-//! # TL;DR (what types should I use)
-//!
-//! Use `&{mut,} nsA[C]String` for functions in rust which wish to take or
-//! mutate XPCOM strings. The other string types `Deref` to this type.
-//!
-//! Use `ns[C]String<'a>` for string struct members which don't leave rust, and
-//! as an intermediate between rust string data structures (such as `String`,
-//! `Vec<u16>`, `&str`, and `&[u16]`) and `&{mut,} nsA[C]String` (using
-//! `ns[C]String::from(value)`). These conversions, when possible, will not
-//! perform any allocations.
-//!
-//! Use `nsFixed[C]String` or `ns_auto_[c]string!` for dynamic stack allocated
-//! strings which are expected to hold short string values.
-//!
-//! Use `*{const,mut} nsA[C]String` (`{const,} nsA[C]String*` in C++) for
-//! function arguments passed across the rust/C++ language boundary.
-//!
-//! Use `ns[C]StringRepr` for string struct members which are shared between
-//! rust and C++, but be careful, because this type lacks a `Drop`
-//! implementation.
-//!
-//! # String Types
-//!
-//! ## `nsA[C]String`
-//!
-//! The core types in this module are `nsAString` and `nsACString`. These types
-//! are zero-sized as far as rust is concerned, and are safe to pass around
-//! behind both references (in rust code), and pointers (in C++ code). They
-//! represent a handle to a XPCOM string which holds either `u16` or `u8`
-//! characters respectively. The backing character buffer is guaranteed to live
-//! as long as the reference to the `nsAString` or `nsACString`.
-//!
-//! These types in rust are simply used as dummy types. References to them
-//! represent a pointer to the beginning of a variable-sized `#[repr(C)]` struct
-//! which is common between both C++ and Rust implementations. In C++, their
-//! corresponding types are also named `nsAString` or `nsACString`, and they are
-//! defined within the `nsTSubstring.{cpp,h}` file.
-//!
-//! ### Valid Operations
-//!
-//! An `&nsA[C]String` acts like rust's `&str`, in that it is a borrowed
-//! reference to the backing data. When used as an argument to other functions
-//! on `&mut nsA[C]String`, optimizations can be performed to avoid copying
-//! buffers, as information about the backing storage is preserved.
-//!
-//! An `&mut nsA[C]String` acts like rust's `&mut Cow<str>`, in that it is a
-//! mutable reference to a potentially borrowed string, which when modified will
-//! ensure that it owns its own backing storage. This type can be appended to
-//! with the methods `.append`, `.append_utf{8,16}`, and with the `write!`
-//! macro, and can be assigned to with `.assign`.
-//!
-//! ## `ns[C]String<'a>`
-//!
-//! This type is an maybe-owned string type. It acts similarially to a
-//! `Cow<[{u8,u16}]>`. This type provides `Deref` and `DerefMut` implementations
-//! to `nsA[C]String`, which provides the methods for manipulating this type.
-//! This type's lifetime parameter, `'a`, represents the lifetime of the backing
-//! storage. When modified this type may re-allocate in order to ensure that it
-//! does not mutate its backing storage.
-//!
-//! `ns[C]String`s can be constructed either with `ns[C]String::new()`, which
-//! creates an empty `ns[C]String<'static>`, or through one of the provided
-//! `From` implementations. Both string types may be constructed `From<&'a
-//! str>`, with `nsCString` having a `'a` lifetime, as the storage is shared
-//! with the `str`, while `nsString` has a `'static` lifetime, as its storage
-//! has to be transcoded.
-//!
-//! When passing this type by reference, prefer passing a `&nsA[C]String` or
-//! `&mut nsA[C]String`. to passing this type.
-//!
-//! This type is _not_ `#[repr(C)]`, as it has a `Drop` impl, which in versions
-//! of `rustc < 1.13` adds drop flags to the struct, which messes up the layout,
-//! making it unsafe to pass across the FFI boundary. The rust compiler will
-//! warn if this type appears in `extern "C"` function definitions.
-//!
-//! When passing this type across the language boundary, pass it as `*const
-//! nsA[C]String` for an immutable reference, or `*mut nsA[C]String` for a
-//! mutable reference.
-//!
-//! This type is similar to the C++ type of the same name.
-//!
-//! ## `nsFixed[C]String<'a>`
-//!
-//! This type is a string type with fixed backing storage. It is created with
-//! `nsFixed[C]String::new(buffer)`, passing a mutable reference to a buffer as
-//! the argument. This buffer will be used as backing storage whenever the
-//! resulting string will fit within it, falling back to heap allocations only
-//! when the string size exceeds that of the backing buffer.
-//!
-//! Like `ns[C]String`, this type dereferences to `nsA[C]String` which provides
-//! the methods for manipulating the type, and is not `#[repr(C)]`.
-//!
-//! When passing this type by reference, prefer passing a `&nsA[C]String` or
-//! `&mut nsA[C]String`. to passing this type.
-//!
-//! This type is _not_ `#[repr(C)]`, as it has a `Drop` impl, which in versions
-//! of `rustc < 1.13` adds drop flags to the struct, which messes up the layout,
-//! making it unsafe to pass across the FFI boundary. The rust compiler will
-//! warn if this type appears in `extern "C"` function definitions.
-//!
-//! When passing this type across the language boundary, pass it as `*const
-//! nsA[C]String` for an immutable reference, or `*mut nsA[C]String` for a
-//! mutable reference.
-//!
-//! This type is similar to the C++ type of the same name.
-//!
-//! ## `ns_auto_[c]string!($name)`
-//!
-//! This is a helper macro which defines a fixed size, (currently 64 character),
-//! backing array on the stack, and defines a local variable with name `$name`
-//! which is a `nsFixed[C]String` using this buffer as its backing storage.
-//!
-//! Usage of this macro is similar to the C++ type `nsAuto[C]String`, but could
-//! not be implemented as a basic type due to the differences between rust and
-//! C++'s move semantics.
-//!
-//! ## `ns[C]StringRepr`
-//!
-//! This type represents a C++ `ns[C]String`. This type is `#[repr(C)]` and is
-//! safe to use in struct definitions which are shared across the language
-//! boundary. It automatically dereferences to `&{mut,} nsA[C]String`, and thus
-//! can be treated similarially to `ns[C]String`.
-//!
-//! If this type is dropped in rust, it will not free its backing storage. This
-//! is because types implementing `Drop` have a drop flag added, which messes up
-//! the layout of this type. When drop flags are removed, which should happen in
-//! `rustc 1.13` (see rust-lang/rust#35764), this type will likely be removed,
-//! and replaced with direct usage of `ns[C]String<'a>`, as its layout may be
-//! identical. This module provides rust bindings to our xpcom ns[C]String
-//! types.
-
-#![allow(non_camel_case_types)]
-
-use std::ops::{Deref, DerefMut};
-use std::marker::PhantomData;
-use std::slice;
-use std::ptr;
-use std::mem;
-use std::fmt;
-use std::cmp;
-use std::str;
-use std::u32;
-
-//////////////////////////////////
-// Internal Implemenation Flags //
-//////////////////////////////////
-
-const F_NONE: u32 = 0; // no flags
-
-// data flags are in the lower 16-bits
-const F_TERMINATED: u32 = 1 << 0; // IsTerminated returns true
-const F_VOIDED: u32 = 1 << 1; // IsVoid returns true
-const F_SHARED: u32 = 1 << 2; // mData points to a heap-allocated, shared buffer
-const F_OWNED: u32 = 1 << 3; // mData points to a heap-allocated, raw buffer
-const F_FIXED: u32 = 1 << 4; // mData points to a fixed-size writable, dependent buffer
-const F_LITERAL: u32 = 1 << 5; // mData points to a string literal; F_TERMINATED will also be set
-
-// class flags are in the upper 16-bits
-const F_CLASS_FIXED: u32 = 1 << 16; // indicates that |this| is of type nsTFixedString
-
-////////////////////////////////////
-// Generic String Bindings Macros //
-////////////////////////////////////
-
-macro_rules! define_string_types {
- {
- char_t = $char_t: ty;
- AString = $AString: ident;
- String = $String: ident;
- FixedString = $FixedString: ident;
-
- StringRepr = $StringRepr: ident;
- FixedStringRepr = $FixedStringRepr: ident;
- AutoStringRepr = $AutoStringRepr: ident;
- } => {
- /// The representation of a ns[C]String type in C++. This type is
- /// used internally by our definition of ns[C]String to ensure layout
- /// compatibility with the C++ ns[C]String type.
- ///
- /// This type may also be used in place of a C++ ns[C]String inside of
- /// struct definitions which are shared with C++, as it has identical
- /// layout to our ns[C]String type. Due to drop flags, our ns[C]String
- /// type does not have identical layout. When drop flags are removed,
- /// this type will likely be made a private implementation detail, and
- /// its uses will be replaced with `ns[C]String`.
- ///
- /// This struct will leak its data if dropped from rust. See the module
- /// documentation for more information on this type.
- #[repr(C)]
- pub struct $StringRepr {
- data: *const $char_t,
- length: u32,
- flags: u32,
- }
-
- impl Deref for $StringRepr {
- type Target = $AString;
- fn deref(&self) -> &$AString {
- unsafe {
- mem::transmute(self)
- }
- }
- }
-
- impl DerefMut for $StringRepr {
- fn deref_mut(&mut self) -> &mut $AString {
- unsafe {
- mem::transmute(self)
- }
- }
- }
-
- /// The representation of a nsFixed[C]String type in C++. This type is
- /// used internally by our definition of nsFixed[C]String to ensure layout
- /// compatibility with the C++ nsFixed[C]String type.
- #[repr(C)]
- struct $FixedStringRepr {
- base: $StringRepr,
- capacity: u32,
- buffer: *mut $char_t,
- }
-
- /// This type is the abstract type which is used for interacting with
- /// strings in rust. Each string type can derefence to an instance of
- /// this type, which provides the useful operations on strings.
- ///
- /// NOTE: Rust thinks this type has a size of 0, because the data
- /// associated with it is not necessarially safe to move. It is not safe
- /// to construct a nsAString yourself, unless it is received by
- /// dereferencing one of these types.
- ///
- /// NOTE: The `[u8; 0]` member is zero sized, and only exists to prevent
- /// the construction by code outside of this module. It is used instead
- /// of a private `()` member because the `improper_ctypes` lint complains
- /// about some ZST members in `extern "C"` function declarations.
- #[repr(C)]
- pub struct $AString {
- _prohibit_constructor: [u8; 0],
- }
-
- impl Deref for $AString {
- type Target = [$char_t];
- fn deref(&self) -> &[$char_t] {
- unsafe {
- // This is legal, as all $AString values actually point to a
- // $StringRepr
- let this: &$StringRepr = mem::transmute(self);
- if this.data.is_null() {
- debug_assert!(this.length == 0);
- // Use an arbitrary non-null value as the pointer
- slice::from_raw_parts(0x1 as *const $char_t, 0)
- } else {
- slice::from_raw_parts(this.data, this.length as usize)
- }
- }
- }
- }
-
- impl cmp::PartialEq for $AString {
- fn eq(&self, other: &$AString) -> bool {
- &self[..] == &other[..]
- }
- }
-
- impl cmp::PartialEq<[$char_t]> for $AString {
- fn eq(&self, other: &[$char_t]) -> bool {
- &self[..] == other
- }
- }
-
- impl<'a> cmp::PartialEq<$String<'a>> for $AString {
- fn eq(&self, other: &$String<'a>) -> bool {
- self.eq(&**other)
- }
- }
-
- impl<'a> cmp::PartialEq<$FixedString<'a>> for $AString {
- fn eq(&self, other: &$FixedString<'a>) -> bool {
- self.eq(&**other)
- }
- }
-
- pub struct $String<'a> {
- hdr: $StringRepr,
- _marker: PhantomData<&'a [$char_t]>,
- }
-
- impl $String<'static> {
- pub fn new() -> $String<'static> {
- $String {
- hdr: $StringRepr {
- data: ptr::null(),
- length: 0,
- flags: F_NONE,
- },
- _marker: PhantomData,
- }
- }
- }
-
- impl<'a> Deref for $String<'a> {
- type Target = $AString;
- fn deref(&self) -> &$AString {
- &self.hdr
- }
- }
-
- impl<'a> DerefMut for $String<'a> {
- fn deref_mut(&mut self) -> &mut $AString {
- &mut self.hdr
- }
- }
-
- impl<'a> From<&'a String> for $String<'a> {
- fn from(s: &'a String) -> $String<'a> {
- $String::from(&s[..])
- }
- }
-
- impl<'a> From<&'a Vec<$char_t>> for $String<'a> {
- fn from(s: &'a Vec<$char_t>) -> $String<'a> {
- $String::from(&s[..])
- }
- }
-
- impl<'a> From<&'a [$char_t]> for $String<'a> {
- fn from(s: &'a [$char_t]) -> $String<'a> {
- assert!(s.len() < (u32::MAX as usize));
- $String {
- hdr: $StringRepr {
- data: s.as_ptr(),
- length: s.len() as u32,
- flags: F_NONE,
- },
- _marker: PhantomData,
- }
- }
- }
-
- impl From<Box<[$char_t]>> for $String<'static> {
- fn from(s: Box<[$char_t]>) -> $String<'static> {
- assert!(s.len() < (u32::MAX as usize));
- // SAFETY NOTE: This method produces an F_OWNED ns[C]String from
- // a Box<[$char_t]>. this is only safe because in the Gecko
- // tree, we use the same allocator for Rust code as for C++
- // code, meaning that our box can be legally freed with
- // libc::free().
- let length = s.len() as u32;
- let ptr = s.as_ptr();
- mem::forget(s);
- $String {
- hdr: $StringRepr {
- data: ptr,
- length: length,
- flags: F_OWNED,
- },
- _marker: PhantomData,
- }
- }
- }
-
- impl From<Vec<$char_t>> for $String<'static> {
- fn from(s: Vec<$char_t>) -> $String<'static> {
- s.into_boxed_slice().into()
- }
- }
-
- impl<'a> From<&'a $AString> for $String<'static> {
- fn from(s: &'a $AString) -> $String<'static> {
- let mut string = $String::new();
- string.assign(s);
- string
- }
- }
-
- impl<'a> fmt::Write for $String<'a> {
- fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
- $AString::write_str(self, s)
- }
- }
-
- impl<'a> fmt::Display for $String<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- <$AString as fmt::Display>::fmt(self, f)
- }
- }
-
- impl<'a> fmt::Debug for $String<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- <$AString as fmt::Debug>::fmt(self, f)
- }
- }
-
- impl<'a> cmp::PartialEq for $String<'a> {
- fn eq(&self, other: &$String<'a>) -> bool {
- $AString::eq(self, other)
- }
- }
-
- impl<'a> cmp::PartialEq<[$char_t]> for $String<'a> {
- fn eq(&self, other: &[$char_t]) -> bool {
- $AString::eq(self, other)
- }
- }
-
- impl<'a, 'b> cmp::PartialEq<&'b [$char_t]> for $String<'a> {
- fn eq(&self, other: &&'b [$char_t]) -> bool {
- $AString::eq(self, *other)
- }
- }
-
- impl<'a> cmp::PartialEq<str> for $String<'a> {
- fn eq(&self, other: &str) -> bool {
- $AString::eq(self, other)
- }
- }
-
- impl<'a, 'b> cmp::PartialEq<&'b str> for $String<'a> {
- fn eq(&self, other: &&'b str) -> bool {
- $AString::eq(self, *other)
- }
- }
-
- impl<'a> Drop for $String<'a> {
- fn drop(&mut self) {
- unsafe {
- self.finalize();
- }
- }
- }
-
- /// A nsFixed[C]String is a string which uses a fixed size mutable
- /// backing buffer for storing strings which will fit within that
- /// buffer, rather than using heap allocations.
- pub struct $FixedString<'a> {
- hdr: $FixedStringRepr,
- _marker: PhantomData<&'a mut [$char_t]>,
- }
-
- impl<'a> $FixedString<'a> {
- pub fn new(buf: &'a mut [$char_t]) -> $FixedString<'a> {
- let len = buf.len();
- assert!(len < (u32::MAX as usize));
- let buf_ptr = buf.as_mut_ptr();
- $FixedString {
- hdr: $FixedStringRepr {
- base: $StringRepr {
- data: ptr::null(),
- length: 0,
- flags: F_CLASS_FIXED,
- },
- capacity: len as u32,
- buffer: buf_ptr,
- },
- _marker: PhantomData,
- }
- }
- }
-
- impl<'a> Deref for $FixedString<'a> {
- type Target = $AString;
- fn deref(&self) -> &$AString {
- &self.hdr.base
- }
- }
-
- impl<'a> DerefMut for $FixedString<'a> {
- fn deref_mut(&mut self) -> &mut $AString {
- &mut self.hdr.base
- }
- }
-
- impl<'a> fmt::Write for $FixedString<'a> {
- fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
- $AString::write_str(self, s)
- }
- }
-
- impl<'a> fmt::Display for $FixedString<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- <$AString as fmt::Display>::fmt(self, f)
- }
- }
-
- impl<'a> fmt::Debug for $FixedString<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- <$AString as fmt::Debug>::fmt(self, f)
- }
- }
-
- impl<'a> cmp::PartialEq for $FixedString<'a> {
- fn eq(&self, other: &$FixedString<'a>) -> bool {
- $AString::eq(self, other)
- }
- }
-
- impl<'a> cmp::PartialEq<[$char_t]> for $FixedString<'a> {
- fn eq(&self, other: &[$char_t]) -> bool {
- $AString::eq(self, other)
- }
- }
-
- impl<'a, 'b> cmp::PartialEq<&'b [$char_t]> for $FixedString<'a> {
- fn eq(&self, other: &&'b [$char_t]) -> bool {
- $AString::eq(self, *other)
- }
- }
-
- impl<'a> cmp::PartialEq<str> for $FixedString<'a> {
- fn eq(&self, other: &str) -> bool {
- $AString::eq(self, other)
- }
- }
-
- impl<'a, 'b> cmp::PartialEq<&'b str> for $FixedString<'a> {
- fn eq(&self, other: &&'b str) -> bool {
- $AString::eq(self, *other)
- }
- }
-
- impl<'a> Drop for $FixedString<'a> {
- fn drop(&mut self) {
- unsafe {
- self.finalize();
- }
- }
- }
- }
-}
-
-///////////////////////////////////////////
-// Bindings for nsCString (u8 char type) //
-///////////////////////////////////////////
-
-define_string_types! {
- char_t = u8;
-
- AString = nsACString;
- String = nsCString;
- FixedString = nsFixedCString;
-
- StringRepr = nsCStringRepr;
- FixedStringRepr = nsFixedCStringRepr;
- AutoStringRepr = nsAutoCStringRepr;
-}
-
-impl nsACString {
- /// Leaves the nsACString in an unstable state with a dangling data pointer.
- /// Should only be used in drop implementations of rust types which wrap
- /// this type.
- unsafe fn finalize(&mut self) {
- Gecko_FinalizeCString(self);
- }
-
- pub fn assign(&mut self, other: &nsACString) {
- unsafe {
- Gecko_AssignCString(self as *mut _, other as *const _);
- }
- }
-
- pub fn assign_utf16(&mut self, other: &nsAString) {
- self.assign(&nsCString::new());
- self.append_utf16(other);
- }
-
- pub fn append(&mut self, other: &nsACString) {
- unsafe {
- Gecko_AppendCString(self as *mut _, other as *const _);
- }
- }
-
- pub fn append_utf16(&mut self, other: &nsAString) {
- unsafe {
- Gecko_AppendUTF16toCString(self as *mut _, other as *const _);
- }
- }
-
- pub unsafe fn as_str_unchecked(&self) -> &str {
- str::from_utf8_unchecked(self)
- }
-}
-
-impl<'a> From<&'a str> for nsCString<'a> {
- fn from(s: &'a str) -> nsCString<'a> {
- s.as_bytes().into()
- }
-}
-
-impl From<Box<str>> for nsCString<'static> {
- fn from(s: Box<str>) -> nsCString<'static> {
- s.into_string().into()
- }
-}
-
-impl From<String> for nsCString<'static> {
- fn from(s: String) -> nsCString<'static> {
- s.into_bytes().into()
- }
-}
-
-// Support for the write!() macro for appending to nsACStrings
-impl fmt::Write for nsACString {
- fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
- self.append(&nsCString::from(s));
- Ok(())
- }
-}
-
-impl fmt::Display for nsACString {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- fmt::Display::fmt(&String::from_utf8_lossy(&self[..]), f)
- }
-}
-
-impl fmt::Debug for nsACString {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- fmt::Debug::fmt(&String::from_utf8_lossy(&self[..]), f)
- }
-}
-
-impl cmp::PartialEq<str> for nsACString {
- fn eq(&self, other: &str) -> bool {
- &self[..] == other.as_bytes()
- }
-}
-
-#[macro_export]
-macro_rules! ns_auto_cstring {
- ($name:ident) => {
- let mut buf: [u8; 64] = [0; 64];
- let mut $name = $crate::nsFixedCString::new(&mut buf);
- }
-}
-
-///////////////////////////////////////////
-// Bindings for nsString (u16 char type) //
-///////////////////////////////////////////
-
-define_string_types! {
- char_t = u16;
-
- AString = nsAString;
- String = nsString;
- FixedString = nsFixedString;
-
- StringRepr = nsStringRepr;
- FixedStringRepr = nsFixedStringRepr;
- AutoStringRepr = nsAutoStringRepr;
-}
-
-impl nsAString {
- /// Leaves the nsAString in an unstable state with a dangling data pointer.
- /// Should only be used in drop implementations of rust types which wrap
- /// this type.
- unsafe fn finalize(&mut self) {
- Gecko_FinalizeString(self);
- }
-
- pub fn assign(&mut self, other: &nsAString) {
- unsafe {
- Gecko_AssignString(self as *mut _, other as *const _);
- }
- }
-
- pub fn assign_utf8(&mut self, other: &nsACString) {
- self.assign(&nsString::new());
- self.append_utf8(other);
- }
-
- pub fn append(&mut self, other: &nsAString) {
- unsafe {
- Gecko_AppendString(self as *mut _, other as *const _);
- }
- }
-
- pub fn append_utf8(&mut self, other: &nsACString) {
- unsafe {
- Gecko_AppendUTF8toString(self as *mut _, other as *const _);
- }
- }
-}
-
-// NOTE: The From impl for a string slice for nsString produces a <'static>
-// lifetime, as it allocates.
-impl<'a> From<&'a str> for nsString<'static> {
- fn from(s: &'a str) -> nsString<'static> {
- s.encode_utf16().collect::<Vec<u16>>().into()
- }
-}
-
-// Support for the write!() macro for writing to nsStrings
-impl fmt::Write for nsAString {
- fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
- // Directly invoke gecko's routines for appending utf8 strings to
- // nsAString values, to avoid as much overhead as possible
- self.append_utf8(&nsCString::from(s));
- Ok(())
- }
-}
-
-impl fmt::Display for nsAString {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- fmt::Display::fmt(&String::from_utf16_lossy(&self[..]), f)
- }
-}
-
-impl fmt::Debug for nsAString {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- fmt::Debug::fmt(&String::from_utf16_lossy(&self[..]), f)
- }
-}
-
-impl cmp::PartialEq<str> for nsAString {
- fn eq(&self, other: &str) -> bool {
- other.encode_utf16().eq(self.iter().cloned())
- }
-}
-
-#[macro_export]
-macro_rules! ns_auto_string {
- ($name:ident) => {
- let mut buf: [u16; 64] = [0; 64];
- let mut $name = $crate::nsFixedString::new(&mut buf);
- }
-}
-
-// NOTE: These bindings currently only expose infallible operations. Perhaps
-// consider allowing for fallible methods?
-extern "C" {
- // Gecko implementation in nsSubstring.cpp
- fn Gecko_FinalizeCString(this: *mut nsACString);
- fn Gecko_AssignCString(this: *mut nsACString, other: *const nsACString);
- fn Gecko_AppendCString(this: *mut nsACString, other: *const nsACString);
-
- fn Gecko_FinalizeString(this: *mut nsAString);
- fn Gecko_AssignString(this: *mut nsAString, other: *const nsAString);
- fn Gecko_AppendString(this: *mut nsAString, other: *const nsAString);
-
- // Gecko implementation in nsReadableUtils.cpp
- fn Gecko_AppendUTF16toCString(this: *mut nsACString, other: *const nsAString);
- fn Gecko_AppendUTF8toString(this: *mut nsAString, other: *const nsACString);
-}
-
-//////////////////////////////////////
-// Repr Validation Helper Functions //
-//////////////////////////////////////
-
-pub mod test_helpers {
- //! This module only exists to help with ensuring that the layout of the
- //! structs inside of rust and C++ are identical.
- //!
- //! It is public to ensure that these testing functions are avaliable to
- //! gtest code.
-
- use super::{
- nsFixedCStringRepr,
- nsFixedStringRepr,
- nsCStringRepr,
- nsStringRepr,
- F_NONE,
- F_TERMINATED,
- F_VOIDED,
- F_SHARED,
- F_OWNED,
- F_FIXED,
- F_LITERAL,
- F_CLASS_FIXED,
- };
- use std::mem;
-
- /// Generates an #[no_mangle] extern "C" function which returns the size and
- /// alignment of the given type with the given name.
- macro_rules! size_align_check {
- ($T:ty, $fname:ident) => {
- #[no_mangle]
- #[allow(non_snake_case)]
- pub extern fn $fname(size: *mut usize, align: *mut usize) {
- unsafe {
- *size = mem::size_of::<$T>();
- *align = mem::align_of::<$T>();
- }
- }
- }
- }
-
- size_align_check!(nsStringRepr, Rust_Test_ReprSizeAlign_nsString);
- size_align_check!(nsCStringRepr, Rust_Test_ReprSizeAlign_nsCString);
- size_align_check!(nsFixedStringRepr, Rust_Test_ReprSizeAlign_nsFixedString);
- size_align_check!(nsFixedCStringRepr, Rust_Test_ReprSizeAlign_nsFixedCString);
-
- /// Generates a $[no_mangle] extern "C" function which returns the size,
- /// alignment and offset in the parent struct of a given member, with the
- /// given name.
- ///
- /// This method can trigger Undefined Behavior if the accessing the member
- /// $member on a given type would use that type's `Deref` implementation.
- macro_rules! member_check {
- ($T:ty, $member:ident, $method:ident) => {
- #[no_mangle]
- #[allow(non_snake_case)]
- pub extern fn $method(size: *mut usize,
- align: *mut usize,
- offset: *mut usize) {
- unsafe {
- // Create a temporary value of type T to get offsets, sizes
- // and aligns off of
- let tmp: $T = mem::zeroed();
- *size = mem::size_of_val(&tmp.$member);
- *align = mem::align_of_val(&tmp.$member);
- *offset =
- (&tmp.$member as *const _ as usize) -
- (&tmp as *const _ as usize);
- mem::forget(tmp);
- }
- }
- }
- }
-
- member_check!(nsStringRepr, data, Rust_Test_Member_nsString_mData);
- member_check!(nsStringRepr, length, Rust_Test_Member_nsString_mLength);
- member_check!(nsStringRepr, flags, Rust_Test_Member_nsString_mFlags);
- member_check!(nsCStringRepr, data, Rust_Test_Member_nsCString_mData);
- member_check!(nsCStringRepr, length, Rust_Test_Member_nsCString_mLength);
- member_check!(nsCStringRepr, flags, Rust_Test_Member_nsCString_mFlags);
- member_check!(nsFixedStringRepr, capacity, Rust_Test_Member_nsFixedString_mFixedCapacity);
- member_check!(nsFixedStringRepr, buffer, Rust_Test_Member_nsFixedString_mFixedBuf);
- member_check!(nsFixedCStringRepr, capacity, Rust_Test_Member_nsFixedCString_mFixedCapacity);
- member_check!(nsFixedCStringRepr, buffer, Rust_Test_Member_nsFixedCString_mFixedBuf);
-
- #[no_mangle]
- #[allow(non_snake_case)]
- pub extern fn Rust_Test_NsStringFlags(f_none: *mut u32,
- f_terminated: *mut u32,
- f_voided: *mut u32,
- f_shared: *mut u32,
- f_owned: *mut u32,
- f_fixed: *mut u32,
- f_literal: *mut u32,
- f_class_fixed: *mut u32) {
- unsafe {
- *f_none = F_NONE;
- *f_terminated = F_TERMINATED;
- *f_voided = F_VOIDED;
- *f_shared = F_SHARED;
- *f_owned = F_OWNED;
- *f_fixed = F_FIXED;
- *f_literal = F_LITERAL;
- *f_class_fixed = F_CLASS_FIXED;
- }
- }
-}
diff --git a/xpcom/system/moz.build b/xpcom/system/moz.build
index 8a4f88efe..1d8e7ea1f 100644
--- a/xpcom/system/moz.build
+++ b/xpcom/system/moz.build
@@ -18,9 +18,4 @@ XPIDL_SOURCES += [
'nsIXULRuntime.idl',
]
-if CONFIG['MOZ_CRASHREPORTER']:
- XPIDL_SOURCES += [
- 'nsICrashReporter.idl',
- ]
-
XPIDL_MODULE = 'xpcom_system'
diff --git a/xpcom/system/nsIXULRuntime.idl b/xpcom/system/nsIXULRuntime.idl
index fda0e696f..994084c0a 100644
--- a/xpcom/system/nsIXULRuntime.idl
+++ b/xpcom/system/nsIXULRuntime.idl
@@ -164,7 +164,7 @@ interface nsIXULRuntime : nsISupports
readonly attribute AUTF8String distributionID;
/**
- * True if this is an official build (MOZILLA_OFFICIAL).
+ * True if this is an official build (MC_OFFICIAL).
*/
readonly attribute boolean isOfficial;
diff --git a/xpcom/tests/gtest/TestDeadlockDetector.cpp b/xpcom/tests/gtest/TestDeadlockDetector.cpp
index 646ee3e1d..877c5f5c3 100644
--- a/xpcom/tests/gtest/TestDeadlockDetector.cpp
+++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp
@@ -15,12 +15,6 @@
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsCOMPtr.h"
-#include "nsICrashReporter.h"
-#include "nsServiceManagerUtils.h"
-#endif
-
#include "gtest/gtest.h"
using namespace mozilla;
@@ -62,13 +56,7 @@ private:
void DisableCrashReporter()
{
-#ifdef MOZ_CRASHREPORTER
- nsCOMPtr<nsICrashReporter> crashreporter =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- if (crashreporter) {
- crashreporter->SetEnabled(false);
- }
-#endif
+ /*** STUB ***/
}
//-----------------------------------------------------------------------------
diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp
index e7a73ae1b..4405b102c 100644
--- a/xpcom/tests/gtest/TestPLDHash.cpp
+++ b/xpcom/tests/gtest/TestPLDHash.cpp
@@ -21,10 +21,6 @@
extern unsigned int _gdb_sleep_duration;
#endif
-#ifdef MOZ_CRASHREPORTER
-#include "nsICrashReporter.h"
-#endif
-
// We can test that certain operations cause expected aborts by forking
// and then checking that the child aborted in the expected way (i.e. via
// MOZ_CRASH). We skip this for the following configurations.
@@ -46,17 +42,6 @@ TestCrashyOperation(void (*aCrashyOperation)())
ASSERT_NE(pid, -1);
if (pid == 0) {
- // Disable the crashreporter -- writing a crash dump in the child will
- // prevent the parent from writing a subsequent dump. Crashes here are
- // expected, so we don't want their stacks to show up in the log anyway.
-#ifdef MOZ_CRASHREPORTER
- nsCOMPtr<nsICrashReporter> crashreporter =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- if (crashreporter) {
- crashreporter->SetEnabled(false);
- }
-#endif
-
// Child: perform the crashy operation.
fprintf(stderr, "TestCrashyOperation: The following crash is expected. Do not panic.\n");
aCrashyOperation();
diff --git a/xpcom/tests/gtest/TestSTLWrappers.cpp b/xpcom/tests/gtest/TestSTLWrappers.cpp
index 9559548a3..295aa7434 100644
--- a/xpcom/tests/gtest/TestSTLWrappers.cpp
+++ b/xpcom/tests/gtest/TestSTLWrappers.cpp
@@ -10,12 +10,6 @@
# error "failed to wrap <vector>"
#endif
-#ifdef MOZ_CRASHREPORTER
-#include "nsCOMPtr.h"
-#include "nsICrashReporter.h"
-#include "nsServiceManagerUtils.h"
-#endif
-
// gcc errors out if we |try ... catch| with -fno-exceptions, but we
// can still test on windows
#ifdef _MSC_VER
@@ -40,14 +34,6 @@ void ShouldAbort()
_gdb_sleep_duration = 0;
#endif
-#ifdef MOZ_CRASHREPORTER
- nsCOMPtr<nsICrashReporter> crashreporter =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- if (crashreporter) {
- crashreporter->SetEnabled(false);
- }
-#endif
-
std::vector<int> v;
int rv = 1;
diff --git a/xpcom/threads/HangMonitor.cpp b/xpcom/threads/HangMonitor.cpp
index 71cc67ca4..bd415be50 100644
--- a/xpcom/threads/HangMonitor.cpp
+++ b/xpcom/threads/HangMonitor.cpp
@@ -22,10 +22,6 @@
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
-
#ifdef XP_WIN
#include <windows.h>
#endif
@@ -111,15 +107,6 @@ Crash()
}
#endif
-#ifdef MOZ_CRASHREPORTER
- // If you change this, you must also deal with the threadsafety of AnnotateCrashReport in
- // non-chrome processes!
- if (GeckoProcessType_Default == XRE_GetProcessType()) {
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Hang"),
- NS_LITERAL_CSTRING("1"));
- }
-#endif
-
NS_RUNTIMEABORT("HangMonitor triggered");
}
diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp
index 63bd28ca3..7c1af08f4 100644
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -39,12 +39,6 @@
#include "nsThreadSyncDispatch.h"
#include "LeakRefPtr.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsServiceManagerUtils.h"
-#include "nsICrashReporter.h"
-#include "mozilla/dom/ContentChild.h"
-#endif
-
#ifdef XP_LINUX
#include <sys/time.h>
#include <sys/resource.h>
@@ -520,73 +514,6 @@ nsThread::ThreadFunc(void* aArg)
//-----------------------------------------------------------------------------
-#ifdef MOZ_CRASHREPORTER
-// Tell the crash reporter to save a memory report if our heuristics determine
-// that an OOM failure is likely to occur soon.
-// Memory usage will not be checked more than every 30 seconds or saved more
-// than every 3 minutes
-// If |aShouldSave == kForceReport|, a report will be saved regardless of
-// whether the process is low on memory or not. However, it will still not be
-// saved if a report was saved less than 3 minutes ago.
-bool
-nsThread::SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave)
-{
- // Keep an eye on memory usage (cheap, ~7ms) somewhat frequently,
- // but save memory reports (expensive, ~75ms) less frequently.
- const size_t kLowMemoryCheckSeconds = 30;
- const size_t kLowMemorySaveSeconds = 3 * 60;
-
- static TimeStamp nextCheck = TimeStamp::NowLoRes()
- + TimeDuration::FromSeconds(kLowMemoryCheckSeconds);
- static bool recentlySavedReport = false; // Keeps track of whether a report
- // was saved last time we checked
-
- // Are we checking again too soon?
- TimeStamp now = TimeStamp::NowLoRes();
- if ((aShouldSave == ShouldSaveMemoryReport::kMaybeReport ||
- recentlySavedReport) && now < nextCheck) {
- return false;
- }
-
- bool needMemoryReport = (aShouldSave == ShouldSaveMemoryReport::kForceReport);
-#ifdef XP_WIN // XXX implement on other platforms as needed
- // If the report is forced there is no need to check whether it is necessary
- if (aShouldSave != ShouldSaveMemoryReport::kForceReport) {
- const size_t LOWMEM_THRESHOLD_VIRTUAL = 200 * 1024 * 1024;
- MEMORYSTATUSEX statex;
- statex.dwLength = sizeof(statex);
- if (GlobalMemoryStatusEx(&statex)) {
- if (statex.ullAvailVirtual < LOWMEM_THRESHOLD_VIRTUAL) {
- needMemoryReport = true;
- }
- }
- }
-#endif
-
- if (needMemoryReport) {
- if (XRE_IsContentProcess()) {
- dom::ContentChild* cc = dom::ContentChild::GetSingleton();
- if (cc) {
- cc->SendNotifyLowMemory();
- }
- } else {
- nsCOMPtr<nsICrashReporter> cr =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- if (cr) {
- cr->SaveMemoryReport();
- }
- }
- recentlySavedReport = true;
- nextCheck = now + TimeDuration::FromSeconds(kLowMemorySaveSeconds);
- } else {
- recentlySavedReport = false;
- nextCheck = now + TimeDuration::FromSeconds(kLowMemoryCheckSeconds);
- }
-
- return recentlySavedReport;
-}
-#endif
-
#ifdef MOZ_CANARY
int sCanaryOutputFD = -1;
#endif
@@ -1459,12 +1386,6 @@ nsThread::DoMainThreadSpecificProcessing(bool aReallyWait)
}
}
}
-
-#ifdef MOZ_CRASHREPORTER
- if (!ShuttingDown()) {
- SaveMemoryReportNearOOM(ShouldSaveMemoryReport::kMaybeReport);
- }
-#endif
}
//-----------------------------------------------------------------------------
diff --git a/xpcom/threads/nsThread.h b/xpcom/threads/nsThread.h
index 836123747..037ef1952 100644
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -83,16 +83,6 @@ public:
void WaitForAllAsynchronousShutdowns();
-#ifdef MOZ_CRASHREPORTER
- enum class ShouldSaveMemoryReport
- {
- kMaybeReport,
- kForceReport
- };
-
- static bool SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave);
-#endif
-
private:
void DoMainThreadSpecificProcessing(bool aReallyWait);