summaryrefslogtreecommitdiff
path: root/chromium/components/heap_profiling
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/heap_profiling')
-rw-r--r--chromium/components/heap_profiling/multi_process/client_connection_manager.cc33
-rw-r--r--chromium/components/heap_profiling/multi_process/supervisor.cc34
-rw-r--r--chromium/components/heap_profiling/multi_process/test_driver.cc30
-rw-r--r--chromium/components/heap_profiling/multi_process/test_driver.h2
4 files changed, 48 insertions, 51 deletions
diff --git a/chromium/components/heap_profiling/multi_process/client_connection_manager.cc b/chromium/components/heap_profiling/multi_process/client_connection_manager.cc
index 8cfa2aeca1b..776f652445d 100644
--- a/chromium/components/heap_profiling/multi_process/client_connection_manager.cc
+++ b/chromium/components/heap_profiling/multi_process/client_connection_manager.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/no_destructor.h"
#include "base/rand_util.h"
-#include "base/task/post_task.h"
#include "components/services/heap_profiling/public/cpp/controller.h"
#include "components/services/heap_profiling/public/cpp/profiling_client.h"
#include "components/services/heap_profiling/public/cpp/settings.h"
@@ -218,9 +217,9 @@ void ClientConnectionManager::StartProfilingProcess(base::ProcessId pid) {
}
// The BrowserChildProcessHostIterator iterator must be used on the IO thread.
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(FROM_HERE, base::BindOnce(&StartProfilingPidOnIOThread,
- controller_, pid));
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&StartProfilingPidOnIOThread, controller_, pid));
}
bool ClientConnectionManager::AllowedToProfileRenderer(
@@ -239,10 +238,9 @@ void ClientConnectionManager::StartProfilingExistingProcessesIfNecessary() {
// Start profiling the current process.
if (ShouldProfileNonRendererProcessType(
mode_, content::ProcessType::PROCESS_TYPE_BROWSER)) {
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(FROM_HERE,
- base::BindOnce(&StartProfilingBrowserProcessOnIOThread,
- controller_));
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&StartProfilingBrowserProcessOnIOThread, controller_));
}
// Start profiling connected renderers.
@@ -255,11 +253,10 @@ void ClientConnectionManager::StartProfilingExistingProcessesIfNecessary() {
}
}
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(
- FROM_HERE,
- base::BindOnce(&StartProfilingNonRenderersIfNecessaryOnIOThread,
- GetMode(), controller_));
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&StartProfilingNonRenderersIfNecessaryOnIOThread,
+ GetMode(), controller_));
}
void ClientConnectionManager::BrowserChildProcessLaunchedAndConnected(
@@ -279,9 +276,8 @@ void ClientConnectionManager::BrowserChildProcessLaunchedAndConnected(
void ClientConnectionManager::StartProfilingNonRendererChild(
const content::ChildProcessData& data) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(FROM_HERE,
- base::BindOnce(&StartProfilingNonRendererChildOnIOThread,
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&StartProfilingNonRendererChildOnIOThread,
controller_, data.Duplicate()));
}
@@ -336,9 +332,8 @@ void ClientConnectionManager::StartProfilingRenderer(
mojo::PendingRemote<mojom::ProfilingClient> client;
host->BindReceiver(client.InitWithNewPipeAndPassReceiver());
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(FROM_HERE,
- base::BindOnce(&StartProfilingClientOnIOThread, controller_,
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&StartProfilingClientOnIOThread, controller_,
std::move(client), host->GetProcess().Pid(),
mojom::ProcessType::RENDERER));
}
diff --git a/chromium/components/heap_profiling/multi_process/supervisor.cc b/chromium/components/heap_profiling/multi_process/supervisor.cc
index 295ffc2e3c0..b228e63cf89 100644
--- a/chromium/components/heap_profiling/multi_process/supervisor.cc
+++ b/chromium/components/heap_profiling/multi_process/supervisor.cc
@@ -8,7 +8,6 @@
#include "base/callback_helpers.h"
#include "base/memory/ref_counted_memory.h"
#include "base/no_destructor.h"
-#include "base/task/post_task.h"
#include "base/trace_event/memory_dump_manager.h"
#include "components/heap_profiling/multi_process/client_connection_manager.h"
#include "components/services/heap_profiling/heap_profiling_service.h"
@@ -89,12 +88,12 @@ void Supervisor::StartProfilingOnMemoryInfraThread(Mode mode,
auto profiler_receiver = profiler.InitWithNewPipeAndPassReceiver();
content::GetResourceCoordinatorService()->RegisterHeapProfiler(
std::move(profiler), helper.InitWithNewPipeAndPassReceiver());
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(FROM_HERE, base::BindOnce(&Supervisor::StartServiceOnIOThread,
- base::Unretained(this),
- std::move(profiler_receiver),
- std::move(helper), mode, stack_mode,
- sampling_rate, std::move(closure)));
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&Supervisor::StartServiceOnIOThread,
+ base::Unretained(this), std::move(profiler_receiver),
+ std::move(helper), mode, stack_mode, sampling_rate,
+ std::move(closure)));
}
Mode Supervisor::GetMode() {
@@ -112,9 +111,8 @@ void Supervisor::GetProfiledPids(GetProfiledPidsCallback callback) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK(HasStarted());
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
- ->PostTask(FROM_HERE,
- base::BindOnce(&Supervisor::GetProfiledPidsOnIOThread,
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&Supervisor::GetProfiledPidsOnIOThread,
base::Unretained(this), std::move(callback)));
}
@@ -146,10 +144,9 @@ void Supervisor::RequestTraceWithHeapDump(TraceFinishedCallback callback,
std::unique_ptr<std::string> in) {
std::string result;
result.swap(*in);
- base::CreateSingleThreadTaskRunner({content::BrowserThread::UI})
- ->PostTask(FROM_HERE,
- base::BindOnce(std::move(callback), true,
- std::move(result)));
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(std::move(callback), true, std::move(result)));
},
std::move(callback));
scoped_refptr<content::TracingController::TraceDataEndpoint> sink =
@@ -201,9 +198,8 @@ void Supervisor::StartServiceOnIOThread(
sampling_rate);
base::WeakPtr<Controller> controller_weak_ptr = controller_->GetWeakPtr();
- base::CreateSingleThreadTaskRunner({content::BrowserThread::UI})
- ->PostTask(FROM_HERE,
- base::BindOnce(&Supervisor::FinishInitializationOnUIhread,
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&Supervisor::FinishInitializationOnUIhread,
base::Unretained(this), mode,
std::move(closure), controller_weak_ptr));
}
@@ -234,8 +230,8 @@ void Supervisor::GetProfiledPidsOnIOThread(GetProfiledPidsCallback callback) {
auto post_result_to_ui_thread = base::BindOnce(
[](GetProfiledPidsCallback callback,
const std::vector<base::ProcessId>& result) {
- base::CreateSingleThreadTaskRunner({content::BrowserThread::UI})
- ->PostTask(FROM_HERE, base::BindOnce(std::move(callback), result));
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(std::move(callback), result));
},
std::move(callback));
controller_->GetProfiledPids(std::move(post_result_to_ui_thread));
diff --git a/chromium/components/heap_profiling/multi_process/test_driver.cc b/chromium/components/heap_profiling/multi_process/test_driver.cc
index c7f7154b0b9..cf61046f830 100644
--- a/chromium/components/heap_profiling/multi_process/test_driver.cc
+++ b/chromium/components/heap_profiling/multi_process/test_driver.cc
@@ -15,7 +15,6 @@
#include "base/run_loop.h"
#include "base/sampling_heap_profiler/poisson_allocation_sampler.h"
#include "base/stl_util.h"
-#include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/heap_profiler_event_filter.h"
@@ -332,14 +331,21 @@ bool ValidateProcessMmaps(base::Value* process_mmaps,
return true;
}
+void HandleOOM(size_t unsued_size) {
+ LOG(FATAL) << "Out of memory.";
+}
+
} // namespace
TestDriver::TestDriver()
: wait_for_ui_thread_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) {
+ base::PartitionAllocGlobalInit(HandleOOM);
partition_allocator_.init();
}
-TestDriver::~TestDriver() = default;
+TestDriver::~TestDriver() {
+ base::PartitionAllocGlobalUninitForTesting();
+}
bool TestDriver::RunTest(const Options& options) {
options_ = options;
@@ -352,8 +358,8 @@ bool TestDriver::RunTest(const Options& options) {
if (running_on_ui_thread_) {
has_started_ = Supervisor::GetInstance()->HasStarted();
} else {
- base::PostTask(FROM_HERE, {content::BrowserThread::UI},
- base::BindOnce(&TestDriver::GetHasStartedOnUIThread,
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&TestDriver::GetHasStartedOnUIThread,
base::Unretained(this)));
wait_for_ui_thread_.Wait();
}
@@ -373,16 +379,16 @@ bool TestDriver::RunTest(const Options& options) {
MakeTestAllocations();
CollectResults(true);
} else {
- base::PostTask(
- FROM_HERE, {content::BrowserThread::UI},
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(&TestDriver::CheckOrStartProfilingOnUIThreadAndSignal,
base::Unretained(this)));
wait_for_ui_thread_.Wait();
if (!initialization_success_)
return false;
if (ShouldProfileRenderer()) {
- base::PostTask(
- FROM_HERE, {content::BrowserThread::UI},
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(
&TestDriver::
WaitForProfilingToStartForAllRenderersUIThreadAndSignal,
@@ -390,12 +396,12 @@ bool TestDriver::RunTest(const Options& options) {
wait_for_ui_thread_.Wait();
}
if (ShouldProfileBrowser()) {
- base::PostTask(FROM_HERE, {content::BrowserThread::UI},
- base::BindOnce(&TestDriver::MakeTestAllocations,
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&TestDriver::MakeTestAllocations,
base::Unretained(this)));
}
- base::PostTask(FROM_HERE, {content::BrowserThread::UI},
- base::BindOnce(&TestDriver::CollectResults,
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&TestDriver::CollectResults,
base::Unretained(this), false));
wait_for_ui_thread_.Wait();
}
diff --git a/chromium/components/heap_profiling/multi_process/test_driver.h b/chromium/components/heap_profiling/multi_process/test_driver.h
index 481802aaf6c..10e0820aa01 100644
--- a/chromium/components/heap_profiling/multi_process/test_driver.h
+++ b/chromium/components/heap_profiling/multi_process/test_driver.h
@@ -129,7 +129,7 @@ class TestDriver {
size_t total_variadic_allocations_ = 0;
// Use to make PA allocations, which should also be shimmed.
- base::PartitionAllocatorGeneric partition_allocator_;
+ base::PartitionAllocator partition_allocator_;
// Contains nothing until |CollectResults| has been called.
std::string serialized_trace_;