migrate off QuitCurrent*Deprecated in browser.cc
modelled after https://chromium-review.googlesource.com/c/chromium/src/+/1096475 and https://chromium-review.googlesource.com/c/chromium/src/+/1096475
This commit is contained in:
parent
98829aa916
commit
f5eaa97d9d
4 changed files with 21 additions and 3 deletions
|
@ -260,6 +260,11 @@ bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
|||
return brightray::BrowserMainParts::MainMessageLoopRun(result_code);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreDefaultMainMessageLoopRun(
|
||||
base::OnceClosure quit_closure) {
|
||||
Browser::SetMainMessageLoopQuitClosure(std::move(quit_closure));
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||
brightray::BrowserMainParts::PostMainMessageLoopStart();
|
||||
#if defined(OS_POSIX)
|
||||
|
|
|
@ -81,6 +81,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
|||
void ToolkitInitialized() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
bool MainMessageLoopRun(int* result_code) override;
|
||||
void PreDefaultMainMessageLoopRun(base::OnceClosure quit_closure) override;
|
||||
void PostMainMessageLoopStart() override;
|
||||
void PostMainMessageLoopRun() override;
|
||||
#if defined(OS_MACOSX)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
|
@ -14,6 +15,7 @@
|
|||
#include "atom/browser/window_list.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
|
@ -23,6 +25,9 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
// Null until/unless the default main message loop is running.
|
||||
base::NoDestructor<base::OnceClosure> g_quit_main_message_loop;
|
||||
|
||||
Browser::LoginItemSettings::LoginItemSettings() = default;
|
||||
Browser::LoginItemSettings::~LoginItemSettings() = default;
|
||||
Browser::LoginItemSettings::LoginItemSettings(const LoginItemSettings& other) =
|
||||
|
@ -90,9 +95,8 @@ void Browser::Shutdown() {
|
|||
for (BrowserObserver& observer : observers_)
|
||||
observer.OnQuit();
|
||||
|
||||
if (base::ThreadTaskRunnerHandle::IsSet()) {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
|
||||
if (*g_quit_main_message_loop) {
|
||||
std::move(*g_quit_main_message_loop).Run();
|
||||
} else {
|
||||
// There is no message loop available so we are in early stage.
|
||||
exit(0);
|
||||
|
@ -191,6 +195,10 @@ void Browser::PreMainMessageLoopRun() {
|
|||
}
|
||||
}
|
||||
|
||||
void Browser::SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) {
|
||||
*g_quit_main_message_loop = std::move(quit_closure);
|
||||
}
|
||||
|
||||
void Browser::NotifyAndShutdown() {
|
||||
if (is_shutdown_)
|
||||
return;
|
||||
|
|
|
@ -239,6 +239,10 @@ class Browser : public WindowListObserver {
|
|||
|
||||
void PreMainMessageLoopRun();
|
||||
|
||||
// Stores the supplied |quit_closure|, to be run when the last Browser
|
||||
// instance is destroyed.
|
||||
static void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
|
||||
|
||||
void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); }
|
||||
|
||||
void RemoveObserver(BrowserObserver* obs) { observers_.RemoveObserver(obs); }
|
||||
|
|
Loading…
Reference in a new issue