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

Unified Diff: mojo/public/cpp/application/application_runner_chromium.h

Issue 441853002: mojo: first take on removing mojo_main_{chromium,standalone}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rev Created 6 years, 4 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/application_runner_chromium.h
diff --git a/mojo/public/cpp/application/application_runner_chromium.h b/mojo/public/cpp/application/application_runner_chromium.h
new file mode 100644
index 0000000000000000000000000000000000000000..14f2c9d58ad06670ef9665c25a2476251f347fa0
--- /dev/null
+++ b/mojo/public/cpp/application/application_runner_chromium.h
@@ -0,0 +1,56 @@
+// Copyright 2014 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 MOJO_PUBLIC_APPLICATION_APPLICATION_RUNNER_CHROMIUM_H_
+#define MOJO_PUBLIC_APPLICATION_APPLICATION_RUNNER_CHROMIUM_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "mojo/public/cpp/system/core.h"
+
+namespace mojo {
+
+class ApplicationDelegate;
+
+// A utility for running a chromium based mojo Application. The typical use
+// case is to use when writing your MojoMain:
+//
+// extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(
+// MojoHandle shell_handle) {
+// return mojo::ApplicationRunnerChromium(
+// make_scoped_delegate(new MyDelegate())).Run(shell_handle);
+// }
+//
+// ApplicationRunnerChromium takes care of chromium environment initialization
+// and shutdown, and starting a RunLoop from which your application can run and
+// ultimately Quit().
+class ApplicationRunnerChromium {
+ public:
+ explicit ApplicationRunnerChromium(scoped_ptr<ApplicationDelegate> delegate);
+ ~ApplicationRunnerChromium();
+
+ void set_loop_type(base::MessageLoop::Type type);
+
+ // Once the various parameters have been set above, use Run to initialize an
+ // ApplicationImpl wired to the provided delegate, and run a RunLoop until
+ // the application exits.
+ MojoResult Run(MojoHandle shell_handle);
+
+ private:
+ scoped_ptr<ApplicationDelegate> delegate_;
+
+ // MessageLoop type. TYPE_DEFAULT is default.
+ base::MessageLoop::Type loop_type_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationRunnerChromium);
+};
+
+template <typename T>
+scoped_ptr<ApplicationDelegate> make_scoped_delegate(T* delegate) {
+ return scoped_ptr<ApplicationDelegate>(delegate);
+}
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_APPLICATION_APPLICATION_RUNNER_CHROMIUM_H_

Powered by Google App Engine
This is Rietveld 408576698