rlz: Use BUILDFLAG for OS checking
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: I20a94c95d961827e70af575deb2e810bd0f71a8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373986
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956770}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e39eca4e7b
commit
1067171187
@ -37,7 +37,7 @@
|
||||
#include "services/network/public/cpp/simple_url_loader.h"
|
||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
#include "base/time/time.h"
|
||||
#endif
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "rlz/win/lib/machine_deal.h"
|
||||
#else
|
||||
#include "base/time/time.h"
|
||||
@ -82,7 +82,7 @@ TEST_F(FinancialPingTest, FormRequest) {
|
||||
std::string brand_string = rlz_lib::SupplementaryBranding::GetBrand();
|
||||
const char* brand = brand_string.empty() ? "GGLA" : brand_string.c_str();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
EXPECT_TRUE(rlz_lib::MachineDealCode::Set("dcc_value"));
|
||||
#define DCC_PARAM "&dcc=dcc_value"
|
||||
#else
|
||||
|
@ -1,12 +1,13 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#ifndef RLZ_LIB_RLZ_API_H_
|
||||
#define RLZ_LIB_RLZ_API_H_
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#define RLZ_LIB_API __cdecl
|
||||
#else
|
||||
#define RLZ_LIB_API
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "rlz/lib/string_utils.h"
|
||||
#include "services/network/public/mojom/url_loader_factory.mojom.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "rlz/lib/machine_deal_win.h"
|
||||
#endif
|
||||
|
||||
@ -587,7 +587,7 @@ bool ParsePingResponse(Product product, const char* response) {
|
||||
}
|
||||
} while (line_end_index >= 0);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Update the DCC in registry if needed.
|
||||
SetMachineDealCodeFromPingResponse(response);
|
||||
#endif
|
||||
@ -637,7 +637,7 @@ bool GetPingParams(Product product, const AccessPoint* access_points,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Report the DCC too if not empty. DCCs are windows-only.
|
||||
char dcc[kMaxDccLength + 1];
|
||||
dcc[0] = 0;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#endif
|
||||
#if !defined(RLZ_NETWORK_IMPLEMENTATION_WIN_INET) && \
|
||||
!defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#define RLZ_NETWORK_IMPLEMENTATION_WIN_INET
|
||||
#else
|
||||
#define RLZ_NETWORK_IMPLEMENTATION_CHROME_NET
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <Windows.h>
|
||||
#include "rlz/win/lib/machine_deal.h"
|
||||
#endif
|
||||
@ -58,13 +58,13 @@
|
||||
#endif
|
||||
|
||||
class MachineDealCodeHelper
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
: public rlz_lib::MachineDealCode
|
||||
#endif
|
||||
{
|
||||
{
|
||||
public:
|
||||
static bool Clear() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return rlz_lib::MachineDealCode::Clear();
|
||||
#else
|
||||
return true;
|
||||
@ -335,7 +335,7 @@ TEST_F(RlzLibTest, GetPingParams) {
|
||||
cgi, 2048));
|
||||
EXPECT_STREQ("rep=2&rlz=T4:TbRlzValue", cgi);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
EXPECT_TRUE(rlz_lib::MachineDealCode::Set("dcc_value"));
|
||||
#define DCC_PARAM "&dcc=dcc_value"
|
||||
#else
|
||||
@ -455,7 +455,7 @@ TEST_F(RlzLibTest, ParsePingResponse) {
|
||||
"dcc: dcc_value\r\n"
|
||||
"crc32: F9070F81";
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
EXPECT_TRUE(rlz_lib::MachineDealCode::Set("dcc_value2"));
|
||||
#endif
|
||||
|
||||
@ -465,7 +465,7 @@ TEST_F(RlzLibTest, ParsePingResponse) {
|
||||
EXPECT_TRUE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER,
|
||||
rlz_lib::IE_HOME_PAGE, rlz_lib::INSTALL));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
EXPECT_TRUE(rlz_lib::MachineDealCode::Set("dcc_value"));
|
||||
#endif
|
||||
EXPECT_TRUE(rlz_lib::ParsePingResponse(rlz_lib::TOOLBAR_NOTIFIER,
|
||||
@ -574,7 +574,7 @@ TEST_F(RlzLibTest, SendFinancialPing) {
|
||||
return;
|
||||
|
||||
#if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
|
||||
#if defined(OS_APPLE)
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
#endif
|
||||
|
||||
@ -585,7 +585,7 @@ TEST_F(RlzLibTest, SendFinancialPing) {
|
||||
#endif
|
||||
|
||||
MachineDealCodeHelper::Clear();
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
EXPECT_TRUE(rlz_lib::MachineDealCode::Set("dcc_value"));
|
||||
#endif
|
||||
|
||||
@ -625,7 +625,7 @@ TEST_F(RlzLibTest, SendFinancialPingDuringShutdown) {
|
||||
if (!rlz_lib::SupplementaryBranding::GetBrand().empty())
|
||||
return;
|
||||
|
||||
#if defined(OS_APPLE)
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
#endif
|
||||
|
||||
@ -703,7 +703,7 @@ TEST_F(RlzLibTest, ClearProductState) {
|
||||
EXPECT_STREQ("", cgi);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
template<class T>
|
||||
class typed_buffer_ptr {
|
||||
std::unique_ptr<char[]> buffer_;
|
||||
@ -970,7 +970,7 @@ TEST_F(RlzLibTest, BrandingWithStatefulEvents) {
|
||||
EXPECT_STREQ("events=I7S", value);
|
||||
}
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
class ReadonlyRlzDirectoryTest : public RlzLibTestNoMachineState {
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
@ -15,11 +15,11 @@
|
||||
#include "build/build_config.h"
|
||||
#include "rlz/lib/rlz_enums.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "rlz/win/lib/lib_mutex.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_APPLE)
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#endif
|
||||
|
||||
@ -101,14 +101,14 @@ class ScopedRlzValueStoreLock {
|
||||
|
||||
private:
|
||||
std::unique_ptr<RlzValueStore> store_;
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
LibMutex lock_;
|
||||
#elif defined(OS_APPLE)
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
namespace testing {
|
||||
// Prefix |directory| to the path where the RLZ data file lives, for tests.
|
||||
void SetRlzStoreDirectory(const base::FilePath& directory);
|
||||
@ -116,7 +116,7 @@ void SetRlzStoreDirectory(const base::FilePath& directory);
|
||||
// Returns the path of the file used as data store.
|
||||
std::string RlzStoreFilenameStr();
|
||||
} // namespace testing
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
|
||||
} // namespace rlz_lib
|
||||
|
||||
|
@ -19,16 +19,16 @@
|
||||
#include "rlz/lib/rlz_lib.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/registry.h"
|
||||
#include "base/win/shlwapi.h"
|
||||
#include "rlz/lib/machine_deal_win.h"
|
||||
#elif defined(OS_POSIX)
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
#include "base/files/file_path.h"
|
||||
#include "rlz/lib/rlz_value_store.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
||||
namespace {
|
||||
|
||||
@ -126,35 +126,35 @@ void InitializeRegistryOverridesForTesting(
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
void RlzLibTestNoMachineStateHelper::SetUp() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
InitializeRegistryOverridesForTesting(&override_manager_));
|
||||
#elif defined(OS_APPLE)
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
#endif // defined(OS_WIN)
|
||||
#if defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
||||
rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.GetPath());
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
}
|
||||
|
||||
void RlzLibTestNoMachineStateHelper::TearDown() {
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
rlz_lib::testing::SetRlzStoreDirectory(base::FilePath());
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
}
|
||||
|
||||
void RlzLibTestNoMachineStateHelper::Reset() {
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
ASSERT_TRUE(temp_dir_.Delete());
|
||||
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
||||
rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.GetPath());
|
||||
#else
|
||||
NOTREACHED();
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
}
|
||||
|
||||
void RlzLibTestNoMachineState::SetUp() {
|
||||
@ -171,16 +171,16 @@ RlzLibTestBase::~RlzLibTestBase() = default;
|
||||
|
||||
void RlzLibTestBase::SetUp() {
|
||||
RlzLibTestNoMachineState::SetUp();
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
rlz_lib::CreateMachineState();
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
// Make sure the values of RLZ strings for access points used in tests start
|
||||
// out not set, since on Chrome OS RLZ string can only be set once.
|
||||
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, ""));
|
||||
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IE_HOME_PAGE, ""));
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
statistics_provider_ =
|
||||
|
@ -12,11 +12,11 @@
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/test/test_reg_util_win.h"
|
||||
#endif
|
||||
|
||||
@ -33,11 +33,11 @@ class RlzLibTestNoMachineStateHelper {
|
||||
void TearDown();
|
||||
void Reset();
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
base::ScopedTempDir temp_dir_;
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
registry_util::RegistryOverrideManager override_manager_;
|
||||
#endif
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "rlz/lib/rlz_value_store.h"
|
||||
@ -35,7 +35,7 @@ int main(int argc, char **argv) {
|
||||
if (ret == 0) {
|
||||
// Now re-run all the tests using a supplementary brand code. This brand
|
||||
// code will remain in effect for the lifetime of the branding object.
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
// Set a temporary directory for RLZ here, because SupplementaryBranding
|
||||
// creates and owns RlzValueStore object for its lifetime.
|
||||
base::ScopedTempDir temp_dir;
|
||||
|
Reference in New Issue
Block a user