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

Unified Diff: content/common/mojo/embedded_application_runner.h

Issue 1871223003: Use ShellClientFactory interface to load mojo:profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months 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
« no previous file with comments | « content/common/mojo/current_thread_loader.cc ('k') | content/common/mojo/embedded_application_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/embedded_application_runner.h
diff --git a/content/common/mojo/embedded_application_runner.h b/content/common/mojo/embedded_application_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..8c5aa8552be9e139f4b020cb4f2438489f6f6e19
--- /dev/null
+++ b/content/common/mojo/embedded_application_runner.h
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_MOJO_EMBEDDED_APPLICATION_RUNNER_H_
+#define CONTENT_COMMON_MOJO_EMBEDDED_APPLICATION_RUNNER_H_
+
+#include <memory>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "services/shell/public/cpp/shell_client.h"
+#include "services/shell/public/interfaces/shell_client.mojom.h"
+
+namespace content {
+
+// Hosts an in-process application instance that supports multiple ShellClient
+// connections. The first incoming connection will invoke a provided factory
+// function to instantiate the application, and the application will
+// automatically be torn down when its last connection is lost. The application
+// may be launched and torn down multiple times by a single
+// EmbeddedApplicationRunner instance.
+class EmbeddedApplicationRunner {
+ public:
+ using FactoryCallback =
+ base::Callback<std::unique_ptr<mojo::ShellClient>()>;
+
+ // Constructs a runner which hosts the application on |task_runner|'s thread.
+ // If an existing instance of the app is not running when an incoming
+ // connection is made, |callback| will be run on |task_runner|'s thread to
+ // create a new instance which will live on that thread.
+ EmbeddedApplicationRunner(
+ const FactoryCallback& callback,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
+
+ ~EmbeddedApplicationRunner();
+
+ // Binds an incoming ShellClientRequest for this application. If the
+ // application isn't already running, it's started. Otherwise the request is
+ // bound to the running instance.
+ void BindShellClientRequest(mojo::shell::mojom::ShellClientRequest request);
+
+ private:
+ class Instance;
+
+ // The TaskRunner on which the factory callback will be run. The
+ // mojo::ShellClient it returns will live and die on this TaskRunner's thread.
+ const scoped_refptr<base::SingleThreadTaskRunner> application_task_runner_;
+
+ // A reference to the application instance which may operate on the
+ // |application_task_runner_|'s thread.
+ scoped_refptr<Instance> instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(EmbeddedApplicationRunner);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_MOJO_EMBEDDED_APPLICATION_RUNNER_H_
« no previous file with comments | « content/common/mojo/current_thread_loader.cc ('k') | content/common/mojo/embedded_application_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698