0

Refactor OS_LINUX preprocessor directive for LaCrOS effort.

Currently, ChromeOS defines the OS_LINUX directive as well as
OS_CHROMEOS.  We're working to separate these two, so we're
making the fact that OS_LINUX == OS_LINUX || OS_CHROMEOS
explicit.

Bug: 1110266
Change-Id: I5aedb1ceaad41242f4a51d450704027dcb0c046e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352022
Commit-Queue: Sean McAllister <smcallis@google.com>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799843}
This commit is contained in:
Sean McAllister
2020-08-19 23:00:48 +00:00
committed by Commit Bot
parent 7b017b01b7
commit b9ad65a619
38 changed files with 109 additions and 104 deletions

@ -11,7 +11,7 @@
#include "base/allocator/winheap_stubs_win.h"
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#include <malloc.h>
#endif
@ -27,8 +27,8 @@ bool IsAllocatorInitialized() {
// Set by allocator_shim_override_ucrt_symbols_win.h when the
// shimmed _set_new_mode() is called.
return g_is_win_shim_layer_initialized;
#elif defined(OS_LINUX) && BUILDFLAG(USE_TCMALLOC) && \
!defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
#elif (defined(OS_LINUX) || defined(OS_CHROMEOS)) && \
BUILDFLAG(USE_TCMALLOC) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
// From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h.
// TODO(primiano): replace with an include once base can depend on allocator.
#define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42

@ -558,7 +558,7 @@ static size_t GetAllocatedSize(void* ptr) {
static size_t GetAllocatedSize(void* ptr) {
return malloc_size(ptr);
}
#elif defined(OS_LINUX)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
static size_t GetAllocatedSize(void* ptr) {
return malloc_usable_size(ptr);
}

@ -109,7 +109,7 @@ void ChromeCrashReporterClient::GetProductNameAndVersion(
*product_name = "Chrome_ChromeOS";
#elif BUILDFLAG(IS_LACROS)
*product_name = "Chrome_Lacros";
#else // OS_LINUX
#else // defined(OS_LINUX
#if !defined(ADDRESS_SANITIZER)
*product_name = "Chrome_Linux";
#else
@ -142,12 +142,12 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation(
return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir);
}
#if defined(OS_MAC) || defined(OS_LINUX)
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
bool ChromeCrashReporterClient::GetCrashMetricsLocation(
base::FilePath* metrics_dir) {
return base::PathService::Get(chrome::DIR_USER_DATA, metrics_dir);
}
#endif // OS_MAC || OS_LINUX
#endif // defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
bool ChromeCrashReporterClient::IsRunningUnattended() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
@ -199,14 +199,14 @@ int ChromeCrashReporterClient::GetAndroidMinidumpDescriptor() {
}
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
bool ChromeCrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
// TODO(jperaza): Turn this on less frequently for stable channels when
// Crashpad is always enabled on Linux. Consider combining with the
// macOS implementation.
return true;
}
#endif // OS_LINUX
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
bool ChromeCrashReporterClient::EnableBreakpadForProcess(
const std::string& process_type) {

@ -43,7 +43,7 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
#if defined(OS_MAC) || defined(OS_LINUX)
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
bool GetCrashMetricsLocation(base::FilePath* metrics_dir) override;
#endif
@ -59,7 +59,7 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
int GetAndroidMinidumpDescriptor() override;
#endif
#if defined(OS_MAC) || defined(OS_LINUX)
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
bool ShouldMonitorCrashHandlerExpensively() override;
#endif

@ -294,7 +294,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppPpapiTest, SendFilesystem) {
// Test is flaky, it fails on certain bots, namely WinXP Tests(1) and Linux
// (dbg)(1)(32). See crbug.com/354425.
#if defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_MediaGalleriesNoAccess DISABLED_MediaGalleriesNoAccess
#else
#define MAYBE_MediaGalleriesNoAccess MediaGalleriesNoAccess
@ -332,7 +332,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
// Test is flaky, it fails on certain bots, namely WinXP Tests(1) and Linux
// (dbg)(1)(32). See crbug.com/354425.
#if defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_MediaGalleriesCopyTo DISABLED_MediaGalleriesCopyTo
#else
#define MAYBE_MediaGalleriesCopyTo MediaGalleriesCopyTo

@ -43,7 +43,7 @@ const ProtocolHandler& LookupHandler(
// If true default protocol handlers will be removed if the OS level
// registration for a protocol is no longer Chrome.
bool ShouldRemoveHandlersNotInOS() {
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// We don't do this on Linux as the OS registration there is not reliable,
// and Chrome OS doesn't have any notion of OS registration.
// TODO(benwells): When Linux support is more reliable remove this

@ -660,7 +660,7 @@ TEST_F(ProtocolHandlerRegistryTest, TestOSRegistration) {
registry()->OnAcceptRegisterProtocolHandler(ph_do2);
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// TODO(benwells): When Linux support is more reliable and
// http://crbug.com/88255 is fixed this test will pass.
#define MAYBE_TestOSRegistrationFailure DISABLED_TestOSRegistrationFailure

@ -1985,7 +1985,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnsubscribeSuccess) {
// Push subscriptions used to be non-InstanceID GCM registrations. Still need
// to be able to unsubscribe these, even though new ones are no longer created.
// Flaky on some Win and Linux buildbots. See crbug.com/835382.
#if defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_LegacyUnsubscribeSuccess DISABLED_LegacyUnsubscribeSuccess
#else
#define MAYBE_LegacyUnsubscribeSuccess LegacyUnsubscribeSuccess

@ -676,7 +676,8 @@ void IncidentReportingService::OnEnvironmentDataCollected(
environment_collection_pending_ = false;
// Process::Current().CreationTime() is missing on some platforms.
#if defined(OS_MAC) || defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_MAC) || defined(OS_WIN) || defined(OS_LINUX) || \
defined(OS_CHROMEOS)
base::TimeDelta uptime =
first_incident_time_ - base::Process::Current().CreationTime();
environment_data->mutable_process()->set_uptime_msec(uptime.InMilliseconds());

@ -289,7 +289,7 @@ IN_PROC_BROWSER_TEST_F(NtpExtensionBubbleViewBrowserTest,
}
// Flaky on Mac https://crbug.com/851655
#if defined(OS_MAC) || defined(OS_LINUX)
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_TestBubbleClosedAfterExtensionUninstall \
DISABLED_TestBubbleClosedAfterExtensionUninstall
#else

@ -183,7 +183,8 @@ TEST_F(ToolbarActionViewUnitTest,
// Test the basic ui of a ToolbarActionView and that it responds correctly to
// a controller's state.
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_WIN)
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
defined(OS_WIN)
// TODO(crbug.com/1042220): Test is flaky on Mac, Linux and Win10.
#define MAYBE_BasicToolbarActionViewTest DISABLED_BasicToolbarActionViewTest
#else

@ -15,7 +15,7 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_structs.h"
#if defined(OS_LINUX) || defined(OS_OPENBSD)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OPENBSD)
#include "components/services/font/public/cpp/font_loader.h"
#include "content/public/common/common_sandbox_support_linux.h"
#elif defined(OS_WIN)
@ -29,7 +29,7 @@ PepperFlashFontFileHost::PepperFlashFontFileHost(
const ppapi::proxy::SerializedFontDescription& description,
PP_PrivateFontCharset charset)
: ResourceHost(host->GetPpapiHost(), instance, resource) {
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// The global SkFontConfigInterface is configured and initialized with a
// SkFontconfigInterface compatible font_service::FontLoader in
// RendererBlinkPlatformImpl (called from RenderThreadImpl::Init) at startup
@ -74,7 +74,7 @@ bool PepperFlashFontFileHost::GetFontData(uint32_t table,
void* buffer,
size_t* length) {
bool result = false;
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
if (font_file_.IsValid()) {
result = content::GetFontTable(font_file_.GetPlatformFile(), table,
0 /* offset */,

@ -14,7 +14,7 @@
#include "ppapi/c/private/pp_private_font_charset.h"
#include "ppapi/host/resource_host.h"
#if defined(OS_LINUX) || defined(OS_OPENBSD)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OPENBSD)
#include "base/files/file.h"
#elif defined(OS_WIN)
#include "third_party/skia/include/core/SkRefCnt.h"
@ -50,7 +50,7 @@ class PepperFlashFontFileHost : public ppapi::host::ResourceHost {
uint32_t table);
bool GetFontData(uint32_t table, void* buffer, size_t* length);
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
base::File font_file_;
#elif defined(OS_WIN)
sk_sp<SkTypeface> typeface_;

@ -125,7 +125,8 @@ using content::RenderViewHost;
#else
#define MAYBE_PPAPI_NACL(test_name) test_name
#if defined(OS_WIN) || defined(OS_LINUX) || defined(ADDRESS_SANITIZER)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
defined(ADDRESS_SANITIZER)
// http://crbug.com/633067, http://crbug.com/727989
#define MAYBE_PPAPI_PNACL(test_name) DISABLED_##test_name
#else
@ -1469,7 +1470,7 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClNewlibTest, MAYBE_PPAPI_NACL(URLLoader3)) {
}
// Flaky on 32-bit linux bot; http://crbug.com/308906
#if defined(OS_LINUX) && defined(ARCH_CPU_X86)
#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86)
#define MAYBE_URLLoader_BasicFilePOST DISABLED_URLLoader_BasicFilePOST
#else
#define MAYBE_URLLoader_BasicFilePOST URLLoader_BasicFilePOST
@ -1745,7 +1746,7 @@ TEST_PPAPI_NACL(MAYBE_FileSystem)
#if defined(OS_MAC)
// http://crbug.com/103912
#define MAYBE_Fullscreen DISABLED_Fullscreen
#elif defined(OS_LINUX)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
// http://crbug.com/146008
#define MAYBE_Fullscreen DISABLED_Fullscreen
#elif defined(OS_WIN)
@ -1969,7 +1970,7 @@ TEST_PPAPI_NACL(AudioEncoder)
LIST_TEST(Audio_AudioCallback4) \
)
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// http://crbug.com/396464
#define MAYBE_Audio DISABLED_Audio
#else
@ -2128,7 +2129,7 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClPNaClNonSfiTest, MAYBE_PNACL_NONSFI(View)) {
)
// Disabled due to flakiness http://crbug.com/1036287
#if defined(OS_LINUX) || defined(OS_MAC)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC)
#define MAYBE_FlashMessageLoop DISABLED_FlashMessageLoop
#else
#define MAYBE_FlashMessageLoop FlashMessageLoop
@ -2224,7 +2225,7 @@ TEST_PPAPI_NACL(MAYBE_VideoEncoder)
TEST_PPAPI_OUT_OF_PROCESS(Printing)
// https://crbug.com/1038957.
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_MessageHandler DISABLED_MessageHandler
#else
#define MAYBE_MessageHandler MessageHandler
@ -2339,7 +2340,7 @@ IN_PROC_BROWSER_TEST_F(NewlibPackagedAppTest,
RunTests("packaged_app");
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// http://crbug.com/579804
#define MAYBE_SuccessfulLoad DISABLED_SuccessfulLoad
#else

@ -17,7 +17,7 @@
// See bug for history.
// Flaky on Win/Mac, http://crbug.com/1048148.
#if defined(ADDRESS_SANITIZER) || defined(OS_WIN) || defined(OS_MAC) || \
defined(OS_LINUX)
defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_MouseLock_SucceedWhenAllowed DISABLED_MouseLock_SucceedWhenAllowed
#else
#define MAYBE_MouseLock_SucceedWhenAllowed MouseLock_SucceedWhenAllowed

@ -177,7 +177,7 @@ bool CrashReporterClient::ShouldWriteMinidumpToLog() {
#endif
#if defined(OS_ANDROID) || defined(OS_LINUX)
#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)
void CrashReporterClient::GetSanitizationInformation(
const char* const** allowed_annotations,
void** target_module,

@ -170,7 +170,7 @@ class CrashReporterClient {
virtual bool ShouldWriteMinidumpToLog();
#endif
#if defined(OS_ANDROID) || defined(OS_LINUX)
#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)
// Configures sanitization of crash dumps.
// |allowed_annotations| is a nullptr terminated array of NUL-terminated
// strings of allowed annotation names or nullptr if all annotations are

@ -15,7 +15,7 @@ namespace switches {
// is a standalone executable.
const char kCrashpadHandler[] = "crashpad-handler";
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// The process ID of the Crashpad handler.
const char kCrashpadHandlerPid[] = "crashpad-handler-pid";
#endif

@ -12,9 +12,9 @@ namespace switches {
extern const char kCrashpadHandler[];
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
extern const char kCrashpadHandlerPid[];
#endif // OS_LINUX
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS)
extern const char kCrashLoopBefore[];

@ -123,7 +123,7 @@ void InitializeCrashpadImpl(bool initial_client,
DCHECK(browser_process || process_type == "Chrome Installer" ||
process_type == "notification-helper" ||
process_type == "GCPW Installer" || process_type == "GCPW DLL");
#elif defined(OS_LINUX) || defined(OS_ANDROID)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
DCHECK(browser_process);
#else
#error Port.
@ -191,7 +191,7 @@ void InitializeCrashpadImpl(bool initial_client,
// other "main, first process" to initialize things. There is no "relauncher"
// on Windows, so this is synonymous with initial_client.
const bool should_initialize_database_and_set_upload_policy = initial_client;
#elif defined(OS_LINUX) || defined(OS_ANDROID)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
const bool should_initialize_database_and_set_upload_policy = browser_process;
#endif
if (should_initialize_database_and_set_upload_policy) {
@ -280,11 +280,11 @@ void DumpWithoutCrashing() {
}
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
void CrashWithoutDumping(const std::string& message) {
crashpad::CrashpadClient::CrashWithoutDump(message);
}
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
void GetReports(std::vector<Report>* reports) {
#if defined(OS_WIN)

@ -22,7 +22,7 @@
#include <windows.h>
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#include <signal.h>
#endif
@ -37,7 +37,7 @@ class CrashReportDatabase;
namespace crash_reporter {
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// TODO(jperaza): Remove kEnableCrashpad and IsCrashpadEnabled() when Crashpad
// is fully enabled on Linux.
extern const char kEnableCrashpad[];
@ -151,11 +151,11 @@ void RequestSingleCrashUpload(const std::string& local_id);
void DumpWithoutCrashing();
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
// Logs message and immediately crashes the current process without triggering a
// crash dump.
void CrashWithoutDumping(const std::string& message);
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
// Returns the Crashpad database path, only valid in the browser.
base::FilePath GetCrashpadDatabasePath();
@ -193,7 +193,7 @@ bool DumpWithoutCrashingForClient(CrashReporterClient* client);
void AllowMemoryRange(void* begin, size_t size);
#endif // OS_ANDROID
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// Install a handler that gets a chance to handle faults before Crashpad. This
// is used by V8 for trap-based bounds checks.
void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*));
@ -201,7 +201,7 @@ void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*));
// Gets the socket and process ID of the Crashpad handler connected to this
// process, valid if this function returns `true`.
bool GetHandlerSocket(int* sock, pid_t* pid);
#endif // OS_LINUX
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
namespace internal {

@ -33,7 +33,7 @@
#include "components/discardable_memory/common/discardable_shared_memory_heap.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros.h"
@ -176,7 +176,7 @@ int64_t GetDefaultMemoryLimit() {
max_default_memory_limit /= 8;
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
base::FilePath shmem_dir;
if (base::GetShmemTempDir(false, &shmem_dir)) {
int64_t shmem_dir_amount_of_free_space =

@ -68,7 +68,7 @@ void HistogramEnumerateOsArch(const std::string& sandbox_isa) {
};
NaClOSArch os_arch = kNaClOSArchMax;
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
os_arch = kNaClLinux32;
#elif defined(OS_MAC)
os_arch = kNaClMac32;

@ -132,7 +132,7 @@
#endif // OS_POSIX || OS_FUCHSIA
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "base/native_library.h"
#include "base/rand_util.h"
#include "content/public/common/zygote/sandbox_support_linux.h"
@ -152,7 +152,7 @@
#include "content/public/common/content_client.h"
#endif
#endif // OS_LINUX
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(USE_ZYGOTE_HANDLE)
#include "content/browser/sandbox_host_linux.h"
@ -301,7 +301,7 @@ void InitializeZygoteSandboxForBrowserProcess(
}
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_PLUGINS)
// Loads the (native) libraries but does not initialize them (i.e., does not
@ -392,7 +392,7 @@ void PreSandboxInit() {
}
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
#endif // OS_LINUX
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
class ControlInterfaceBinderImpl : public mojo_base::mojom::Binder {
public:
@ -473,7 +473,7 @@ int RunZygote(ContentMainDelegate* delegate) {
delegate->ZygoteStarting(&zygote_fork_delegates);
media::InitializeMediaLibrary();
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
PreSandboxInit();
#endif
@ -617,11 +617,11 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) {
base::GlobalDescriptors::kBaseDescriptor);
#endif // !OS_ANDROID
#if defined(OS_LINUX) || defined(OS_OPENBSD)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OPENBSD)
g_fds->Set(service_manager::kCrashDumpSignal,
service_manager::kCrashDumpSignal +
base::GlobalDescriptors::kBaseDescriptor);
#endif // OS_LINUX || OS_OPENBSD
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OPENBSD)
#endif // !OS_WIN
@ -853,7 +853,7 @@ int ContentMainRunnerImpl::Run(bool start_service_manager_only) {
delegate_->PostFieldTrialInitialization();
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// If dynamic Mojo Core is being used, ensure that it's loaded very early in
// the child/zygote process, before any sandbox is initialized. The library
// is not fully initialized with IPC support until a ChildProcess is later
@ -863,7 +863,7 @@ int ContentMainRunnerImpl::Run(bool start_service_manager_only) {
CHECK_EQ(mojo::LoadCoreLibrary(GetMojoCoreSharedLibraryPath()),
MOJO_RESULT_OK);
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
}
MainFunctionParams main_params(command_line);

@ -2950,7 +2950,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_RemoveResumedDownload) {
}
// TODO(qinmin): Flaky crashes on ASAN Linux. https://crbug.com/836689
#if defined(OS_LINUX) && defined(ADDRESS_SANITIZER)
#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ADDRESS_SANITIZER)
#define MAYBE_CancelResumedDownload DISABLED_CancelResumedDownload
#else
#define MAYBE_CancelResumedDownload CancelResumedDownload

@ -433,7 +433,7 @@ void PepperFileIOHost::OnLocalFileOpened(
ppapi::host::ReplyMessageContext reply_context,
const base::FilePath& path,
base::File::Error error_code) {
#if defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
// Quarantining a file before its contents are available is only supported on
// Windows and Linux.
if (!FileOpenForWrite(open_flags_) || error_code != base::File::FILE_OK) {
@ -454,7 +454,7 @@ void PepperFileIOHost::OnLocalFileOpened(
#endif
}
#if defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
void PepperFileIOHost::OnLocalFileQuarantined(
ppapi::host::ReplyMessageContext reply_context,
const base::FilePath& path,

@ -28,9 +28,9 @@
#if BUILDFLAG(ENABLE_NACL)
#include "components/nacl/common/nacl_switches.h" // nogncheck
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "components/nacl/common/nacl_paths.h" // nogncheck
#endif // OS_LINUX
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#if defined(OS_POSIX) && !defined(OS_MAC) && !defined(OS_ANDROID)
#include "components/nacl/zygote/nacl_fork_delegate_linux.h"
#endif // OS_POSIX && !OS_MAC && !OS_ANDROID
@ -38,7 +38,7 @@
#if defined(OS_WIN)
#include "base/base_paths_win.h"
#elif defined(OS_LINUX)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "base/nix/xdg_util.h"
#elif defined(OS_MAC)
#include "base/base_paths_mac.h"
@ -70,7 +70,7 @@ base::FilePath GetDataPath() {
return cmd_line->GetSwitchValuePath(switches::kContentShellDataPath);
base::FilePath data_dir;
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
std::unique_ptr<base::Environment> env(base::Environment::Create());
data_dir = base::nix::GetXDGDirectory(
env.get(), base::nix::kXdgConfigHomeEnvVar, base::nix::kDotConfigDir);
@ -138,7 +138,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
#if defined(OS_CHROMEOS)
chromeos::RegisterPathProvider();
#endif
#if BUILDFLAG(ENABLE_NACL) && defined(OS_LINUX)
#if BUILDFLAG(ENABLE_NACL) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
nacl::RegisterPathProvider();
#endif
extensions::RegisterPathProvider();

@ -56,7 +56,7 @@
#include "extensions/shell/browser/shell_network_controller_chromeos.h"
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#endif
@ -65,7 +65,7 @@
#include "chromeos/dbus/audio/cras_audio_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power/power_manager_client.h"
#elif defined(OS_LINUX)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#endif

@ -136,7 +136,7 @@ double FlashResource::GetLocalTimeZoneOffset(PP_Instance instance,
// require filesystem access prohibited by the sandbox.
// TODO(shess): Figure out why OSX needs the access, the sandbox warmup should
// handle it. http://crbug.com/149006
#if defined(OS_LINUX) || defined(OS_MAC)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC)
int32_t result = SyncCall<PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply>(
BROWSER,
PpapiHostMsg_Flash_GetLocalTimeZoneOffset(PPTimeToTime(t)),

@ -442,7 +442,7 @@ TEST_F(CoordinatorImplTest, TimeOutStuckChildMultiProcess) {
// This ifdef is here to match the sandboxing behavior of the client.
// On Linux, all memory dumps come from the browser client. On all other
// platforms, they are expected to come from each individual client.
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
EXPECT_CALL(browser_client,
RequestOSMemoryDumpMock(
_, AllOf(Contains(kBrowserPid), Contains(kRendererPid)), _))
@ -472,7 +472,7 @@ TEST_F(CoordinatorImplTest, TimeOutStuckChildMultiProcess) {
results[0] = FillRawOSDump(kRendererPid);
std::move(callback).Run(true, std::move(results));
}));
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
// Make the browser respond correctly but pretend the renderer is "stuck"
// by storing a callback.
@ -619,7 +619,7 @@ TEST_F(CoordinatorImplTest, GlobalMemoryDumpStruct) {
MemoryAllocatorDump::kUnitsBytes, 1024 * 2);
std::move(callback).Run(true, args.dump_guid, std::move(pmd));
}));
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
EXPECT_CALL(browser_client,
RequestOSMemoryDumpMock(_, AllOf(Contains(1), Contains(2)), _))
.WillOnce(Invoke(
@ -660,7 +660,7 @@ TEST_F(CoordinatorImplTest, GlobalMemoryDumpStruct) {
results[0]->resident_set_kb = 2;
std::move(callback).Run(true, std::move(results));
}));
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
MockGlobalMemoryDumpCallback callback;
EXPECT_CALL(callback, OnCall(true, NotNull()))
@ -704,7 +704,7 @@ TEST_F(CoordinatorImplTest, VmRegionsForHeapProfiler) {
// This ifdef is here to match the sandboxing behavior of the client.
// On Linux, all memory dumps come from the browser client. On all other
// platforms, they are expected to come from each individual client.
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
EXPECT_CALL(browser_client,
RequestOSMemoryDumpMock(
_, AllOf(Contains(kBrowserPid), Contains(kRendererPid)), _))
@ -734,7 +734,7 @@ TEST_F(CoordinatorImplTest, VmRegionsForHeapProfiler) {
results[0] = FillRawOSDump(kRendererPid);
std::move(callback).Run(true, std::move(results));
}));
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
MockGetVmRegionsForHeapProfilerCallback callback;
EXPECT_CALL(callback, OnCall(_))
@ -866,7 +866,7 @@ TEST_F(CoordinatorImplTest, DumpByPidSuccess) {
// This ifdef is here to match the sandboxing behavior of the client.
// On Linux, all memory dumps come from the browser client. On all other
// platforms, they are expected to come from each individual client.
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
EXPECT_CALL(client_process_1, RequestOSMemoryDumpMock(_, _, _))
.WillOnce(Invoke(
[](mojom::MemoryMapOption, const std::vector<base::ProcessId>& pids,
@ -914,7 +914,7 @@ TEST_F(CoordinatorImplTest, DumpByPidSuccess) {
results[0] = FillRawOSDump(kGpuPid);
std::move(callback).Run(true, std::move(results));
}));
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
base::RunLoop run_loop;

@ -43,7 +43,7 @@ namespace {
uint32_t CalculatePrivateFootprintKb(const mojom::RawOSMemDump& os_dump,
uint32_t shared_resident_kb) {
DCHECK(os_dump.platform_private_footprint);
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
uint64_t rss_anon_bytes = os_dump.platform_private_footprint->rss_anon_bytes;
uint64_t vm_swap_bytes = os_dump.platform_private_footprint->vm_swap_bytes;
return (rss_anon_bytes + vm_swap_bytes) / 1024;
@ -82,7 +82,7 @@ memory_instrumentation::mojom::OSMemDumpPtr CreatePublicOSDump(
os_dump->is_peak_rss_resettable = internal_os_dump.is_peak_rss_resettable;
os_dump->private_footprint_kb =
CalculatePrivateFootprintKb(internal_os_dump, shared_resident_kb);
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
os_dump->private_footprint_swap_kb =
internal_os_dump.platform_private_footprint->vm_swap_bytes / 1024;
#endif
@ -243,12 +243,12 @@ void QueuedRequestDispatcher::SetUpAndDispatch(
// On most platforms each process can dump data about their own process
// so ask each process to do so Linux is special see below.
#if !defined(OS_LINUX)
#if !defined(OS_LINUX) && !defined(OS_CHROMEOS)
request->pending_responses.insert({client_info.pid, ResponseType::kOSDump});
client->RequestOSMemoryDump(request->memory_map_option(),
{base::kNullProcessId},
base::BindOnce(os_callback, client_info.pid));
#endif // !defined(OS_LINUX)
#endif // !defined(OS_LINUX) && !defined(OS_CHROMEOS)
// If we are in the single pid case, then we've already found the only
// process we're looking for.
@ -258,7 +258,7 @@ void QueuedRequestDispatcher::SetUpAndDispatch(
// In some cases, OS stats can only be dumped from a privileged process to
// get around to sandboxing/selinux restrictions (see crbug.com/461788).
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
std::vector<base::ProcessId> pids;
mojom::ClientProcess* browser_client = nullptr;
base::ProcessId browser_client_pid = base::kNullProcessId;
@ -283,7 +283,7 @@ void QueuedRequestDispatcher::SetUpAndDispatch(
browser_client->RequestOSMemoryDump(request->memory_map_option(), pids,
std::move(callback));
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
// In this case, we have not found the pid we are looking for so increment
// the failed dump count and exit.
@ -302,7 +302,7 @@ void QueuedRequestDispatcher::SetUpAndDispatchVmRegionRequest(
const OsCallback& os_callback) {
// On Linux, OS stats can only be dumped from a privileged process to
// get around to sandboxing/selinux restrictions (see crbug.com/461788).
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
mojom::ClientProcess* browser_client = nullptr;
base::ProcessId browser_client_pid = 0;
for (const auto& client_info : clients) {
@ -337,7 +337,7 @@ void QueuedRequestDispatcher::SetUpAndDispatchVmRegionRequest(
base::BindOnce(os_callback, client_info.pid));
}
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
}
// static
@ -353,7 +353,7 @@ QueuedRequestDispatcher::FinalizeVmRegionRequest(
// each client process provides 1 OS dump, % the case where the client is
// disconnected mid dump.
OSMemDumpMap& extra_os_dumps = response.second.os_dumps;
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
for (auto& kv : extra_os_dumps) {
auto pid = kv.first == base::kNullProcessId ? original_pid : kv.first;
DCHECK(results.find(pid) == results.end());
@ -414,7 +414,7 @@ void QueuedRequestDispatcher::Finalize(QueuedRequest* request,
// crash). In the latter case (OS_LINUX) we expect the full map to come
// from the browser process response.
OSMemDumpMap& extra_os_dumps = response.second.os_dumps;
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
for (const auto& kv : extra_os_dumps) {
auto pid = kv.first == base::kNullProcessId ? original_pid : kv.first;
DCHECK_EQ(pid_to_os_dump[pid], nullptr);

@ -45,9 +45,9 @@ class COMPONENT_EXPORT(
mojom::RawOSMemDump*);
static std::vector<mojom::VmRegionPtr> GetProcessMemoryMaps(base::ProcessId);
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
static void SetProcSmapsForTesting(FILE*);
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
private:
FRIEND_TEST_ALL_PREFIXES(OSMetricsTest, ParseProcSmaps);
@ -61,7 +61,7 @@ class COMPONENT_EXPORT(
static std::vector<mojom::VmRegionPtr> GetProcessModules(base::ProcessId);
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
// Provides information on the dump state of resident pages. These values are
// written to logs. New enum values can be added, but existing enums must
// never be renumbered or deleted and reused.
@ -96,7 +96,7 @@ class COMPONENT_EXPORT(
// TODO(chiniforooshan): move to /base/process/process_metrics_linux.cc after
// making sure that peak RSS is useful.
static size_t GetPeakResidentSetSize(base::ProcessId pid);
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
};
} // namespace memory_instrumentation

@ -22,13 +22,13 @@
#include <windows.h>
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
#include <sys/mman.h>
#endif
namespace memory_instrumentation {
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
namespace {
const char kTestSmaps1[] =
"00400000-004be000 r-xp 00000000 fc:01 1234 /file/1\n"
@ -128,7 +128,7 @@ void CreateTempFileWithContents(const char* contents, base::ScopedFILE* file) {
}
} // namespace
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
TEST(OSMetricsTest, GivesNonZeroResults) {
base::ProcessId pid = base::kNullProcessId;
@ -136,7 +136,8 @@ TEST(OSMetricsTest, GivesNonZeroResults) {
dump.platform_private_footprint = mojom::PlatformPrivateFootprint::New();
EXPECT_TRUE(OSMetrics::FillOSMemoryDump(pid, &dump));
EXPECT_TRUE(dump.platform_private_footprint);
#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FUCHSIA)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \
defined(OS_FUCHSIA)
EXPECT_GT(dump.platform_private_footprint->rss_anon_bytes, 0u);
#elif defined(OS_WIN)
EXPECT_GT(dump.platform_private_footprint->private_bytes, 0u);
@ -145,7 +146,7 @@ TEST(OSMetricsTest, GivesNonZeroResults) {
#endif
}
#if defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
TEST(OSMetricsTest, ParseProcSmaps) {
const uint32_t kProtR = mojom::VmRegion::kProtectionFlagsRead;
const uint32_t kProtW = mojom::VmRegion::kProtectionFlagsWrite;
@ -252,7 +253,7 @@ TEST(OSMetricsTest, GetMappedAndResidentPages) {
EXPECT_EQ(pages == accessed_pages_set, true);
}
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
#if defined(OS_WIN)
void DummyFunction() {}

@ -6005,7 +6005,7 @@ TEST_F(WebFrameTest, DISABLED_PositionForPointTest) {
EXPECT_EQ(64, ComputeOffset(layout_object, 1000, 1000));
}
#if !defined(OS_MAC) && !defined(OS_LINUX)
#if !defined(OS_MAC) && !defined(OS_LINUX) && !defined(OS_CHROMEOS)
TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) {
RegisterMockedHttpURLLoad("move_caret.html");
@ -6338,7 +6338,7 @@ TEST_F(CompositedSelectionBoundsTest, Editable) {
TEST_F(CompositedSelectionBoundsTest, EditableDiv) {
RunTest("composited_selection_bounds_editable_div.html");
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if !defined(OS_ANDROID)
TEST_F(CompositedSelectionBoundsTest, Input) {
RunTest("composited_selection_bounds_input.html");

@ -44,7 +44,7 @@
#include "libusbi.h"
#include "hotplug.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
const struct usbi_os_backend * const usbi_backend = &linux_usbfs_backend;
#elif defined(OS_DARWIN)
const struct usbi_os_backend * const usbi_backend = &darwin_backend;

@ -435,7 +435,8 @@ void usbi_connect_device (struct libusb_device *dev);
void usbi_disconnect_device (struct libusb_device *dev);
/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_DARWIN) || \
defined(OS_OPENBSD) || defined(OS_NETBSD)
#include <unistd.h>
#include "os/poll_posix.h"
#elif defined(OS_WINDOWS) || defined(OS_WINCE)

@ -10,7 +10,7 @@
#include "third_party/tcmalloc/chromium/src/config_win.h"
#elif defined(OS_ANDROID)
#include "third_party/tcmalloc/chromium/src/config_android.h"
#elif defined(OS_LINUX)
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
#include "third_party/tcmalloc/chromium/src/config_linux.h"
#elif defined(OS_FREEBSD)
#include "third_party/tcmalloc/chromium/src/config_freebsd.h"

@ -791,7 +791,7 @@ void DesktopWindowTreeHostPlatform::AddAdditionalInitProperties(
// DesktopWindowTreeHost:
// Linux subclasses this host and adds some Linux specific bits.
#if !defined(OS_LINUX)
#if !defined(OS_LINUX) && !defined(OS_CHROMEOS)
// static
DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
internal::NativeWidgetDelegate* native_widget_delegate,