summaryrefslogtreecommitdiff
path: root/ipc/glue
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-22 22:44:01 -0500
committerMatt A. Tobin <email@mattatobin.com>2020-02-22 22:44:01 -0500
commitdada39db2360486de3135d902aed4c351d6a76ad (patch)
tree4a0412b42521ae957a03191fbc3e6236c2b5f1c1 /ipc/glue
parent5496e4f391dd42ebde590eb0b041667490464a90 (diff)
downloaduxp-dada39db2360486de3135d902aed4c351d6a76ad.tar.gz
Issue #1053 - Remove android support from ipc except for ipc/chromium
This does not include android in the imported chromium code as specific research needs done on defines and logic.
Diffstat (limited to 'ipc/glue')
-rw-r--r--ipc/glue/GeckoChildProcessHost.cpp46
-rw-r--r--ipc/glue/ProtocolUtils.cpp4
-rw-r--r--ipc/glue/ProtocolUtils.h4
-rw-r--r--ipc/glue/SharedMemoryBasic.h4
-rw-r--r--ipc/glue/SharedMemoryBasic_android.cpp139
-rw-r--r--ipc/glue/SharedMemoryBasic_android.h72
-rw-r--r--ipc/glue/moz.build10
7 files changed, 3 insertions, 276 deletions
diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp
index 9e83a8729d..a14be5693e 100644
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -47,17 +47,6 @@
using mozilla::MonitorAutoLock;
using mozilla::ipc::GeckoChildProcessHost;
-#ifdef ANDROID
-// Like its predecessor in nsExceptionHandler.cpp, this is
-// the magic number of a file descriptor remapping we must
-// preserve for the child process.
-static const int kMagicAndroidSystemPropFd = 5;
-#endif
-
-#ifdef MOZ_WIDGET_ANDROID
-#include "AndroidBridge.h"
-#endif
-
static const bool kLowRightsSubprocesses =
// We only attempted to drop privileges on gonk, because it
// had no plugins or extensions to worry about breaking.
@@ -170,17 +159,7 @@ GeckoChildProcessHost::GetPathToBinary(FilePath& exePath, GeckoProcessType proce
exePath = exePath.DirName();
}
-#ifdef MOZ_WIDGET_ANDROID
- exePath = exePath.AppendASCII("lib");
-
- // We must use the PIE binary on 5.0 and higher
- const char* processName = mozilla::AndroidBridge::Bridge()->GetAPIVersion() >= 21 ?
- MOZ_CHILD_PROCESS_NAME_PIE : MOZ_CHILD_PROCESS_NAME;
-
- exePath = exePath.AppendASCII(processName);
-#else
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
-#endif
return BinaryPathType::PluginContainer;
}
@@ -622,9 +601,6 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
nsCString path;
NS_CopyUnicodeToNative(nsDependentString(gGREBinPath), path);
# if defined(OS_LINUX) || defined(OS_BSD)
-# if defined(MOZ_WIDGET_ANDROID)
- path += "/lib";
-# endif // MOZ_WIDGET_ANDROID
const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH");
nsCString new_ld_lib_path(path.get());
@@ -668,28 +644,6 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
FilePath exePath;
BinaryPathType pathType = GetPathToBinary(exePath, mProcessType);
-#ifdef MOZ_WIDGET_ANDROID
- // The java wrapper unpacks this for us but can't make it executable
- chmod(exePath.value().c_str(), 0700);
-#endif // MOZ_WIDGET_ANDROID
-
-#ifdef ANDROID
- // Remap the Android property workspace to a well-known int,
- // and update the environment to reflect the new value for the
- // child process.
- const char *apws = getenv("ANDROID_PROPERTY_WORKSPACE");
- if (apws) {
- int fd = atoi(apws);
- mFileMap.push_back(std::pair<int, int>(fd, kMagicAndroidSystemPropFd));
-
- char buf[32];
- char *szptr = strchr(apws, ',');
-
- snprintf(buf, sizeof(buf), "%d%s", kMagicAndroidSystemPropFd, szptr);
- newEnvVars["ANDROID_PROPERTY_WORKSPACE"] = buf;
- }
-#endif // ANDROID
-
// remap the IPC socket fd to a well-known int, as the OS does for
// STDOUT_FILENO, for example
int srcChannelFd, dstChannelFd;
diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp
index 7d8a1153c0..eb18bb987b 100644
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -183,9 +183,7 @@ LogMessageForProtocol(const char* aTopLevelProtocol, base::ProcessId aOtherPid,
aOtherPid, aTopLevelProtocol,
aContextDescription,
StringFromIPCMessageType(aMessageId));
-#ifdef ANDROID
- __android_log_write(ANDROID_LOG_INFO, "GeckoIPC", logMessage.get());
-#endif
+
fputs(logMessage.get(), stderr);
}
diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h
index 83860d93a4..e22f16c1c4 100644
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -27,10 +27,6 @@
#include "mozilla/UniquePtr.h"
#include "MainThreadUtils.h"
-#if defined(ANDROID) && defined(DEBUG)
-#include <android/log.h>
-#endif
-
template<typename T> class nsTHashtable;
template<typename T> class nsPtrHashKey;
diff --git a/ipc/glue/SharedMemoryBasic.h b/ipc/glue/SharedMemoryBasic.h
index d8720271f3..2bf4a93a05 100644
--- a/ipc/glue/SharedMemoryBasic.h
+++ b/ipc/glue/SharedMemoryBasic.h
@@ -7,9 +7,7 @@
#ifndef mozilla_ipc_SharedMemoryBasic_h
#define mozilla_ipc_SharedMemoryBasic_h
-#ifdef ANDROID
-# include "mozilla/ipc/SharedMemoryBasic_android.h"
-#elif defined(XP_DARWIN)
+#ifdef XP_DARWIN
# include "mozilla/ipc/SharedMemoryBasic_mach.h"
#else
# include "mozilla/ipc/SharedMemoryBasic_chromium.h"
diff --git a/ipc/glue/SharedMemoryBasic_android.cpp b/ipc/glue/SharedMemoryBasic_android.cpp
deleted file mode 100644
index 05c9ca9adc..0000000000
--- a/ipc/glue/SharedMemoryBasic_android.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#include <android/log.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "base/process_util.h"
-
-#include "SharedMemoryBasic.h"
-
-//
-// Temporarily go directly to the kernel interface until we can
-// interact better with libcutils.
-//
-#include <linux/ashmem.h>
-
-namespace mozilla {
-namespace ipc {
-
-static void
-LogError(const char* what)
-{
- __android_log_print(ANDROID_LOG_ERROR, "Gecko",
- "%s: %s (%d)", what, strerror(errno), errno);
-}
-
-SharedMemoryBasic::SharedMemoryBasic()
- : mShmFd(-1)
- , mMemory(nullptr)
-{ }
-
-SharedMemoryBasic::~SharedMemoryBasic()
-{
- Unmap();
- CloseHandle();
-}
-
-bool
-SharedMemoryBasic::SetHandle(const Handle& aHandle)
-{
- MOZ_ASSERT(-1 == mShmFd, "Already Create()d");
- mShmFd = aHandle.fd;
- return true;
-}
-
-bool
-SharedMemoryBasic::Create(size_t aNbytes)
-{
- MOZ_ASSERT(-1 == mShmFd, "Already Create()d");
-
- // Carve a new instance off of /dev/ashmem
- int shmfd = open("/" ASHMEM_NAME_DEF, O_RDWR, 0600);
- if (-1 == shmfd) {
- LogError("ShmemAndroid::Create():open");
- return false;
- }
-
- if (ioctl(shmfd, ASHMEM_SET_SIZE, aNbytes)) {
- LogError("ShmemAndroid::Unmap():ioctl(SET_SIZE)");
- close(shmfd);
- return false;
- }
-
- mShmFd = shmfd;
- Created(aNbytes);
- return true;
-}
-
-bool
-SharedMemoryBasic::Map(size_t nBytes)
-{
- MOZ_ASSERT(nullptr == mMemory, "Already Map()d");
-
- mMemory = mmap(nullptr, nBytes,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- mShmFd,
- 0);
- if (MAP_FAILED == mMemory) {
- LogError("ShmemAndroid::Map()");
- mMemory = nullptr;
- return false;
- }
-
- Mapped(nBytes);
- return true;
-}
-
-bool
-SharedMemoryBasic::ShareToProcess(base::ProcessId/*unused*/,
- Handle* aNewHandle)
-{
- MOZ_ASSERT(mShmFd >= 0, "Should have been Create()d by now");
-
- int shmfdDup = dup(mShmFd);
- if (-1 == shmfdDup) {
- LogError("ShmemAndroid::ShareToProcess()");
- return false;
- }
-
- aNewHandle->fd = shmfdDup;
- aNewHandle->auto_close = true;
- return true;
-}
-
-void
-SharedMemoryBasic::Unmap()
-{
- if (!mMemory) {
- return;
- }
-
- if (munmap(mMemory, Size())) {
- LogError("ShmemAndroid::Unmap()");
- }
- mMemory = nullptr;
-}
-
-void
-SharedMemoryBasic::CloseHandle()
-{
- if (mShmFd != -1) {
- close(mShmFd);
- mShmFd = -1;
- }
-}
-
-} // namespace ipc
-} // namespace mozilla
diff --git a/ipc/glue/SharedMemoryBasic_android.h b/ipc/glue/SharedMemoryBasic_android.h
deleted file mode 100644
index 488390d9f5..0000000000
--- a/ipc/glue/SharedMemoryBasic_android.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#ifndef mozilla_ipc_SharedMemoryBasic_android_h
-#define mozilla_ipc_SharedMemoryBasic_android_h
-
-#include "base/file_descriptor_posix.h"
-
-#include "SharedMemory.h"
-
-//
-// This is a low-level wrapper around platform shared memory. Don't
-// use it directly; use Shmem allocated through IPDL interfaces.
-//
-
-namespace mozilla {
-namespace ipc {
-
-class SharedMemoryBasic final : public SharedMemoryCommon<base::FileDescriptor>
-{
-public:
- SharedMemoryBasic();
-
- virtual bool SetHandle(const Handle& aHandle) override;
-
- virtual bool Create(size_t aNbytes) override;
-
- virtual bool Map(size_t nBytes) override;
-
- virtual void CloseHandle() override;
-
- virtual void* memory() const override
- {
- return mMemory;
- }
-
- virtual SharedMemoryType Type() const override
- {
- return TYPE_BASIC;
- }
-
- static Handle NULLHandle()
- {
- return Handle();
- }
-
- virtual bool IsHandleValid(const Handle &aHandle) const override
- {
- return aHandle.fd >= 0;
- }
-
- virtual bool ShareToProcess(base::ProcessId aProcessId,
- Handle* aNewHandle) override;
-
-private:
- ~SharedMemoryBasic();
-
- void Unmap();
-
- // The /dev/ashmem fd we allocate.
- int mShmFd;
- // Pointer to mapped region, null if unmapped.
- void *mMemory;
-};
-
-} // namespace ipc
-} // namespace mozilla
-
-#endif // ifndef mozilla_ipc_SharedMemoryBasic_android_h
diff --git a/ipc/glue/moz.build b/ipc/glue/moz.build
index 85d7f8fa0b..51e6538ffe 100644
--- a/ipc/glue/moz.build
+++ b/ipc/glue/moz.build
@@ -78,15 +78,7 @@ else:
'CrossProcessMutex_unimplemented.cpp',
]
-# Android has its own,
-# almost-but-not-quite-compatible-with-POSIX-or-/dev/shm shared memory
-# impl.
-if CONFIG['OS_TARGET'] == 'Android':
- EXPORTS.mozilla.ipc += ['SharedMemoryBasic_android.h']
- UNIFIED_SOURCES += [
- 'SharedMemoryBasic_android.cpp',
- ]
-elif CONFIG['OS_ARCH'] == 'Darwin':
+if CONFIG['OS_ARCH'] == 'Darwin':
EXPORTS.mozilla.ipc += ['SharedMemoryBasic_mach.h']
SOURCES += [
'SharedMemoryBasic_mach.mm',