Skip to content

Commit

Permalink
services: Use BUILDFLAG for OS checking
Browse files Browse the repository at this point in the history
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).

Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).

R=thakis@chromium.org

Bug: 1234043
Test: No functionality change
Change-Id: Id7916be191d4f8fd178826343f9f863d2c91e0ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373988
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#958815}
  • Loading branch information
xhwang-chromium authored and Chromium LUCI CQ committed Jan 13, 2022
1 parent 15fd7b2 commit bfdfa21
Show file tree
Hide file tree
Showing 137 changed files with 538 additions and 514 deletions.
2 changes: 1 addition & 1 deletion services/audio/input_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DeviceOutputListener;
class InputStreamActivityMonitor;

// Only do power monitoring for non-mobile platforms to save resources.
#if !defined(OS_ANDROID) && !defined(OS_IOS)
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#define AUDIO_POWER_MONITORING
#endif

Expand Down
2 changes: 1 addition & 1 deletion services/audio/input_sync_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void InputSyncWriter::Close() {
}

void InputSyncWriter::CheckTimeSinceLastWrite() {
#if !defined(OS_ANDROID)
#if !BUILDFLAG(IS_ANDROID)
static const base::TimeDelta kLogDelayThreadhold = base::Milliseconds(500);

base::TimeTicks new_write_time = base::TimeTicks::Now();
Expand Down
2 changes: 1 addition & 1 deletion services/audio/input_sync_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "media/base/audio_parameters.h"
#include "services/audio/input_controller.h"

#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
#include "base/file_descriptor_posix.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion services/audio/input_sync_writer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class InputSyncWriterTest : public testing::Test {
// with a glitch summary from the destructor. Besides that only for errors
// and fifo info.
int GetTotalNumberOfExpectedLogCalls(int expected_calls_due_to_error) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
return expected_calls_due_to_error + 1;
#else
return expected_calls_due_to_error + 2;
Expand Down
2 changes: 1 addition & 1 deletion services/audio/output_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class OutputController : public media::AudioOutputStream::AudioSourceCallback,
// Indicates whether audio power level analysis will be performed. If false,
// ReadCurrentPowerAndClip() can not be called.
static constexpr bool will_monitor_audio_levels() {
#if defined(OS_ANDROID) || defined(OS_IOS)
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
return false;
#else
return true;
Expand Down
4 changes: 2 additions & 2 deletions services/audio/owning_audio_manager_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "build/build_config.h"
#include "services/audio/service.h"

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif

Expand Down Expand Up @@ -48,7 +48,7 @@ class OwningAudioManagerAccessor : public Service::AudioManagerAccessor {
void Shutdown() final;

private:
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Required to access CoreAudio.
base::win::ScopedCOMInitializer com_initializer_{
base::win::ScopedCOMInitializer::kMTA};
Expand Down
2 changes: 1 addition & 1 deletion services/audio/public/cpp/debug_recording_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace audio {

namespace {

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#define NumberToStringType base::NumberToWString
#else
#define NumberToStringType base::NumberToString
Expand Down
2 changes: 1 addition & 1 deletion services/audio/public/cpp/output_device_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct DataFlowTestEnvironment {
CHECK(reader->IsValid());
time_stamp = base::TimeTicks::Now();

#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
// TODO(https://crbug.com/838367): Fuchsia bots use nested virtualization,
// which can result in unusually long scheduling delays, so allow a longer
// timeout.
Expand Down
5 changes: 3 additions & 2 deletions services/audio/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "media/audio/audio_manager.h"
#include "media/base/bind_to_current_loop.h"
#include "services/audio/debug_recording.h"
Expand All @@ -23,7 +24,7 @@
#include "services/audio/service_metrics.h"
#include "services/audio/system_info.h"

#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
#include "media/audio/mac/audio_device_listener_mac.h"
#endif

Expand Down Expand Up @@ -157,7 +158,7 @@ void Service::BindTestingApi(

void Service::InitializeDeviceMonitor() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
if (audio_device_listener_mac_)
return;

Expand Down
2 changes: 1 addition & 1 deletion services/audio/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Service final : public mojom::AudioService {
std::unique_ptr<AudioManagerAccessor> audio_manager_accessor_;
const bool enable_remote_client_support_;
std::unique_ptr<base::SystemMonitor> system_monitor_;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::unique_ptr<media::AudioDeviceListenerMac> audio_device_listener_mac_;
#endif
std::unique_ptr<SystemInfo> system_info_;
Expand Down
4 changes: 2 additions & 2 deletions services/audio/sync_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void LogPerLatencyGlitchUma(AudioLatency::LatencyType latency,

namespace audio {

#if !defined(OS_MAC) && !BUILDFLAG(IS_CHROMEOS_ASH) && \
#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_CHROMEOS_ASH) && \
!BUILDFLAG(IS_CHROMEOS_LACROS)
const base::Feature kDynamicAudioTimeout{"DynamicAudioTimeout",
base::FEATURE_DISABLED_BY_DEFAULT};
Expand All @@ -115,7 +115,7 @@ SyncReader::SyncReader(
renderer_missed_callback_count_(0),
trailing_renderer_missed_callback_count_(0),
buffer_index_(0) {
#if defined(OS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) || \
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) || \
BUILDFLAG(IS_CHROMEOS_LACROS)
maximum_wait_time_ = params.GetBufferDuration() / 2;
#else
Expand Down
2 changes: 1 addition & 1 deletion services/audio/sync_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "media/base/audio_latency.h"
#include "services/audio/output_controller.h"

#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
#include "base/file_descriptor_posix.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion services/audio/test/debug_recording_session_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace audio {

namespace {

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#define NumberToStringType base::NumberToWString
#else
#define NumberToStringType base::NumberToString
Expand Down
10 changes: 5 additions & 5 deletions services/cert_verifier/cert_verifier_creation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ scoped_refptr<net::CertVerifyProc> CreateCertVerifyProcWithoutUserSlots(
scoped_refptr<net::CertVerifyProc> CreateOldDefaultWithoutCaching(
scoped_refptr<net::CertNetFetcher> cert_net_fetcher) {
scoped_refptr<net::CertVerifyProc> verify_proc;
#if defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
verify_proc =
net::CertVerifyProc::CreateBuiltinVerifyProc(std::move(cert_net_fetcher));
#else
Expand All @@ -104,7 +104,7 @@ scoped_refptr<net::CertVerifyProc> CreateNewDefaultWithoutCaching(
scoped_refptr<net::CertNetFetcher> cert_net_fetcher) {
scoped_refptr<net::CertVerifyProc> verify_proc;
#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) && \
(defined(OS_LINUX) || defined(OS_WIN))
(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN))
verify_proc = net::CreateCertVerifyProcBuiltin(
std::move(cert_net_fetcher), net::CreateSslSystemTrustStoreChromeRoot());
#elif BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED)
Expand All @@ -119,9 +119,9 @@ scoped_refptr<net::CertVerifyProc> CreateNewDefaultWithoutCaching(
} // namespace

bool IsUsingCertNetFetcher() {
#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(OS_CHROMEOS) || \
defined(OS_LINUX) || \
BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) || \
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) || \
BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED)
return true;
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class NetworkServiceIntegrationTest : public testing::Test {
};

// CRLSets are not supported on iOS and Android system verifiers.
#if !defined(OS_IOS) && !defined(OS_ANDROID)
#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)

class NetworkServiceCRLSetTest : public NetworkServiceIntegrationTest {
public:
Expand Down Expand Up @@ -368,10 +368,10 @@ TEST_F(NetworkServiceCRLSetTest, CRLSetDoesNotDowngrade) {
net::CERT_STATUS_REVOKED);
}

#endif // !defined(OS_IOS) && !defined(OS_ANDROID)
#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)

// TODO(crbug.com/860189): AIA tests fail on iOS
#if defined(OS_IOS)
#if BUILDFLAG(IS_IOS)
#define MAYBE(test_name) DISABLED_##test_name
#else
#define MAYBE(test_name) test_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SSLConfigServiceMojoTestWithCertVerifier : public testing::Test {
scoped_refptr<CertNetFetcherURLLoader> cert_net_fetcher_url_loader_;
};

#if !defined(OS_IOS) && !defined(OS_ANDROID)
#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
TEST_F(SSLConfigServiceMojoTestWithCertVerifier, CRLSetIsApplied) {
mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client;

Expand Down Expand Up @@ -163,6 +163,6 @@ TEST_F(SSLConfigServiceMojoTestWithCertVerifier, CRLSetIsApplied) {
net::test::IsError(net::ERR_CERT_REVOKED));
}

#endif // !defined(OS_IOS) && !defined(OS_ANDROID)
#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)

} // namespace cert_verifier
14 changes: 7 additions & 7 deletions services/cert_verifier/trial_comparison_cert_verifier_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
#include "net/der/encode_values.h"
#include "net/der/parse_values.h"

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "net/cert/cert_verify_proc_mac.h"
#include "net/cert/internal/trust_store_mac.h"
#endif

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "net/cert/cert_verify_proc_win.h"
#endif

namespace {

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType
TrustImplTypeToMojom(net::TrustStoreMac::TrustImplType input) {
switch (input) {
Expand Down Expand Up @@ -103,7 +103,7 @@ void TrialComparisonCertVerifierMojo::OnSendTrialReport(
mojom::CertVerifierDebugInfoPtr debug_info =
mojom::CertVerifierDebugInfo::New();

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
auto* mac_platform_debug_info =
net::CertVerifyProcMac::ResultDebugData::Get(&primary_result);
if (mac_platform_debug_info) {
Expand All @@ -130,9 +130,9 @@ void TrialComparisonCertVerifierMojo::OnSendTrialReport(
debug_info->mac_trust_impl =
TrustImplTypeToMojom(mac_trust_debug_info->trust_impl());
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
auto* win_platform_debug_info =
net::CertVerifyProcWin::ResultDebugData::Get(&primary_result);
if (win_platform_debug_info) {
Expand All @@ -143,7 +143,7 @@ void TrialComparisonCertVerifierMojo::OnSendTrialReport(
debug_info->win_platform_debug_info->authroot_sequence_number =
win_platform_debug_info->authroot_sequence_number();
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)

auto* cert_verify_proc_builtin_debug_data =
net::CertVerifyProcBuiltinResultDebugData::Get(&trial_result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include "net/test/test_data_directory.h"
#include "testing/gtest/include/gtest/gtest.h"

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "net/cert/cert_verify_proc_mac.h"
#include "net/cert/internal/trust_store_mac.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "net/cert/cert_verify_proc_win.h"
#endif

Expand Down Expand Up @@ -109,7 +109,7 @@ TEST(TrialComparisonCertVerifierMojoTest, SendReportDebugInfo) {

base::Time time = base::Time::Now();

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
constexpr uint32_t kExpectedTrustResult = 4;
constexpr int32_t kExpectedResultCode = -12345;
std::vector<net::CertVerifyProcMac::ResultDebugData::CertEvidenceInfo>
Expand All @@ -136,7 +136,7 @@ TEST(TrialComparisonCertVerifierMojoTest, SendReportDebugInfo) {
mac_trust_debug_info->UpdateTrustDebugInfo(
kExpectedTrustDebugInfo, net::TrustStoreMac::TrustImplType::kSimple);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::vector<uint8_t> authroot_sequence{'T', 'E', 'S', 'T'};
net::CertVerifyProcWin::ResultDebugData::Create(time, authroot_sequence,
&primary_result);
Expand Down Expand Up @@ -180,7 +180,7 @@ TEST(TrialComparisonCertVerifierMojoTest, SendReportDebugInfo) {
std::string(report.sct_list.begin(), report.sct_list.end()));

ASSERT_TRUE(report.debug_info);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
ASSERT_TRUE(report.debug_info->mac_platform_debug_info);
EXPECT_EQ(kExpectedTrustResult,
report.debug_info->mac_platform_debug_info->trust_result);
Expand All @@ -203,7 +203,7 @@ TEST(TrialComparisonCertVerifierMojoTest, SendReportDebugInfo) {
cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType::kSimple,
report.debug_info->mac_trust_impl);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
ASSERT_TRUE(report.debug_info->win_platform_debug_info);
EXPECT_EQ(time,
report.debug_info->win_platform_debug_info->authroot_this_update);
Expand Down
4 changes: 2 additions & 2 deletions services/data_decoder/data_decoder_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "services/data_decoder/ble_scan_parser_impl.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

#if !defined(OS_IOS)
#if !BUILDFLAG(IS_IOS)
#include "services/data_decoder/image_decoder_impl.h"
#endif

Expand All @@ -46,7 +46,7 @@ void DataDecoderService::BindReceiver(

void DataDecoderService::BindImageDecoder(
mojo::PendingReceiver<mojom::ImageDecoder> receiver) {
#if defined(OS_IOS)
#if BUILDFLAG(IS_IOS)
LOG(FATAL) << "ImageDecoder not supported on iOS.";
#else
if (drop_image_decoders_)
Expand Down
2 changes: 1 addition & 1 deletion services/data_decoder/image_decoder_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TEST_F(ImageDecoderImplTest, DecodeImageSizeLimit) {
static_cast<uint64_t>(kTestMaxImageSize));
// Android does its own image shrinking for memory conservation deeper in
// the decode, so more specific tests here won't work.
#if !defined(OS_ANDROID)
#if !BUILDFLAG(IS_ANDROID)
EXPECT_EQ(widths[i] >> i, request.bitmap().width());
EXPECT_EQ(heights[i] >> i, request.bitmap().height());

Expand Down
10 changes: 5 additions & 5 deletions services/data_decoder/public/cpp/data_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include "services/data_decoder/public/mojom/json_parser.mojom.h"
#include "services/data_decoder/public/mojom/xml_parser.mojom.h"

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "services/data_decoder/public/cpp/json_sanitizer.h"
#endif

#if defined(OS_IOS)
#if BUILDFLAG(IS_IOS)
#include "base/task/post_task.h"
#include "services/data_decoder/data_decoder_service.h" // nogncheck
#endif
Expand Down Expand Up @@ -107,7 +107,7 @@ class ValueParseRequest : public base::RefCounted<ValueParseRequest<T, V>> {
DataDecoder::ResultCallback<V> callback_;
};

#if defined(OS_IOS)
#if BUILDFLAG(IS_IOS)
void BindInProcessService(
mojo::PendingReceiver<mojom::DataDecoderService> receiver) {
static base::NoDestructor<scoped_refptr<base::SequencedTaskRunner>>
Expand Down Expand Up @@ -140,7 +140,7 @@ mojom::DataDecoderService* DataDecoder::GetService() {
if (provider) {
provider->BindDataDecoderService(service_.BindNewPipeAndPassReceiver());
} else {
#if defined(OS_IOS)
#if BUILDFLAG(IS_IOS)
BindInProcessService(service_.BindNewPipeAndPassReceiver());
#else
LOG(FATAL) << "data_decoder::ServiceProvider::Set() must be called "
Expand All @@ -158,7 +158,7 @@ mojom::DataDecoderService* DataDecoder::GetService() {

void DataDecoder::ParseJson(const std::string& json,
ValueParseCallback callback) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// For Android, we use the in-process sanitizer and then parse with a simple
// JSONReader.
JsonSanitizer::Sanitize(
Expand Down
Loading

0 comments on commit bfdfa21

Please sign in to comment.