0

LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_CHROMEOS_ASH)

The change is mostly mechanical replacing defined(OS_CHROMEOS) with
BUILDFLAG(IS_CHROMEOS_ASH) and GN variable is_chromeos with
is_chromeos_ash with some special cases (For those cases please
refer to http://go/lacros-macros).

The patch is made in preparation to switching lacros build from
target_os=linux to target_os=chromeos. This will prevent lacros from
changing behaviour after the switch.

Bug: 1052397
Change-Id: I91abd1d1403357076883ec43724c1daa8826d1d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550005
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831462}
This commit is contained in:
Yuta Hijikata
2020-11-27 03:17:23 +00:00
committed by Commit Bot
parent 44e18e2bcb
commit 1c9feb175b
9 changed files with 46 additions and 28 deletions

@ -5,6 +5,7 @@
# Note that this build file assumes rlz_use_chrome_net which is a condition in
# the GYP file, but is always true for Chrome builds.
import("//build/config/chromeos/ui_mode.gni")
import("//rlz/buildflags/buildflags.gni")
import("//testing/test.gni")
@ -30,7 +31,10 @@ source_set("rlz_utils") {
public_deps = [ "//base" ]
deps = [ "//third_party/zlib" ]
deps = [
"//build:chromeos_buildflags",
"//third_party/zlib",
]
}
if (enable_rlz_support) {
@ -72,9 +76,10 @@ if (enable_rlz_support) {
deps = [
":rlz_utils",
"//base",
"//build:chromeos_buildflags",
]
if (is_chromeos) {
if (is_chromeos_ash) {
sources += [
"chromeos/lib/rlz_value_store_chromeos.cc",
"chromeos/lib/rlz_value_store_chromeos.h",
@ -130,13 +135,14 @@ if (enable_rlz_support) {
deps = [
":rlz_utils",
"//base/third_party/dynamic_annotations",
"//build:chromeos_buildflags",
"//net",
"//services/network/public/cpp:cpp",
"//services/network/public/mojom",
"//url",
]
if (is_chromeos) {
if (is_chromeos_ash) {
deps += [
"//chromeos/dbus",
"//chromeos/system",
@ -157,8 +163,11 @@ if (enable_rlz_support) {
"//base/test:test_support",
"//testing/gtest",
]
deps = [ ":rlz_lib" ]
if (is_chromeos) {
deps = [
":rlz_lib",
"//build:chromeos_buildflags",
]
if (is_chromeos_ash) {
public_deps += [ "//chromeos/system" ]
}
}
@ -187,6 +196,7 @@ if (enable_rlz_support) {
":rlz_utils",
":test_support",
"//base",
"//build:chromeos_buildflags",
"//mojo/core/embedder",
"//net:test_support",
"//services/network:test_support",
@ -194,7 +204,7 @@ if (enable_rlz_support) {
"//testing/gtest",
"//third_party/zlib",
]
if (is_chromeos) {
if (is_chromeos_ash) {
deps += [
"//chromeos/dbus:test_support",
"//chromeos/system",

@ -3,9 +3,10 @@
# found in the LICENSE file.
import("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
# Whether we are using the rlz library or not. Platforms like Android send
# rlz codes for searches but do not use the library.
enable_rlz_support = is_win || is_apple || is_chromeos
enable_rlz_support = is_win || is_apple || is_chromeos_ash
enable_rlz = is_chrome_branded && enable_rlz_support

@ -23,6 +23,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "rlz/lib/lib_values.h"
#include "rlz/lib/machine_id.h"
#include "rlz/lib/rlz_lib.h"
@ -38,14 +39,14 @@
#include "base/time/time.h"
#endif
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/system/factory_ping_embargo_check.h"
#include "rlz/chromeos/lib/rlz_value_store_chromeos.h"
#endif
namespace {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
void RemoveMachineIdFromUrl(std::string* url) {
size_t id_offset = url->find("&id=");
EXPECT_NE(std::string::npos, id_offset);
@ -104,7 +105,7 @@ TEST_F(FinancialPingTest, FormRequest) {
// Don't check the machine Id on Chrome OS since a random one is generated
// each time.
std::string machine_id;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool got_machine_id = false;
#else
bool got_machine_id = rlz_lib::GetMachineId(&machine_id);
@ -114,7 +115,7 @@ TEST_F(FinancialPingTest, FormRequest) {
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
points, "swg", brand, NULL, "en", false, &request));
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Ignore the machine Id of the request URL. On Chrome OS a random Id is
// generated with each request.
RemoveMachineIdFromUrl(&request);
@ -134,7 +135,7 @@ TEST_F(FinancialPingTest, FormRequest) {
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
points, "swg", brand, "IdOk2", NULL, false, &request));
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Ignore the machine Id of the request URL. On Chrome OS a random Id is
// generated with each request.
RemoveMachineIdFromUrl(&request);
@ -328,7 +329,7 @@ TEST_F(FinancialPingTest, ClearLastPingTime) {
false));
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(FinancialPingTest, RlzEmbargoEndDate) {
// Do not set last ping time, verify that |IsPingTime| returns true.
EXPECT_TRUE(

@ -9,6 +9,7 @@
#include "base/hash/sha1.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "build/chromeos_buildflags.h"
#include "rlz/lib/assert.h"
#include "rlz/lib/crc8.h"
#include "rlz/lib/string_utils.h"
@ -19,7 +20,7 @@ bool GetMachineId(std::string* machine_id) {
if (!machine_id)
return false;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Generate a random machine Id each time this function is called. This
// prevents the RLZ server from correlating two RLZ pings from the same
@ -60,7 +61,7 @@ bool GetMachineId(std::string* machine_id) {
calculated_id = *machine_id;
return true;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
namespace testing {

@ -7,6 +7,7 @@
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
#include "rlz/test/rlz_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -20,7 +21,7 @@ TEST(MachineDealCodeTestMachineId, MachineId) {
id.c_str());
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST(MachineDealCodeTestMachineId, MachineIdIsUnique) {
std::string id1;
std::string id2;

@ -15,6 +15,7 @@
#include "base/syslog_logging.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "net/base/backoff_entry.h"
#include "rlz/lib/assert.h"
#include "rlz/lib/financial_ping.h"
@ -441,7 +442,7 @@ bool SendFinancialPing(Product product,
FinancialPing::UpdateLastPingTime(product);
std::string response;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
const net::BackoffEntry::Policy policy = {
0, // Number of initial errors to ignore.
base::TimeDelta::FromSeconds(5).InMilliseconds(), // Initial delay.

@ -23,6 +23,7 @@
#include "base/strings/stringprintf.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "rlz/lib/financial_ping.h"
#include "rlz/lib/lib_values.h"
#include "rlz/lib/net_response_check.h"
@ -48,7 +49,7 @@
#include "services/network/test/test_url_loader_factory.h"
#endif
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/files/important_file_writer.h"
#include "base/stl_util.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@ -219,7 +220,7 @@ TEST_F(RlzLibTest, SetAccessPointRlz) {
EXPECT_STREQ("IeTbRlz", rlz_50);
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(RlzLibTest, SetAccessPointRlzOnlyOnce) {
// On Chrome OS, and RLZ string can ne set only once.
char rlz_50[50];
@ -483,7 +484,7 @@ TEST_F(RlzLibTest, ParsePingResponse) {
EXPECT_TRUE(rlz_lib::ParsePingResponse(rlz_lib::TOOLBAR_NOTIFIER,
kPingResponse2));
EXPECT_TRUE(rlz_lib::GetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, value, 50));
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// On Chrome OS, the RLZ string is not modified by response once set.
EXPECT_STREQ("1T4_____en__252", value);
#else
@ -494,7 +495,7 @@ TEST_F(RlzLibTest, ParsePingResponse) {
"crc32: 0\r\n"; // Good RLZ - empty response.
EXPECT_TRUE(rlz_lib::ParsePingResponse(rlz_lib::TOOLBAR_NOTIFIER,
kPingResponse3));
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// On Chrome OS, the RLZ string is not modified by response once set.
EXPECT_STREQ("1T4_____en__252", value);
#else
@ -1078,7 +1079,7 @@ TEST_F(RlzLibTest, LockAcquistionSucceedsButStoreFileCannotBeCreated) {
#endif
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
class TestDebugDaemonClient : public chromeos::FakeDebugDaemonClient {
public:
TestDebugDaemonClient() = default;

@ -15,6 +15,7 @@
#include "base/notreached.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "rlz/lib/rlz_lib.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -181,16 +182,16 @@ void RlzLibTestBase::SetUp() {
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IE_HOME_PAGE, ""));
#endif // defined(OS_POSIX)
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
statistics_provider_ =
std::make_unique<chromeos::system::FakeStatisticsProvider>();
chromeos::system::StatisticsProvider::SetTestProvider(
statistics_provider_.get());
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void RlzLibTestBase::TearDown() {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::system::StatisticsProvider::SetTestProvider(nullptr);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}

@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_POSIX)
@ -19,7 +20,7 @@
#include "base/test/test_reg_util_win.h"
#endif
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/system/fake_statistics_provider.h"
#endif
@ -58,7 +59,7 @@ class RlzLibTestBase : public RlzLibTestNoMachineState {
void SetUp() override;
void TearDown() override;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<chromeos::system::FakeStatisticsProvider>
statistics_provider_;
#endif