Commit 6dc9eb71 authored by Eugene Zemtsov's avatar Eugene Zemtsov Committed by Commit Bot

Rename memory_infra_background_whitelist to allowlist

Also renaming related functions and variables.
Making wording more inclusive.

Bug: 842296
Change-Id: If1121d2496c151a87ecb9a517633195d8e851a7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095841Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarssid <ssid@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749314}
parent 51371b2f
......@@ -811,8 +811,8 @@ jumbo_component("base") {
"trace_event/memory_dump_request_args.h",
"trace_event/memory_dump_scheduler.cc",
"trace_event/memory_dump_scheduler.h",
"trace_event/memory_infra_background_whitelist.cc",
"trace_event/memory_infra_background_whitelist.h",
"trace_event/memory_infra_background_allowlist.cc",
"trace_event/memory_infra_background_allowlist.h",
"trace_event/memory_usage_estimator.cc",
"trace_event/memory_usage_estimator.h",
"trace_event/process_memory_dump.cc",
......@@ -2756,7 +2756,7 @@ test("base_unittests") {
"trace_event/memory_allocator_dump_unittest.cc",
"trace_event/memory_dump_manager_unittest.cc",
"trace_event/memory_dump_scheduler_unittest.cc",
"trace_event/memory_infra_background_whitelist_unittest.cc",
"trace_event/memory_infra_background_allowlist_unittest.cc",
"trace_event/memory_usage_estimator_unittest.cc",
"trace_event/process_memory_dump_unittest.cc",
"trace_event/trace_arguments_unittest.cc",
......
......@@ -28,7 +28,7 @@
#include "base/trace_event/malloc_dump_provider.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_scheduler.h"
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
......@@ -180,14 +180,13 @@ void MemoryDumpManager::RegisterDumpProviderInternal(
return;
// Only a handful of MDPs are required to compute the memory metrics. These
// have small enough performance overhead that it is resonable to run them
// have small enough performance overhead that it is reasonable to run them
// in the background while the user is doing other things. Those MDPs are
// 'whitelisted for background mode'.
bool whitelisted_for_background_mode = IsMemoryDumpProviderWhitelisted(name);
// 'allowed in background mode'.
bool allowed_in_background_mode = IsMemoryDumpProviderInAllowlist(name);
scoped_refptr<MemoryDumpProviderInfo> mdpinfo =
new MemoryDumpProviderInfo(mdp, name, std::move(task_runner), options,
whitelisted_for_background_mode);
scoped_refptr<MemoryDumpProviderInfo> mdpinfo = new MemoryDumpProviderInfo(
mdp, name, std::move(task_runner), options, allowed_in_background_mode);
{
AutoLock lock(lock_);
......@@ -348,7 +347,7 @@ void MemoryDumpManager::ContinueAsyncProcessDump(
// providers. Ignore other providers and continue.
if (pmd_async_state->req_args.level_of_detail ==
MemoryDumpLevelOfDetail::BACKGROUND &&
!mdpinfo->whitelisted_for_background_mode) {
!mdpinfo->allowed_in_background_mode) {
pmd_async_state->pending_dump_providers.pop_back();
continue;
}
......
......@@ -30,7 +30,7 @@
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_request_args.h"
#include "base/trace_event/memory_dump_scheduler.h"
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -752,7 +752,7 @@ TEST_F(MemoryDumpManagerTest, TriggerDumpWithoutTracing) {
}
TEST_F(MemoryDumpManagerTest, BackgroundWhitelisting) {
SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
SetDumpProviderAllowlistForTesting(kTestMDPWhitelist);
// Standard provider with default options (create dump for current process).
MockMemoryDumpProvider backgroundMdp;
......@@ -857,7 +857,7 @@ class SimpleMockMemoryDumpProvider : public MemoryDumpProvider {
};
TEST_F(MemoryDumpManagerTest, NoStackOverflowWithTooManyMDPs) {
SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
SetDumpProviderAllowlistForTesting(kTestMDPWhitelist);
int kMDPCount = 1000;
std::vector<std::unique_ptr<SimpleMockMemoryDumpProvider>> mdps;
......
......@@ -16,12 +16,12 @@ MemoryDumpProviderInfo::MemoryDumpProviderInfo(
const char* name,
scoped_refptr<SequencedTaskRunner> task_runner,
const MemoryDumpProvider::Options& options,
bool whitelisted_for_background_mode)
bool allowed_in_background_mode)
: dump_provider(dump_provider),
options(options),
name(name),
task_runner(std::move(task_runner)),
whitelisted_for_background_mode(whitelisted_for_background_mode),
allowed_in_background_mode(allowed_in_background_mode),
consecutive_failures(0),
disabled(false) {}
......
......@@ -58,7 +58,7 @@ struct BASE_EXPORT MemoryDumpProviderInfo
const char* name,
scoped_refptr<SequencedTaskRunner> task_runner,
const MemoryDumpProvider::Options& options,
bool whitelisted_for_background_mode);
bool allowed_in_background_mode);
// It is safe to access the const fields below from any thread as they are
// never mutated.
......@@ -78,7 +78,7 @@ struct BASE_EXPORT MemoryDumpProviderInfo
const scoped_refptr<SequencedTaskRunner> task_runner;
// True if the dump provider is whitelisted for background mode.
const bool whitelisted_for_background_mode;
const bool allowed_in_background_mode;
// These fields below, instead, are not thread safe and can be mutated only:
// - On the |task_runner|, when not null (i.e. for thread-bound MDPS).
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include <ctype.h>
#include <string.h>
......@@ -15,12 +15,12 @@ namespace base {
namespace trace_event {
namespace {
// The names of dump providers whitelisted for background tracing. Dump
// The names of dump providers allowed to perform background tracing. Dump
// providers can be added here only if the background mode dump has very
// little processor and memory overhead.
// TODO(ssid): Some dump providers do not create ownership edges on background
// dump. So, the effective size will not be correct.
const char* const kDumpProviderWhitelist[] = {
const char* const kDumpProviderAllowlist[] = {
"android::ResourceManagerImpl",
"AutocompleteController",
"BlinkGC",
......@@ -70,7 +70,7 @@ const char* const kDumpProviderWhitelist[] = {
// A list of string names that are allowed for the memory allocator dumps in
// background mode.
const char* const kAllocatorDumpNameWhitelist[] = {
const char* const kAllocatorDumpNameAllowlist[] = {
"blink_gc/main/heap",
"blink_gc/workers/heap/worker_0x?",
"blink_objects/AdSubframe",
......@@ -387,9 +387,9 @@ const char* const kAllocatorDumpNameWhitelist[] = {
nullptr // End of list marker.
};
const char* const* g_dump_provider_whitelist = kDumpProviderWhitelist;
const char* const* g_allocator_dump_name_whitelist =
kAllocatorDumpNameWhitelist;
const char* const* g_dump_provider_allowlist = kDumpProviderAllowlist;
const char* const* g_allocator_dump_name_allowlist =
kAllocatorDumpNameAllowlist;
bool IsMemoryDumpProviderInList(const char* mdp_name, const char* const* list) {
for (size_t i = 0; list[i] != nullptr; ++i) {
......@@ -401,12 +401,12 @@ bool IsMemoryDumpProviderInList(const char* mdp_name, const char* const* list) {
} // namespace
bool IsMemoryDumpProviderWhitelisted(const char* mdp_name) {
return IsMemoryDumpProviderInList(mdp_name, g_dump_provider_whitelist);
bool IsMemoryDumpProviderInAllowlist(const char* mdp_name) {
return IsMemoryDumpProviderInList(mdp_name, g_dump_provider_allowlist);
}
bool IsMemoryAllocatorDumpNameWhitelisted(const std::string& name) {
// Global dumps are explicitly whitelisted for background use.
bool IsMemoryAllocatorDumpNameInAllowlist(const std::string& name) {
// Global dumps that are of hex digits are all allowed for background use.
if (base::StartsWith(name, "global/", CompareCase::SENSITIVE)) {
for (size_t i = strlen("global/"); i < name.size(); i++)
if (!base::IsHexDigit(name[i]))
......@@ -440,20 +440,20 @@ bool IsMemoryAllocatorDumpNameWhitelisted(const std::string& name) {
}
}
for (size_t i = 0; g_allocator_dump_name_whitelist[i] != nullptr; ++i) {
if (stripped_str == g_allocator_dump_name_whitelist[i]) {
for (size_t i = 0; g_allocator_dump_name_allowlist[i] != nullptr; ++i) {
if (stripped_str == g_allocator_dump_name_allowlist[i]) {
return true;
}
}
return false;
}
void SetDumpProviderWhitelistForTesting(const char* const* list) {
g_dump_provider_whitelist = list;
void SetDumpProviderAllowlistForTesting(const char* const* list) {
g_dump_provider_allowlist = list;
}
void SetAllocatorDumpNameWhitelistForTesting(const char* const* list) {
g_allocator_dump_name_whitelist = list;
void SetAllocatorDumpNameAllowlistForTesting(const char* const* list) {
g_allocator_dump_name_allowlist = list;
}
} // namespace trace_event
......
......@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_TRACE_EVENT_MEMORY_INFRA_BACKGROUND_WHITELIST_H_
#define BASE_TRACE_EVENT_MEMORY_INFRA_BACKGROUND_WHITELIST_H_
#ifndef BASE_TRACE_EVENT_MEMORY_INFRA_BACKGROUND_ALLOWLIST_H_
#define BASE_TRACE_EVENT_MEMORY_INFRA_BACKGROUND_ALLOWLIST_H_
// This file contains the whitelists for background mode to limit the tracing
// overhead and remove sensitive information from traces.
// This file contains the allowlists (aka whitelists) for background mode to
// limit the tracing overhead and remove sensitive information from traces.
#include <string>
......@@ -15,19 +15,19 @@
namespace base {
namespace trace_event {
// Checks if the given |mdp_name| is in the whitelist.
bool BASE_EXPORT IsMemoryDumpProviderWhitelisted(const char* mdp_name);
// Checks if the given |mdp_name| is in the allow list.
bool BASE_EXPORT IsMemoryDumpProviderInAllowlist(const char* mdp_name);
// Checks if the given |name| matches any of the whitelisted patterns.
bool BASE_EXPORT IsMemoryAllocatorDumpNameWhitelisted(const std::string& name);
// Checks if the given |name| matches any of the allowed patterns.
bool BASE_EXPORT IsMemoryAllocatorDumpNameInAllowlist(const std::string& name);
// The whitelist is replaced with the given list for tests. The last element of
// the list must be nullptr.
void BASE_EXPORT SetDumpProviderWhitelistForTesting(const char* const* list);
// The allow list is replaced with the given list for tests. The last element
// of the list must be nullptr.
void BASE_EXPORT SetDumpProviderAllowlistForTesting(const char* const* list);
void BASE_EXPORT
SetAllocatorDumpNameWhitelistForTesting(const char* const* list);
SetAllocatorDumpNameAllowlistForTesting(const char* const* list);
} // namespace trace_event
} // namespace base
#endif // BASE_TRACE_EVENT_MEMORY_INFRA_BACKGROUND_WHITELIST_H_
#endif // BASE_TRACE_EVENT_MEMORY_INFRA_BACKGROUND_ALLOWLIST_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -10,25 +10,25 @@ namespace base {
namespace trace_event {
TEST(MemoryInfraBackgroundWhitelist, Whitelist) {
// Global dumps that are of hex digits are all whitelisted for background use.
EXPECT_TRUE(IsMemoryAllocatorDumpNameWhitelisted("global/01234ABCDEF"));
TEST(MemoryInfraBackgroundAllowlist, Allowlist) {
// Global dumps that are of hex digits are all allowed for background use.
EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("global/01234ABCDEF"));
EXPECT_TRUE(
IsMemoryAllocatorDumpNameWhitelisted("shared_memory/01234ABCDEF"));
IsMemoryAllocatorDumpNameInAllowlist("shared_memory/01234ABCDEF"));
// Global dumps that contain non-hex digits are not whitelisted.
EXPECT_FALSE(IsMemoryAllocatorDumpNameWhitelisted("global/GHIJK"));
EXPECT_FALSE(IsMemoryAllocatorDumpNameWhitelisted("shared_memory/GHIJK"));
// Global dumps that contain non-hex digits are not in the allowlist.
EXPECT_FALSE(IsMemoryAllocatorDumpNameInAllowlist("global/GHIJK"));
EXPECT_FALSE(IsMemoryAllocatorDumpNameInAllowlist("shared_memory/GHIJK"));
// Test a couple that contain pointer values.
EXPECT_TRUE(IsMemoryAllocatorDumpNameWhitelisted("net/url_request_context"));
EXPECT_TRUE(IsMemoryAllocatorDumpNameWhitelisted(
EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("net/url_request_context"));
EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist(
"net/url_request_context/app_request/0x123/cookie_monster"));
EXPECT_TRUE(
IsMemoryAllocatorDumpNameWhitelisted("net/http_network_session_0x123"));
IsMemoryAllocatorDumpNameInAllowlist("net/http_network_session_0x123"));
EXPECT_FALSE(
IsMemoryAllocatorDumpNameWhitelisted("net/http_network_session/0x123"));
EXPECT_TRUE(IsMemoryAllocatorDumpNameWhitelisted(
IsMemoryAllocatorDumpNameInAllowlist("net/http_network_session/0x123"));
EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist(
"net/http_network_session_0x123/quic_stream_factory"));
}
......
......@@ -12,7 +12,7 @@
#include "base/memory/shared_memory_tracker.h"
#include "base/process/process_metrics.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/trace_event_impl.h"
#include "base/trace_event/traced_value.h"
#include "base/unguessable_token.h"
......@@ -256,7 +256,7 @@ MemoryAllocatorDump* ProcessMemoryDump::AddAllocatorDumpInternal(
// In background mode return the black hole dump, if invalid dump name is
// given.
if (dump_args_.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND &&
!IsMemoryAllocatorDumpNameWhitelisted(mad->absolute_name())) {
!IsMemoryAllocatorDumpNameInAllowlist(mad->absolute_name())) {
return GetBlackHoleMad();
}
......
......@@ -12,7 +12,7 @@
#include "base/memory/writable_shared_memory_region.h"
#include "base/process/process_metrics.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/trace_log.h"
#include "base/trace_event/traced_value.h"
#include "build/build_config.h"
......@@ -384,7 +384,7 @@ TEST(ProcessMemoryDumpTest, BackgroundModeTest) {
std::unique_ptr<ProcessMemoryDump> pmd(
new ProcessMemoryDump(background_args));
ProcessMemoryDump::is_black_hole_non_fatal_for_testing_ = true;
SetAllocatorDumpNameWhitelistForTesting(kTestDumpNameWhitelist);
SetAllocatorDumpNameAllowlistForTesting(kTestDumpNameWhitelist);
MemoryAllocatorDump* black_hole_mad = pmd->GetBlackHoleMad();
// GetAllocatorDump works for uncreated dumps.
......@@ -428,19 +428,19 @@ TEST(ProcessMemoryDumpTest, BackgroundModeTest) {
EXPECT_NE(black_hole_mad, pmd->GetAllocatorDump("Whitelisted/TestName"));
// Test whitelisted entries.
ASSERT_TRUE(IsMemoryAllocatorDumpNameWhitelisted("Whitelisted/TestName"));
ASSERT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("Whitelisted/TestName"));
// Global dumps should be whitelisted.
ASSERT_TRUE(IsMemoryAllocatorDumpNameWhitelisted("global/13456"));
ASSERT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("global/13456"));
// Global dumps with non-guids should not be.
ASSERT_FALSE(IsMemoryAllocatorDumpNameWhitelisted("global/random"));
ASSERT_FALSE(IsMemoryAllocatorDumpNameInAllowlist("global/random"));
// Random names should not.
ASSERT_FALSE(IsMemoryAllocatorDumpNameWhitelisted("NotWhitelisted/TestName"));
ASSERT_FALSE(IsMemoryAllocatorDumpNameInAllowlist("NotWhitelisted/TestName"));
// Check hex processing.
ASSERT_TRUE(IsMemoryAllocatorDumpNameWhitelisted("Whitelisted/0xA1b2"));
ASSERT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("Whitelisted/0xA1b2"));
}
TEST(ProcessMemoryDumpTest, GuidsTest) {
......
......@@ -194,8 +194,8 @@ static_assert(41 == syncer::ModelType::NUM_ENTRIES,
"and suffix SyncModelType in histograms.xml.");
static_assert(41 == syncer::ModelType::NUM_ENTRIES,
"When adding a new type, update kAllocatorDumpNameWhitelist in "
"base/trace_event/memory_infra_background_whitelist.cc.");
"When adding a new type, update kAllocatorDumpNameAllowlist in "
"base/trace_event/memory_infra_background_allowlist.cc.");
void AddDefaultFieldValue(ModelType type, sync_pb::EntitySpecifics* specifics) {
switch (type) {
......
......@@ -16,7 +16,7 @@
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_dump_manager_test_utils.h"
#include "base/trace_event/memory_dump_scheduler.h"
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/trace_buffer.h"
#include "base/trace_event/trace_config.h"
#include "base/trace_event/trace_config_memory_test_util.h"
......@@ -298,7 +298,7 @@ TEST_F(MemoryTracingIntegrationTest, InitializedAfterStartOfTracing) {
// DETAILED, even if requested explicitly.
TEST_F(MemoryTracingIntegrationTest, TestBackgroundTracingSetup) {
InitializeClientProcess(mojom::ProcessType::BROWSER);
base::trace_event::SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
base::trace_event::SetDumpProviderAllowlistForTesting(kTestMDPWhitelist);
auto mdp = std::make_unique<MockMemoryDumpProvider>();
RegisterDumpProvider(&*mdp, nullptr, MemoryDumpProvider::Options(),
kWhitelistedMDPName);
......@@ -444,7 +444,7 @@ TEST_F(MemoryTracingIntegrationTest, PeriodicDumpingWithMultipleModes) {
TEST_F(MemoryTracingIntegrationTest, TestWhitelistingMDP) {
InitializeClientProcess(mojom::ProcessType::RENDERER);
base::trace_event::SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
base::trace_event::SetDumpProviderAllowlistForTesting(kTestMDPWhitelist);
std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider);
RegisterDumpProvider(mdp1.get(), nullptr);
std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider);
......
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