summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Greenblatt <magreenblatt@gmail.com>2023-03-14 15:12:03 -0400
committerMarshall Greenblatt <magreenblatt@gmail.com>2023-03-14 15:12:06 -0400
commit49cae3707a761f940e67f2cd25ee9fa434aafa1e (patch)
tree6e927cd64606cb80bf8aadc1d980e5102fa50289
parent3215aaebef9a71aa6f6a5a4b9a98fa765c39d31d (diff)
downloadcef-49cae3707a761f940e67f2cd25ee9fa434aafa1e.tar.gz
chrome: Move ThreadProfiler initialization to the UI thread (fixes #3465)
ThreadProfiler::CreateAndStartOnMainThread and SetMainThreadTaskRunnerImpl should be called on the same thread.
-rw-r--r--libcef/browser/main_runner.cc2
-rw-r--r--libcef/common/chrome/chrome_main_runner_delegate.cc8
-rw-r--r--libcef/common/chrome/chrome_main_runner_delegate.h2
-rw-r--r--libcef/common/main_runner_delegate.h1
4 files changed, 8 insertions, 5 deletions
diff --git a/libcef/browser/main_runner.cc b/libcef/browser/main_runner.cc
index 65d644bc..82916923 100644
--- a/libcef/browser/main_runner.cc
+++ b/libcef/browser/main_runner.cc
@@ -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());
}
diff --git a/libcef/common/chrome/chrome_main_runner_delegate.cc b/libcef/common/chrome/chrome_main_runner_delegate.cc
index 70aba721..57a92d93 100644
--- a/libcef/common/chrome/chrome_main_runner_delegate.cc
+++ b/libcef/common/chrome/chrome_main_runner_delegate.cc
@@ -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();
}
diff --git a/libcef/common/chrome/chrome_main_runner_delegate.h b/libcef/common/chrome/chrome_main_runner_delegate.h
index a153d781..970cecd1 100644
--- a/libcef/common/chrome/chrome_main_runner_delegate.h
+++ b/libcef/common/chrome/chrome_main_runner_delegate.h
@@ -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;
diff --git a/libcef/common/main_runner_delegate.h b/libcef/common/main_runner_delegate.h
index 2f9224ea..335ab2b8 100644
--- a/libcef/common/main_runner_delegate.h
+++ b/libcef/common/main_runner_delegate.h
@@ -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() {}