Move OnBrowserReady call to PreMainMessageLoopRun to account for timing issues on macOS
This commit is contained in:
parent
28900a9b63
commit
f928a399ae
3 changed files with 14 additions and 0 deletions
|
@ -522,6 +522,7 @@ App::App(v8::Isolate* isolate) {
|
||||||
base::ProcessMetrics::CreateCurrentProcessMetrics()));
|
base::ProcessMetrics::CreateCurrentProcessMetrics()));
|
||||||
app_metrics_[pid] = std::move(process_metric);
|
app_metrics_[pid] = std::move(process_metric);
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
|
App::self_ = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
App::~App() {
|
App::~App() {
|
||||||
|
@ -532,6 +533,10 @@ App::~App() {
|
||||||
content::BrowserChildProcessObserver::Remove(this);
|
content::BrowserChildProcessObserver::Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App* App::Get() {
|
||||||
|
return App::self_;
|
||||||
|
}
|
||||||
|
|
||||||
void App::OnBeforeQuit(bool* prevent_default) {
|
void App::OnBeforeQuit(bool* prevent_default) {
|
||||||
*prevent_default = Emit("before-quit");
|
*prevent_default = Emit("before-quit");
|
||||||
}
|
}
|
||||||
|
@ -577,7 +582,9 @@ void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||||
media::AudioManager::SetGlobalAppName(Browser::Get()->GetName());
|
media::AudioManager::SetGlobalAppName(Browser::Get()->GetName());
|
||||||
#endif
|
#endif
|
||||||
Emit("ready", launch_info);
|
Emit("ready", launch_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::PreMainMessageLoopRun() {
|
||||||
if (process_singleton_) {
|
if (process_singleton_) {
|
||||||
process_singleton_->OnBrowserReady();
|
process_singleton_->OnBrowserReady();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
||||||
|
static App* Get();
|
||||||
|
|
||||||
// Called when window with disposition needs to be created.
|
// Called when window with disposition needs to be created.
|
||||||
void OnCreateWindow(
|
void OnCreateWindow(
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
|
@ -94,10 +96,12 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
base::FilePath GetAppPath() const;
|
base::FilePath GetAppPath() const;
|
||||||
void RenderProcessReady(content::RenderProcessHost* host);
|
void RenderProcessReady(content::RenderProcessHost* host);
|
||||||
void RenderProcessDisconnected(base::ProcessId host_pid);
|
void RenderProcessDisconnected(base::ProcessId host_pid);
|
||||||
|
void PreMainMessageLoopRun();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit App(v8::Isolate* isolate);
|
explicit App(v8::Isolate* isolate);
|
||||||
~App() override;
|
~App() override;
|
||||||
|
static App* self_ = nullptr;
|
||||||
|
|
||||||
// BrowserObserver:
|
// BrowserObserver:
|
||||||
void OnBeforeQuit(bool* prevent_default) override;
|
void OnBeforeQuit(bool* prevent_default) override;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "atom/browser/atom_browser_main_parts.h"
|
#include "atom/browser/atom_browser_main_parts.h"
|
||||||
|
|
||||||
|
#include "atom/browser/api/atom_api_app.h"
|
||||||
#include "atom/browser/api/trackable_object.h"
|
#include "atom/browser/api/trackable_object.h"
|
||||||
#include "atom/browser/atom_access_token_store.h"
|
#include "atom/browser/atom_access_token_store.h"
|
||||||
#include "atom/browser/atom_browser_client.h"
|
#include "atom/browser/atom_browser_client.h"
|
||||||
|
@ -183,6 +184,8 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
std::unique_ptr<base::DictionaryValue> empty_info(new base::DictionaryValue);
|
std::unique_ptr<base::DictionaryValue> empty_info(new base::DictionaryValue);
|
||||||
Browser::Get()->DidFinishLaunching(*empty_info);
|
Browser::Get()->DidFinishLaunching(*empty_info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
atom::api::App::Get()->PreMainMessageLoopRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue