Invoke |started_profiling_callback| independent of whether the profiling starts successfully or not.
|started_profiling_callback| (AddProfilingClient's return callback)
must be always called even if profiling has not been started because
of mojo connection error of StartProfiling.
Because the return callback is created by
ProfilingService_AddProfilingClient_ProxyToResponder::
CreateCallback(),
The callback owns
ProfilingService_AddProfilingClient_ProxyToResponder instance.
So when the callback is destroyed,
~ProfilingService_AddProfilingClient_ProxyToResponder will be invoked,
but the destructor has DCHECK():
---
// If we're being destroyed without being run, we want to ensure the
// binding endpoint has been closed.
---
However ProfilingService is still running, not closed. So we will see
DCHECK() failure. To avoid the failure, we need to make the callback
run independent of whether profiling starts successfully or not.
Change-Id: I60a266ff15d9ea8935ae2f0a00dfa66af60318df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5418073
Reviewed-by: Takashi Toyoshima <[email protected]>
Commit-Queue: Takashi Sakamoto <[email protected]>
Reviewed-by: Erik Chen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1292886}
diff --git a/components/services/heap_profiling/connection_manager.h b/components/services/heap_profiling/connection_manager.h
index 8201fc3..09c241f 100644
--- a/components/services/heap_profiling/connection_manager.h
+++ b/components/services/heap_profiling/connection_manager.h
@@ -65,7 +65,8 @@
mojo::PendingRemote<mojom::ProfilingClient> client,
mojom::ProcessType process_type,
mojom::ProfilingParamsPtr params,
- base::OnceClosure started_profiling_closure);
+ mojom::ProfilingService::AddProfilingClientCallback
+ started_profiling_closure);
// Returns pids of clients that have started profiling.
std::vector<base::ProcessId> GetConnectionPids();