Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2900)

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 1423063004: Allow Chrome to bind an Application request from mojo_runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callback
Patch Set: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 372d0ee473b064461c7dffada6a2ed778f297df8..8d8a4ce9351b11a5297ae825ad2b743b82667ddd 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -63,6 +63,7 @@
#include "chrome/browser/memory/tab_manager.h"
#include "chrome/browser/metrics/field_trial_synchronizer.h"
#include "chrome/browser/metrics/thread_watcher.h"
+#include "chrome/browser/mojo_runner_util.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/net/crl_set_fetcher.h"
#include "chrome/browser/performance_monitor/performance_monitor.h"
@@ -247,6 +248,12 @@
#include "components/webusb/webusb_detector.h"
#endif
+#if defined(MOJO_RUNNER_CLIENT)
+#include "mojo/application/public/cpp/application_delegate.h"
+#include "mojo/application/public/cpp/application_impl.h"
+#include "mojo/runner/child/runner_connection.h"
+#endif
+
using content::BrowserThread;
namespace {
@@ -571,6 +578,32 @@ const char kMissingLocaleDataMessage[] =
} // namespace chrome_browser
+#if defined(MOJO_RUNNER_CLIENT)
+class ChromeApplicationDelegate : public mojo::ApplicationDelegate {
+ public:
+ ChromeApplicationDelegate() {}
+ ~ChromeApplicationDelegate() override {}
+
+ // Runs the current thread's message loop until we receive an Initialize()
+ // call from the shell.
+ void RunUntilInitialize() {
+ base::MessageLoop::current()->Run();
sky 2015/11/05 00:29:34 You sure you want to run a nested message loop her
+ }
+
+ private:
+ void Initialize(mojo::ApplicationImpl* application) override {
+ // TODO(beng): Connect to the window manager.
+ base::MessageLoop::current()->QuitNow();
+ }
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override {
+ return false;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeApplicationDelegate);
+};
+#endif // defined(MOJO_RUNNER_CLIENT)
+
// BrowserMainParts ------------------------------------------------------------
ChromeBrowserMainParts::ChromeBrowserMainParts(
@@ -1212,6 +1245,21 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime");
const base::TimeTicks start_time_step1 = base::TimeTicks::Now();
+#if defined(MOJO_RUNNER_CLIENT)
+ if (chrome::IsRunningInMojoRunner()) {
+ // When run from the Mojo Runner, block until we can bind an Application
+ // request from the runner's shell, and run the main message loop until
+ // our bound ApplicationImpl is ready to use.
+ mojo::InterfaceRequest<mojo::Application> application_request;
+ runner_connection_.reset(
+ mojo::runner::RunnerConnection::ConnectToRunner(&application_request));
+ application_delegate_.reset(new ChromeApplicationDelegate);
+ application_impl_.reset(new mojo::ApplicationImpl(
+ application_delegate_.get(), application_request.Pass()));
+ application_delegate_->RunUntilInitialize();
+ }
+#endif // defined(MOJO_RUNNER_CLIENT)
+
#if defined(OS_WIN)
// Windows parental controls calls can be slow, so we do an early init here
// that calculates this value off of the UI thread.

Powered by Google App Engine
This is Rietveld 408576698