chrome: Move ThreadProfiler initialization to the UI thread (fixes #3465)
ThreadProfiler::CreateAndStartOnMainThread and SetMainThreadTaskRunnerImpl should be called on the same thread.
This commit is contained in:
parent
178a44bd18
commit
0a2c7a1070
|
@ -394,6 +394,7 @@ bool CefMainRunner::ContentMainRun(bool* initialized,
|
|||
|
||||
if (!CreateUIThread(base::BindOnce(
|
||||
[](CefMainRunner* runner, base::WaitableEvent* event) {
|
||||
runner->main_delegate_->BeforeUIThreadInitialize();
|
||||
content::ContentMainRun(runner->main_runner_.get());
|
||||
event->Signal();
|
||||
},
|
||||
|
@ -408,6 +409,7 @@ bool CefMainRunner::ContentMainRun(bool* initialized,
|
|||
uithread_startup_event.Wait();
|
||||
} else {
|
||||
*initialized = true;
|
||||
main_delegate_->BeforeUIThreadInitialize();
|
||||
content::ContentMainRun(main_runner_.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ void ChromeMainRunnerDelegate::BeforeMainThreadInitialize(
|
|||
#else
|
||||
base::CommandLine::Init(args.argc, args.argv);
|
||||
#endif
|
||||
|
||||
sampling_profiler_ = std::make_unique<MainThreadStackSamplingProfiler>();
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::BeforeMainMessageLoopRun(
|
||||
|
@ -70,14 +68,16 @@ bool ChromeMainRunnerDelegate::HandleMainMessageLoopQuit() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::BeforeUIThreadInitialize() {
|
||||
sampling_profiler_ = std::make_unique<MainThreadStackSamplingProfiler>();
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::AfterUIThreadShutdown() {
|
||||
static_cast<ChromeContentBrowserClient*>(
|
||||
CefAppManager::Get()->GetContentClient()->browser())
|
||||
->CleanupOnUIThread();
|
||||
main_delegate_->CleanupOnUIThread();
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::AfterMainThreadShutdown() {
|
||||
sampling_profiler_.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ class ChromeMainRunnerDelegate : public CefMainRunnerDelegate {
|
|||
void BeforeMainThreadInitialize(const CefMainArgs& args) override;
|
||||
void BeforeMainMessageLoopRun(base::RunLoop* run_loop) override;
|
||||
bool HandleMainMessageLoopQuit() override;
|
||||
void BeforeUIThreadInitialize() override;
|
||||
void AfterUIThreadShutdown() override;
|
||||
void AfterMainThreadShutdown() override;
|
||||
void BeforeExecuteProcess(const CefMainArgs& args) override;
|
||||
void AfterExecuteProcess() override;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class CefMainRunnerDelegate {
|
|||
virtual void BeforeMainThreadRun() {}
|
||||
virtual void BeforeMainMessageLoopRun(base::RunLoop* run_loop) {}
|
||||
virtual bool HandleMainMessageLoopQuit() { return false; }
|
||||
virtual void BeforeUIThreadInitialize() {}
|
||||
virtual void AfterUIThreadInitialize() {}
|
||||
virtual void AfterUIThreadShutdown() {}
|
||||
virtual void BeforeMainThreadShutdown() {}
|
||||
|
|
Loading…
Reference in New Issue