mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
Honor ios_is_app_extension chromium build flag
If building for chromium, honor the ios_is_app_extension gn variable that is set per toolchain. When it is defined, the code is built for an application extension (i.e. -fapplication-extension is passed to the compiler). Use CRASHPAD_IS_IOS_APP_EXTENSION build guard to not compile code that use unavailable extension when ios_is_app_extension is set. If the variable is not set, then check at runtime whether the API can be used or not (if the crashpad client uses the same toolchain for the main application and its application extensions). This is required to pass -fapplication-extension to the compiler when building application extensions (which allow catching API that is not available to application extensions). Bug: 40120082 Change-Id: I28d545fcfd0f8662430c40ff202b79b0c2b2ff8b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5286216 Reviewed-by: Justin Cohen <justincohen@chromium.org> Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
This commit is contained in:
parent
c576bf35ea
commit
5075fb617a
@ -72,4 +72,17 @@ if (crashpad_is_ios) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (crashpad_is_in_chromium) {
|
||||||
|
import("//build/config/ios/ios_sdk.gni")
|
||||||
|
crashpad_is_ios_app_extension = ios_is_app_extension
|
||||||
|
} else {
|
||||||
|
crashpad_is_ios_app_extension = false
|
||||||
|
}
|
||||||
|
|
||||||
|
config("crashpad_is_ios_app_extension") {
|
||||||
|
if (crashpad_is_ios_app_extension) {
|
||||||
|
defines = [ "CRASHPAD_IS_IOS_APP_EXTENSION" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,6 +597,10 @@ crashpad_static_library("util") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (crashpad_is_ios) {
|
||||||
|
configs += [ "../build:crashpad_is_ios_app_extension" ]
|
||||||
|
}
|
||||||
|
|
||||||
if (crashpad_is_win) {
|
if (crashpad_is_win) {
|
||||||
libs = [
|
libs = [
|
||||||
"user32.lib",
|
"user32.lib",
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#include "base/apple/mach_logging.h"
|
#include "base/apple/mach_logging.h"
|
||||||
|
#include "base/notreached.h"
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
@ -99,7 +100,14 @@ IOSSystemDataCollector::IOSSystemDataCollector()
|
|||||||
build_ = ReadStringSysctlByName("kern.osversion");
|
build_ = ReadStringSysctlByName("kern.osversion");
|
||||||
bundle_identifier_ =
|
bundle_identifier_ =
|
||||||
base::SysNSStringToUTF8([[NSBundle mainBundle] bundleIdentifier]);
|
base::SysNSStringToUTF8([[NSBundle mainBundle] bundleIdentifier]);
|
||||||
|
// If CRASHPAD_IS_IOS_APP_EXTENSION is defined, then the code is compiled with
|
||||||
|
// -fapplication-extension and can only be used in an app extension. Otherwise
|
||||||
|
// check at runtime whether the code is executing in an app extension or not.
|
||||||
|
#if defined(CRASHPAD_IS_IOS_APP_EXTENSION)
|
||||||
|
is_extension_ = true;
|
||||||
|
#else
|
||||||
is_extension_ = [[NSBundle mainBundle].bundlePath hasSuffix:@"appex"];
|
is_extension_ = [[NSBundle mainBundle].bundlePath hasSuffix:@"appex"];
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ARCH_CPU_X86_64)
|
#if defined(ARCH_CPU_X86_64)
|
||||||
cpu_vendor_ = ReadStringSysctlByName("machdep.cpu.vendor");
|
cpu_vendor_ = ReadStringSysctlByName("machdep.cpu.vendor");
|
||||||
@ -172,6 +180,7 @@ void IOSSystemDataCollector::InstallHandlers() {
|
|||||||
(__bridge CFStringRef)UIDeviceOrientationDidChangeNotification, this);
|
(__bridge CFStringRef)UIDeviceOrientationDidChangeNotification, this);
|
||||||
OrientationDidChangeNotification();
|
OrientationDidChangeNotification();
|
||||||
|
|
||||||
|
#if !defined(CRASHPAD_IS_IOS_APP_EXTENSION)
|
||||||
// Foreground/Background. Extensions shouldn't use UIApplication*.
|
// Foreground/Background. Extensions shouldn't use UIApplication*.
|
||||||
if (!is_extension_) {
|
if (!is_extension_) {
|
||||||
AddObserver<
|
AddObserver<
|
||||||
@ -185,6 +194,7 @@ void IOSSystemDataCollector::InstallHandlers() {
|
|||||||
this);
|
this);
|
||||||
ApplicationDidChangeActiveNotification();
|
ApplicationDidChangeActiveNotification();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOSSystemDataCollector::SystemTimeZoneDidChangeNotification() {
|
void IOSSystemDataCollector::SystemTimeZoneDidChangeNotification() {
|
||||||
@ -228,6 +238,9 @@ void IOSSystemDataCollector::OrientationDidChangeNotification() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IOSSystemDataCollector::ApplicationDidChangeActiveNotification() {
|
void IOSSystemDataCollector::ApplicationDidChangeActiveNotification() {
|
||||||
|
#if defined(CRASHPAD_IS_IOS_APP_EXTENSION)
|
||||||
|
NOTREACHED_NORETURN();
|
||||||
|
#else
|
||||||
dispatch_assert_queue_debug(dispatch_get_main_queue());
|
dispatch_assert_queue_debug(dispatch_get_main_queue());
|
||||||
bool old_active = active_;
|
bool old_active = active_;
|
||||||
active_ = [UIApplication sharedApplication].applicationState ==
|
active_ = [UIApplication sharedApplication].applicationState ==
|
||||||
@ -235,6 +248,7 @@ void IOSSystemDataCollector::ApplicationDidChangeActiveNotification() {
|
|||||||
if (active_ != old_active && active_application_callback_) {
|
if (active_ != old_active && active_application_callback_) {
|
||||||
active_application_callback_(active_);
|
active_application_callback_(active_);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user