summaryrefslogtreecommitdiff
path: root/base/message_loop/message_loop.cc
diff options
context:
space:
mode:
authorhscham <hscham@google.com>2020-05-07 13:50:12 +0900
committerQijiang Fan <fqj@google.com>2020-06-06 03:51:05 +0900
commit866a61d36b2de6d3ad3f799434f82113db5d475f (patch)
tree90d5f3bf638779874d89f7b9ade99479d8e75665 /base/message_loop/message_loop.cc
parent28c27b86b6d3ad3cc57b63a9b0b8fd272a496db0 (diff)
downloadlibchrome-866a61d36b2de6d3ad3f799434f82113db5d475f.tar.gz
libchrome: build libchrome on Android target with OS_ANDROID
Android target is now built with OS_ANDROID. Note __ANDROID__ remains defined by the Android toolchain when building for Android target. (For Android hosts, __ANDROID_HOST__ and __linux__ is defined, and OS_LINUX is used. This is not in the scope of this CL.) In the original Chromium browser code, OS_ANDROID is used to build the browser on Android. With this change, most local libchrome patches that changed "\#if defined(OS_ANDROID)" to "\#if defined(OS_ANDROID) || defined(__ANDROID__)" (or the negation) are removed which simplifies maintenance. Note there is code that applies to Chromium browser on Android but not libchrome on Android targets. Since for libchrome, OS_ANDROID implies the latter and never the former, to avoid confusion caused by use of macros if-else, those cases are now guarded by "\#if defined(OS_ANDROID) && 0" (or equivalent logic). In Android.bp, some Android specific code are added to the source list and the conflicting posix specific code are excluded when building for Android. Necessary dependencies are also added. Android specific code (e.g. base/memory/platform_shared_memory_region_android.cc) introduces use of ashmem_get_prot_region which is not implemented in Android libcutils. Since ashmem is largely deprecated in upstream (migiration to memfd is on-going), add local implementation to third_party/ashmem/ashmem.h. (See b/153118750 for detailed discussion.) trace_event is not supported in libchrome. To maintain build compatibility, in base/trace_event/trace_event.h, more empty trace macros are defined. To avoid includes of more trace_event code by base/memory/shared_memory_tracker.h, in (its only usage in) b/m/platform_shared_memory_region_android.cc, replace SharedMemoryTracker::GetDumpNameForTracing by the actual implementation. Support for MessageLoopForUI is dropped to avoid dependency on libandroid ALooper. The Android UI thread is tied to the Android framework and is not used. Bug: 109925343 Test: presumbit Test: cherry-picked to ChromeOS libchrome, passes pre-CQ Change-Id: Ib698eaccb1741c7c9cdba8452a967caa788bb547 Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/external/libchrome/+/2220416 Reviewed-by: Hidehiko Abe <hidehiko@chromium.org> Commit-Queue: Qijiang Fan <fqj@google.com> Tested-by: Qijiang Fan <fqj@google.com> (Reconstructed from 144774bb4c8d73cc610760d7826ed43a9076b99a)
Diffstat (limited to 'base/message_loop/message_loop.cc')
-rw-r--r--base/message_loop/message_loop.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index b3e32de0ef..9149a672d9 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -243,6 +243,7 @@ bool MessageLoop::InitMessagePumpForUIFactory(MessagePumpFactory* factory) {
// static
std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
+#if !defined(OS_ANDROID)
if (type == MessageLoop::TYPE_UI) {
if (message_pump_for_ui_factory_)
return message_pump_for_ui_factory_();
@@ -257,11 +258,12 @@ std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
return std::make_unique<MessagePumpForUI>();
#endif
}
+#endif
if (type == MessageLoop::TYPE_IO)
return std::unique_ptr<MessagePump>(new MessagePumpForIO());
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) && 0
if (type == MessageLoop::TYPE_JAVA)
return std::unique_ptr<MessagePump>(new MessagePumpForUI());
#endif
@@ -360,7 +362,7 @@ void MessageLoop::BindToCurrentThread() {
RunLoop::RegisterDelegateForCurrentThread(this);
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) && 0
// On Android, attach to the native loop when there is one.
if (type_ == TYPE_UI || type_ == TYPE_JAVA)
static_cast<MessagePumpForUI*>(pump_.get())->Attach(this);
@@ -674,7 +676,7 @@ bool MessageLoop::DoIdleWork() {
return false;
}
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(OS_ANDROID)
//------------------------------------------------------------------------------
// MessageLoopForUI
@@ -724,7 +726,7 @@ void MessageLoopForUI::EnableWmQuit() {
}
#endif // defined(OS_WIN)
-#endif // !defined(OS_NACL)
+#endif // !defined(OS_NACL) && !defined(OS_ANDROID)
//------------------------------------------------------------------------------
// MessageLoopForIO