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

Unified Diff: mojo/public/cpp/application/lib/run_application.cc

Issue 2004493002: Add a mojo::RunApplication() for running implementations of ApplicationImplBase. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_environment_no_instantiate
Patch Set: rebased Created 4 years, 7 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
Index: mojo/public/cpp/application/lib/run_application.cc
diff --git a/mojo/public/cpp/application/lib/run_application.cc b/mojo/public/cpp/application/lib/run_application.cc
new file mode 100644
index 0000000000000000000000000000000000000000..82d3089fef359221aa17680e909d2c8587ee45f7
--- /dev/null
+++ b/mojo/public/cpp/application/lib/run_application.cc
@@ -0,0 +1,32 @@
+// 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.
+
+#include "mojo/public/cpp/application/run_application.h"
+
+#include "mojo/public/cpp/application/application_impl_base.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+#include "mojo/public/cpp/utility/run_loop.h"
+#include "mojo/public/interfaces/application/application.mojom.h"
+
+namespace mojo {
+
+void RunApplication(MojoHandle application_request_handle,
+ ApplicationImplBase* application_impl) {
+ // TODO(vtl): Possibly we should have an assertion that we're not running, but
+ // that requires TLS.
+
+ RunLoop loop;
+ application_impl->Bind(InterfaceRequest<Application>(
+ MakeScopedHandle(MessagePipeHandle(application_request_handle))));
+ loop.Run();
+
+ // TODO(vtl): Should we unbind stuff here? (Should there be "will start"/"did
+ // stop" notifications to the |ApplicationImplBase|?)
+}
+
+void TerminateApplication() {
+ RunLoop::current()->Quit();
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/public/cpp/application/lib/application_impl_base.cc ('k') | mojo/public/cpp/application/run_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698