fix: record cpu_profiler data for main process (#21187)

* fix: record cpu_profiler data for main process

* kick ci
This commit is contained in:
Jeremy Apthorp 2019-11-21 18:05:41 -08:00 committed by Shelley Vohr
parent 135a64955c
commit 033d309874
4 changed files with 17 additions and 0 deletions

View file

@ -24,6 +24,7 @@
#include "ipc/ipc_buildflags.h"
#include "services/service_manager/embedder/switches.h"
#include "services/service_manager/sandbox/switches.h"
#include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h"
#include "shell/app/atom_content_client.h"
#include "shell/browser/atom_browser_client.h"
#include "shell/browser/atom_gpu_client.h"
@ -182,6 +183,9 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
if (env->HasVar("ELECTRON_DISABLE_SANDBOX"))
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
tracing_sampler_profiler_ =
tracing::TracingSamplerProfiler::CreateOnMainThread();
chrome::RegisterPathProvider();
#if defined(OS_MACOSX)

View file

@ -11,6 +11,10 @@
#include "content/public/app/content_main_delegate.h"
#include "content/public/common/content_client.h"
namespace tracing {
class TracingSamplerProfiler;
}
namespace electron {
void LoadResourceBundle(const std::string& locale);
@ -51,6 +55,7 @@ class AtomMainDelegate : public content::ContentMainDelegate {
std::unique_ptr<content::ContentGpuClient> gpu_client_;
std::unique_ptr<content::ContentRendererClient> renderer_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_;
std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler_;
DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate);
};

View file

@ -32,6 +32,7 @@
#include "services/device/public/mojom/constants.mojom.h"
#include "services/network/public/cpp/features.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h"
#include "shell/app/atom_main_delegate.h"
#include "shell/browser/api/atom_api_app.h"
#include "shell/browser/atom_browser_client.h"
@ -389,6 +390,12 @@ int AtomBrowserMainParts::PreCreateThreads() {
return 0;
}
void AtomBrowserMainParts::PostCreateThreads() {
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&tracing::TracingSamplerProfiler::CreateOnChildThread));
}
void AtomBrowserMainParts::PostDestroyThreads() {
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
extensions_browser_client_.reset();

View file

@ -92,6 +92,7 @@ class AtomBrowserMainParts : public content::BrowserMainParts {
void PostMainMessageLoopStart() override;
void PostMainMessageLoopRun() override;
void PreMainMessageLoopStart() override;
void PostCreateThreads() override;
void PostDestroyThreads() override;
private: