Browse Source

Creates TaskScheduler and MessageLoop on main thread early

https://chromium-review.googlesource.com/c/chromium/src/+/1072387
Jeremy Apthorp 6 years ago
parent
commit
8eb15f7554

+ 10 - 0
atom/app/atom_main_delegate.cc

@@ -35,6 +35,10 @@
 #include "atom/common/common_message_generator.h"
 #endif
 
+#if defined(OS_MACOSX)
+#include "atom/app/atom_main_delegate_mac.h"
+#endif
+
 namespace atom {
 
 namespace {
@@ -158,6 +162,12 @@ void AtomMainDelegate::PreSandboxStartup() {
 #endif
 }
 
+void AtomMainDelegate::PreContentInitialization() {
+#if defined(OS_MACOSX)
+  RegisterAtomCrApp();
+#endif
+}
+
 content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
   browser_client_.reset(new AtomBrowserClient);
   return browser_client_.get();

+ 1 - 0
atom/app/atom_main_delegate.h

@@ -22,6 +22,7 @@ class AtomMainDelegate : public brightray::MainDelegate {
   // content::ContentMainDelegate:
   bool BasicStartupComplete(int* exit_code) override;
   void PreSandboxStartup() override;
+  void PreContentInitialization() override;
   content::ContentBrowserClient* CreateContentBrowserClient() override;
   content::ContentRendererClient* CreateContentRendererClient() override;
   content::ContentUtilityClient* CreateContentUtilityClient() override;

+ 15 - 0
atom/app/atom_main_delegate_mac.h

@@ -0,0 +1,15 @@
+// Copyright 2013 Slack Technologies, Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_MAC_H_
+#define ATOM_APP_ATOM_MAIN_DELEGATE_MAC_H_
+
+namespace atom {
+
+// Initializes NSApplication.
+void RegisterAtomCrApp();
+
+}  // namespace atom
+
+#endif  // ATOM_APP_ATOM_MAIN_DELEGATE_MAC_H_

+ 6 - 0
atom/app/atom_main_delegate_mac.mm

@@ -4,6 +4,7 @@
 
 #include "atom/app/atom_main_delegate.h"
 
+#include "atom/browser/mac/atom_application.h"
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/mac/bundle_locations.h"
@@ -63,4 +64,9 @@ void AtomMainDelegate::SetUpBundleOverrides() {
   base::mac::SetBaseBundleID(base_bundle_id.c_str());
 }
 
+void RegisterAtomCrApp() {
+  // Force the NSApplication subclass to be used.
+  [AtomApplication sharedApplication];
+}
+
 }  // namespace atom

+ 0 - 4
atom/browser/atom_browser_main_parts_mac.mm

@@ -4,7 +4,6 @@
 
 #include "atom/browser/atom_browser_main_parts.h"
 
-#include "atom/browser/mac/atom_application.h"
 #include "atom/browser/mac/atom_application_delegate.h"
 #include "base/mac/bundle_locations.h"
 #include "base/mac/foundation_util.h"
@@ -13,9 +12,6 @@
 namespace atom {
 
 void AtomBrowserMainParts::PreMainMessageLoopStart() {
-  // Force the NSApplication subclass to be used.
-  [AtomApplication sharedApplication];
-
   // Set our own application delegate.
   AtomApplicationDelegate* delegate = [[AtomApplicationDelegate alloc] init];
   [NSApp setDelegate:delegate];

+ 1 - 0
filenames.gni

@@ -112,6 +112,7 @@ filenames = {
     "atom/app/atom_content_client.h",
     "atom/app/atom_main_delegate.cc",
     "atom/app/atom_main_delegate.h",
+    "atom/app/atom_main_delegate_mac.h",
     "atom/app/atom_main_delegate_mac.mm",
     "atom/app/command_line_args.cc",
     "atom/app/command_line_args.h",