Refactor as per @zcbenz comments
Also fix issue where we run the single instance callback *not* on the UI thread, this apparently results in a hung process.
This commit is contained in:
parent
ecbeb0d117
commit
0ab83b301d
7 changed files with 22 additions and 16 deletions
|
@ -407,7 +407,12 @@ bool NotificationCallbackWrapper(
|
|||
const base::FilePath& cwd) {
|
||||
// Make sure the callback is called after app gets ready.
|
||||
if (Browser::Get()->is_ready()) {
|
||||
callback.Run(cmd, cwd);
|
||||
// We definitely want to call this callback on the UI thread
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI,
|
||||
FROM_HERE,
|
||||
base::Bind(base::IgnoreResult(callback), cmd, cwd)
|
||||
);
|
||||
} else {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner(
|
||||
base::ThreadTaskRunnerHandle::Get());
|
||||
|
@ -522,7 +527,6 @@ App::App(v8::Isolate* isolate) {
|
|||
base::ProcessMetrics::CreateCurrentProcessMetrics()));
|
||||
app_metrics_[pid] = std::move(process_metric);
|
||||
Init(isolate);
|
||||
App::self_ = this;
|
||||
}
|
||||
|
||||
App::~App() {
|
||||
|
@ -533,12 +537,6 @@ App::~App() {
|
|||
content::BrowserChildProcessObserver::Remove(this);
|
||||
}
|
||||
|
||||
App* App::self_ = nullptr;
|
||||
|
||||
App* App::Get() {
|
||||
return App::self_;
|
||||
}
|
||||
|
||||
void App::OnBeforeQuit(bool* prevent_default) {
|
||||
*prevent_default = Emit("before-quit");
|
||||
}
|
||||
|
@ -586,7 +584,7 @@ void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
|
|||
Emit("ready", launch_info);
|
||||
}
|
||||
|
||||
void App::PreMainMessageLoopRun() {
|
||||
void App::OnPreMainMessageLoopRun() {
|
||||
if (process_singleton_) {
|
||||
process_singleton_->OnBrowserReady();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue