Commit 0daa79d2 authored by Mike Wittman's avatar Mike Wittman Committed by Commit Bot

[Sampling profiler] Rationalize release/channel config

Updates the ThreadProfiler configuration to consider a build to be a
Chrome release if it's official and Chrome branded. The existing code
only considered the Chrome branded state which is overly lenient. For
what its worth breakpad uses the same conditions for whether it should
be enabled.

This changes behavior of edge cases as follows:

Unofficial Chrome branded builds are now considered to be
development/CQ builds and as such the profiler is always enabled
for them.

Official Chrome branded builds with unknown channel are no longer
treated as development/CQ builds, so the profiler is disabled for
them rather than always enabled.

Bug: 1129939
Change-Id: I52b2120ef98734278ffd211809463c2ded3d3bd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432386
Commit-Queue: Mike Wittman <wittman@chromium.org>
Reviewed-by: default avatarEtienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812417}
parent 50b04c1c
...@@ -33,6 +33,17 @@ bool IsBrowserTestModeEnabled() { ...@@ -33,6 +33,17 @@ bool IsBrowserTestModeEnabled() {
switches::kStartStackProfilerBrowserTest; switches::kStartStackProfilerBrowserTest;
} }
// Returns the channel if this is a Chrome release, otherwise returns nullopt. A
// build is considered to be a Chrome release if it's official and has Chrome
// branding.
base::Optional<version_info::Channel> GetReleaseChannel() {
#if defined(OFFICIAL_BUILD) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
return chrome::GetChannel();
#else
return base::nullopt;
#endif
}
} // namespace } // namespace
ThreadProfilerConfiguration::ThreadProfilerConfiguration() ThreadProfilerConfiguration::ThreadProfilerConfiguration()
...@@ -84,8 +95,7 @@ bool ThreadProfilerConfiguration::GetSyntheticFieldTrial( ...@@ -84,8 +95,7 @@ bool ThreadProfilerConfiguration::GetSyntheticFieldTrial(
std::string* group_name) const { std::string* group_name) const {
DCHECK_EQ(metrics::CallStackProfileParams::BROWSER_PROCESS, current_process_); DCHECK_EQ(metrics::CallStackProfileParams::BROWSER_PROCESS, current_process_);
if (!platform_configuration_->IsSupported(BUILDFLAG(GOOGLE_CHROME_BRANDING), if (!platform_configuration_->IsSupported(GetReleaseChannel())) {
chrome::GetChannel())) {
return false; return false;
} }
...@@ -175,16 +185,14 @@ ThreadProfilerConfiguration::GenerateConfiguration( ...@@ -175,16 +185,14 @@ ThreadProfilerConfiguration::GenerateConfiguration(
if (process != metrics::CallStackProfileParams::BROWSER_PROCESS) if (process != metrics::CallStackProfileParams::BROWSER_PROCESS)
return PROFILE_FROM_COMMAND_LINE; return PROFILE_FROM_COMMAND_LINE;
const version_info::Channel channel = chrome::GetChannel(); const base::Optional<version_info::Channel> release_channel =
if (!platform_configuration.IsSupported(BUILDFLAG(GOOGLE_CHROME_BRANDING), GetReleaseChannel();
channel)) { if (!platform_configuration.IsSupported(release_channel))
return PROFILE_DISABLED; return PROFILE_DISABLED;
}
using RuntimeModuleState = using RuntimeModuleState =
ThreadProfilerPlatformConfiguration::RuntimeModuleState; ThreadProfilerPlatformConfiguration::RuntimeModuleState;
switch (platform_configuration.GetRuntimeModuleState( switch (platform_configuration.GetRuntimeModuleState(release_channel)) {
BUILDFLAG(GOOGLE_CHROME_BRANDING), channel)) {
case RuntimeModuleState::kModuleAbsentButAvailable: case RuntimeModuleState::kModuleAbsentButAvailable:
platform_configuration.RequestRuntimeModuleInstall(); platform_configuration.RequestRuntimeModuleInstall();
FALLTHROUGH; FALLTHROUGH;
...@@ -197,12 +205,8 @@ ThreadProfilerConfiguration::GenerateConfiguration( ...@@ -197,12 +205,8 @@ ThreadProfilerConfiguration::GenerateConfiguration(
} }
ThreadProfilerPlatformConfiguration::RelativePopulations ThreadProfilerPlatformConfiguration::RelativePopulations
relative_populations = platform_configuration.GetEnableRates( relative_populations =
BUILDFLAG(GOOGLE_CHROME_BRANDING), channel); platform_configuration.GetEnableRates(release_channel);
if (relative_populations.enabled == 0 &&
relative_populations.experiment == 0) {
return PROFILE_DISABLED;
}
CHECK_EQ(0, relative_populations.experiment % 2); CHECK_EQ(0, relative_populations.experiment % 2);
return ChooseConfiguration({ return ChooseConfiguration({
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/common/profiler/thread_profiler_platform_configuration.h" #include "chrome/common/profiler/thread_profiler_platform_configuration.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/notreached.h"
#include "base/profiler/stack_sampling_profiler.h" #include "base/profiler/stack_sampling_profiler.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/profiler/process_type.h" #include "chrome/common/profiler/process_type.h"
...@@ -24,12 +25,10 @@ class DefaultPlatformConfiguration ...@@ -24,12 +25,10 @@ class DefaultPlatformConfiguration
// ThreadProfilerPlatformConfiguration: // ThreadProfilerPlatformConfiguration:
RuntimeModuleState GetRuntimeModuleState( RuntimeModuleState GetRuntimeModuleState(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const override;
version_info::Channel channel) const override;
RelativePopulations GetEnableRates( RelativePopulations GetEnableRates(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const override;
version_info::Channel channel) const override;
double GetChildProcessEnableFraction( double GetChildProcessEnableFraction(
metrics::CallStackProfileParams::Process process) const override; metrics::CallStackProfileParams::Process process) const override;
...@@ -39,8 +38,8 @@ class DefaultPlatformConfiguration ...@@ -39,8 +38,8 @@ class DefaultPlatformConfiguration
metrics::CallStackProfileParams::Thread thread) const override; metrics::CallStackProfileParams::Thread thread) const override;
protected: protected:
bool IsSupportedForChannel(bool is_chrome_branded, bool IsSupportedForChannel(
version_info::Channel channel) const override; base::Optional<version_info::Channel> release_channel) const override;
bool browser_test_mode_enabled() const { return browser_test_mode_enabled_; } bool browser_test_mode_enabled() const { return browser_test_mode_enabled_; }
...@@ -54,29 +53,24 @@ DefaultPlatformConfiguration::DefaultPlatformConfiguration( ...@@ -54,29 +53,24 @@ DefaultPlatformConfiguration::DefaultPlatformConfiguration(
ThreadProfilerPlatformConfiguration::RuntimeModuleState ThreadProfilerPlatformConfiguration::RuntimeModuleState
DefaultPlatformConfiguration::GetRuntimeModuleState( DefaultPlatformConfiguration::GetRuntimeModuleState(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const {
version_info::Channel channel) const {
return RuntimeModuleState::kModuleNotRequired; return RuntimeModuleState::kModuleNotRequired;
} }
ThreadProfilerPlatformConfiguration::RelativePopulations ThreadProfilerPlatformConfiguration::RelativePopulations
DefaultPlatformConfiguration::GetEnableRates( DefaultPlatformConfiguration::GetEnableRates(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const {
version_info::Channel channel) const { CHECK(IsSupportedForChannel(release_channel));
// TODO(https://crbug.com/1129939): Make this logic consistent with
// IsSupportedForChannel() for identifying local/CQ builds. if (!release_channel) {
switch (channel) { // This is a local/CQ build.
// Enable the profiler unconditionally for development/waterfall builds.
case version_info::Channel::UNKNOWN:
return RelativePopulations{100, 0}; return RelativePopulations{100, 0};
}
case version_info::Channel::CANARY: CHECK(*release_channel == version_info::Channel::CANARY ||
case version_info::Channel::DEV: *release_channel == version_info::Channel::DEV);
return RelativePopulations{80, 20};
default: return RelativePopulations{80, 20};
return RelativePopulations{0, 0};
}
} }
double DefaultPlatformConfiguration::GetChildProcessEnableFraction( double DefaultPlatformConfiguration::GetChildProcessEnableFraction(
...@@ -109,16 +103,15 @@ bool DefaultPlatformConfiguration::IsEnabledForThread( ...@@ -109,16 +103,15 @@ bool DefaultPlatformConfiguration::IsEnabledForThread(
} }
bool DefaultPlatformConfiguration::IsSupportedForChannel( bool DefaultPlatformConfiguration::IsSupportedForChannel(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const {
version_info::Channel channel) const {
// The profiler is always supported for local builds and the CQ. // The profiler is always supported for local builds and the CQ.
if (!is_chrome_branded) if (!release_channel)
return true; return true;
// Canary and dev are the only channels currently supported in release // Canary and dev are the only channels currently supported in release
// builds. // builds.
return channel == version_info::Channel::CANARY || return *release_channel == version_info::Channel::CANARY ||
channel == version_info::Channel::DEV; *release_channel == version_info::Channel::DEV;
} }
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -132,8 +125,7 @@ class AndroidPlatformConfiguration : public DefaultPlatformConfiguration { ...@@ -132,8 +125,7 @@ class AndroidPlatformConfiguration : public DefaultPlatformConfiguration {
// DefaultPlatformConfiguration: // DefaultPlatformConfiguration:
RuntimeModuleState GetRuntimeModuleState( RuntimeModuleState GetRuntimeModuleState(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const override;
version_info::Channel channel) const override;
void RequestRuntimeModuleInstall() const override; void RequestRuntimeModuleInstall() const override;
...@@ -145,8 +137,8 @@ class AndroidPlatformConfiguration : public DefaultPlatformConfiguration { ...@@ -145,8 +137,8 @@ class AndroidPlatformConfiguration : public DefaultPlatformConfiguration {
metrics::CallStackProfileParams::Thread thread) const override; metrics::CallStackProfileParams::Thread thread) const override;
protected: protected:
bool IsSupportedForChannel(bool is_chrome_branded, bool IsSupportedForChannel(
version_info::Channel channel) const override; base::Optional<version_info::Channel> release_channel) const override;
}; };
AndroidPlatformConfiguration::AndroidPlatformConfiguration( AndroidPlatformConfiguration::AndroidPlatformConfiguration(
...@@ -155,22 +147,21 @@ AndroidPlatformConfiguration::AndroidPlatformConfiguration( ...@@ -155,22 +147,21 @@ AndroidPlatformConfiguration::AndroidPlatformConfiguration(
ThreadProfilerPlatformConfiguration::RuntimeModuleState ThreadProfilerPlatformConfiguration::RuntimeModuleState
AndroidPlatformConfiguration::GetRuntimeModuleState( AndroidPlatformConfiguration::GetRuntimeModuleState(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const {
version_info::Channel channel) const {
// The module will be present in releases due to having been installed via // The module will be present in releases due to having been installed via
// RequestRuntimeModuleInstall(), and in local/CQ builds of bundle targets // RequestRuntimeModuleInstall(), and in local/CQ builds of bundle targets
// where the module was installed with the bundle. // where the module was installed with the bundle.
if (stack_unwinder::Module::IsInstalled()) if (stack_unwinder::Module::IsInstalled())
return RuntimeModuleState::kModulePresent; return RuntimeModuleState::kModulePresent;
if (is_chrome_branded) { if (release_channel) {
// We only want to incur the cost of universally downloading the module in // We only want to incur the cost of universally downloading the module in
// early channels, where profiling will occur over substantially all of // early channels, where profiling will occur over substantially all of
// the population. When supporting later channels in the future we will // the population. When supporting later channels in the future we will
// enable profiling for only a fraction of users and only download for // enable profiling for only a fraction of users and only download for
// those users. // those users.
if (channel == version_info::Channel::CANARY || if (*release_channel == version_info::Channel::CANARY ||
channel == version_info::Channel::DEV) { *release_channel == version_info::Channel::DEV) {
return RuntimeModuleState::kModuleAbsentButAvailable; return RuntimeModuleState::kModuleAbsentButAvailable;
} }
...@@ -214,8 +205,7 @@ bool AndroidPlatformConfiguration::IsEnabledForThread( ...@@ -214,8 +205,7 @@ bool AndroidPlatformConfiguration::IsEnabledForThread(
} }
bool AndroidPlatformConfiguration::IsSupportedForChannel( bool AndroidPlatformConfiguration::IsSupportedForChannel(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const {
version_info::Channel channel) const {
// On Android profiling is only enabled in its own dedicated browser tests // On Android profiling is only enabled in its own dedicated browser tests
// in local builds and the CQ. // in local builds and the CQ.
// TODO(https://crbug.com/1004855): Enable across all browser tests. // TODO(https://crbug.com/1004855): Enable across all browser tests.
...@@ -237,8 +227,7 @@ ThreadProfilerPlatformConfiguration::Create(bool browser_test_mode_enabled) { ...@@ -237,8 +227,7 @@ ThreadProfilerPlatformConfiguration::Create(bool browser_test_mode_enabled) {
} }
bool ThreadProfilerPlatformConfiguration::IsSupported( bool ThreadProfilerPlatformConfiguration::IsSupported(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const {
version_info::Channel channel) const {
return base::StackSamplingProfiler::IsSupportedForCurrentPlatform() && return base::StackSamplingProfiler::IsSupportedForCurrentPlatform() &&
IsSupportedForChannel(is_chrome_branded, channel); IsSupportedForChannel(release_channel);
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "base/optional.h"
#include "components/metrics/call_stack_profile_params.h" #include "components/metrics/call_stack_profile_params.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
...@@ -14,14 +15,19 @@ ...@@ -14,14 +15,19 @@
// //
// The interface functions this class make a distinction between 'supported' and // The interface functions this class make a distinction between 'supported' and
// 'enabled' state. Supported means the profiler can be run in *some* // 'enabled' state. Supported means the profiler can be run in *some*
// circumstances for *some* fraction of the population on the // circumstances for *some* fraction of the population on the platform/{released
// platform/branding/channel combination. This state is intended to enable // Chrome channel, development/CQ build} combination. This state is intended to
// experiment reporting. This avoids spamming UMA with experiment state on // enable experiment reporting. This avoids spamming UMA with experiment state
// platforms/channels where the profiler is not being run. // on platforms/channels where the profiler is not being run.
// //
// Enabled means we chose to the run the profiler on at least some threads on a // Enabled means we chose to the run the profiler on at least some threads on a
// platform/branding/channel combination that is configured for profiling. The // platform/{released Chrome channel, development/CQ build} combination that is
// overall enable/disable state should be reported to UMA in this case. // configured for profiling. The overall enable/disable state should be reported
// to UMA in this case.
//
// The base::Optional<version_info::Channel> release_channel passed to functions
// in this interface should be the channel for released Chrome and nullopt for
// development/CQ builds.
class ThreadProfilerPlatformConfiguration { class ThreadProfilerPlatformConfiguration {
public: public:
// State of the runtime module used by the profiler on the platform (if any). // State of the runtime module used by the profiler on the platform (if any).
...@@ -41,8 +47,7 @@ class ThreadProfilerPlatformConfiguration { ...@@ -41,8 +47,7 @@ class ThreadProfilerPlatformConfiguration {
// |enabled| + |experiment| is expected to equal 100. Profiling is to be // |enabled| + |experiment| is expected to equal 100. Profiling is to be
// enabled with probability |enabled|/100. The fraction |experiment|/100 is to // enabled with probability |enabled|/100. The fraction |experiment|/100 is to
// be split in to two equal-sized experiment groups with probability // be split in to two equal-sized experiment groups with probability
// |experiment|/(2 * 100), one of which will be enabled and one disabled. As a // |experiment|/(2 * 100), one of which will be enabled and one disabled.
// special case {0, 0} means always disable.
struct RelativePopulations { struct RelativePopulations {
int enabled; int enabled;
int experiment; int experiment;
...@@ -55,26 +60,24 @@ class ThreadProfilerPlatformConfiguration { ...@@ -55,26 +60,24 @@ class ThreadProfilerPlatformConfiguration {
bool browser_test_mode_enabled); bool browser_test_mode_enabled);
// True if the platform supports the StackSamplingProfiler and the profiler is // True if the platform supports the StackSamplingProfiler and the profiler is
// to be run for the channel/chrome branding. // to be run for the released Chrome channel or development/CQ build.
bool IsSupported(bool is_chrome_branded, version_info::Channel channel) const; bool IsSupported(base::Optional<version_info::Channel> release_channel) const;
// Returns the current state of the runtime support module for the // Returns the current state of the runtime support module for the released
// channel/chrome branding on the platform. Runtime module state is valid only // Chrome channel or development/CQ build on the platform. Runtime module
// if IsSupported(). // state is valid only if IsSupported().
virtual RuntimeModuleState GetRuntimeModuleState( virtual RuntimeModuleState GetRuntimeModuleState(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const = 0;
version_info::Channel channel) const = 0;
// Request install of the runtime support module. May be invoked only if // Request install of the runtime support module. May be invoked only if
// GetRuntimeModuleState() returns kModuleAbsentButAvailable. // GetRuntimeModuleState() returns kModuleAbsentButAvailable.
virtual void RequestRuntimeModuleInstall() const {} virtual void RequestRuntimeModuleInstall() const {}
// Returns the relative population disposition for the channel/chrome branding // Returns the relative population disposition for the released Chrome channel
// on the platform. See the documentation on RelativePopulations. Enable rates // or development/CQ build on the platform. See the documentation on
// are valid only if IsSupported(). // RelativePopulations. Enable rates are valid only if IsSupported().
virtual RelativePopulations GetEnableRates( virtual RelativePopulations GetEnableRates(
bool is_chrome_branded, base::Optional<version_info::Channel> release_channel) const = 0;
version_info::Channel channel) const = 0;
// Returns the fraction of the time that profiling should be randomly enabled // Returns the fraction of the time that profiling should be randomly enabled
// for the child |process|. The return value is in the range [0.0, 1.0]. // for the child |process|. The return value is in the range [0.0, 1.0].
...@@ -87,11 +90,12 @@ class ThreadProfilerPlatformConfiguration { ...@@ -87,11 +90,12 @@ class ThreadProfilerPlatformConfiguration {
metrics::CallStackProfileParams::Thread thread) const = 0; metrics::CallStackProfileParams::Thread thread) const = 0;
protected: protected:
// True if the profiler is to be run for the channel/chrome branding on the // True if the profiler is to be run for the released Chrome channel or
// platform. Does not need to check whether the StackSamplingProfiler is // development/CQ build on the platform. Does not need to check whether the
// supported on the platform since that's done in IsSupported(). // StackSamplingProfiler is supported on the platform since that's done in
virtual bool IsSupportedForChannel(bool is_chrome_branded, // IsSupported().
version_info::Channel channel) const = 0; virtual bool IsSupportedForChannel(
base::Optional<version_info::Channel> release_channel) const = 0;
}; };
#endif // CHROME_COMMON_PROFILER_THREAD_PROFILER_PLATFORM_CONFIGURATION_H_ #endif // CHROME_COMMON_PROFILER_THREAD_PROFILER_PLATFORM_CONFIGURATION_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <utility> #include <utility>
#include "base/profiler/profiler_buildflags.h" #include "base/profiler/profiler_buildflags.h"
#include "base/test/gtest_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -62,47 +63,29 @@ bool operator==( ...@@ -62,47 +63,29 @@ bool operator==(
TEST_F(ThreadProfilerPlatformConfigurationTest, IsSupported) { TEST_F(ThreadProfilerPlatformConfigurationTest, IsSupported) {
#if !THREAD_PROFILER_SUPPORTED_ON_PLATFORM #if !THREAD_PROFILER_SUPPORTED_ON_PLATFORM
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN)); EXPECT_FALSE(config()->IsSupported(version_info::Channel::CANARY));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::DEV));
version_info::Channel::CANARY)); EXPECT_FALSE(config()->IsSupported(version_info::Channel::BETA));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::STABLE));
version_info::Channel::DEV));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true,
version_info::Channel::BETA));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true,
version_info::Channel::STABLE));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/false, EXPECT_FALSE(config()->IsSupported(base::nullopt));
version_info::Channel::UNKNOWN));
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN)); EXPECT_FALSE(config()->IsSupported(version_info::Channel::CANARY));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::DEV));
version_info::Channel::CANARY)); EXPECT_FALSE(config()->IsSupported(version_info::Channel::BETA));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::STABLE));
version_info::Channel::DEV));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true,
version_info::Channel::BETA));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true,
version_info::Channel::STABLE));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/false, EXPECT_FALSE(config()->IsSupported(base::nullopt));
version_info::Channel::UNKNOWN));
#else #else
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN)); EXPECT_TRUE(config()->IsSupported(version_info::Channel::CANARY));
EXPECT_TRUE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_TRUE(config()->IsSupported(version_info::Channel::DEV));
version_info::Channel::CANARY)); EXPECT_FALSE(config()->IsSupported(version_info::Channel::BETA));
EXPECT_TRUE(config()->IsSupported(/*is_chrome_branded=*/true, EXPECT_FALSE(config()->IsSupported(version_info::Channel::STABLE));
version_info::Channel::DEV));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true,
version_info::Channel::BETA));
EXPECT_FALSE(config()->IsSupported(/*is_chrome_branded=*/true,
version_info::Channel::STABLE));
EXPECT_TRUE(config()->IsSupported(/*is_chrome_branded=*/false, EXPECT_TRUE(config()->IsSupported(base::nullopt));
version_info::Channel::UNKNOWN));
#endif #endif
} }
...@@ -112,70 +95,53 @@ MAYBE_PLATFORM_CONFIG_TEST_F(ThreadProfilerPlatformConfigurationTest, ...@@ -112,70 +95,53 @@ MAYBE_PLATFORM_CONFIG_TEST_F(ThreadProfilerPlatformConfigurationTest,
ThreadProfilerPlatformConfiguration::RuntimeModuleState; ThreadProfilerPlatformConfiguration::RuntimeModuleState;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable, EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN));
EXPECT_EQ(RuntimeModuleState::kModuleAbsentButAvailable, EXPECT_EQ(RuntimeModuleState::kModuleAbsentButAvailable,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::CANARY));
version_info::Channel::CANARY));
EXPECT_EQ(RuntimeModuleState::kModuleAbsentButAvailable, EXPECT_EQ(RuntimeModuleState::kModuleAbsentButAvailable,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::DEV));
version_info::Channel::DEV));
EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable, EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::BETA));
version_info::Channel::BETA));
EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable, EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::STABLE));
version_info::Channel::STABLE));
EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable, EXPECT_EQ(RuntimeModuleState::kModuleNotAvailable,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN));
#else #else
EXPECT_EQ(RuntimeModuleState::kModuleNotRequired, EXPECT_EQ(RuntimeModuleState::kModuleNotRequired,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN));
EXPECT_EQ(RuntimeModuleState::kModuleNotRequired, EXPECT_EQ(RuntimeModuleState::kModuleNotRequired,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::CANARY));
version_info::Channel::CANARY));
EXPECT_EQ(RuntimeModuleState::kModuleNotRequired, EXPECT_EQ(RuntimeModuleState::kModuleNotRequired,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::DEV));
version_info::Channel::DEV));
EXPECT_EQ(RuntimeModuleState::kModuleNotRequired, EXPECT_EQ(RuntimeModuleState::kModuleNotRequired,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::BETA));
version_info::Channel::BETA));
EXPECT_EQ(RuntimeModuleState::kModuleNotRequired, EXPECT_EQ(RuntimeModuleState::kModuleNotRequired,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::STABLE));
version_info::Channel::STABLE));
EXPECT_EQ(RuntimeModuleState::kModuleNotRequired, EXPECT_EQ(RuntimeModuleState::kModuleNotRequired,
config()->GetRuntimeModuleState(/*is_chrome_branded=*/true, config()->GetRuntimeModuleState(version_info::Channel::UNKNOWN));
version_info::Channel::UNKNOWN));
#endif #endif
} }
MAYBE_PLATFORM_CONFIG_TEST_F(ThreadProfilerPlatformConfigurationTest, MAYBE_PLATFORM_CONFIG_TEST_F(ThreadProfilerPlatformConfigurationTest,
GetEnableRates) { GetEnableRates) {
// Note: death tests aren't supported on Android. Otherwise this test would
// check that all inputs result in CHECKs.
#if !defined(OS_ANDROID)
using RelativePopulations = using RelativePopulations =
ThreadProfilerPlatformConfiguration::RelativePopulations; ThreadProfilerPlatformConfiguration::RelativePopulations;
EXPECT_EQ((RelativePopulations{100, 0}), EXPECT_CHECK_DEATH(config()->GetEnableRates(version_info::Channel::UNKNOWN));
config()->GetEnableRates(/*is_chrome_branded=*/true,
version_info::Channel::UNKNOWN));
EXPECT_EQ((RelativePopulations{80, 20}), EXPECT_EQ((RelativePopulations{80, 20}),
config()->GetEnableRates(/*is_chrome_branded=*/true, config()->GetEnableRates(version_info::Channel::CANARY));
version_info::Channel::CANARY));
EXPECT_EQ((RelativePopulations{80, 20}), EXPECT_EQ((RelativePopulations{80, 20}),
config()->GetEnableRates(/*is_chrome_branded=*/true, config()->GetEnableRates(version_info::Channel::DEV));
version_info::Channel::DEV)); EXPECT_CHECK_DEATH(config()->GetEnableRates(version_info::Channel::BETA));
EXPECT_EQ((RelativePopulations{0, 0}), EXPECT_CHECK_DEATH(config()->GetEnableRates(version_info::Channel::STABLE));
config()->GetEnableRates(/*is_chrome_branded=*/true,
version_info::Channel::BETA));
EXPECT_EQ((RelativePopulations{0, 0}),
config()->GetEnableRates(/*is_chrome_branded=*/true,
version_info::Channel::STABLE));
EXPECT_EQ((RelativePopulations{100, 0}), EXPECT_EQ((RelativePopulations{100, 0}),
config()->GetEnableRates(/*is_chrome_branded=*/true, config()->GetEnableRates(base::nullopt));
version_info::Channel::UNKNOWN)); #endif
} }
MAYBE_PLATFORM_CONFIG_TEST_F(ThreadProfilerPlatformConfigurationTest, MAYBE_PLATFORM_CONFIG_TEST_F(ThreadProfilerPlatformConfigurationTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment