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

Side by Side Diff: mojo/public/cpp/application/run_application.h

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_RUN_APPLICATION_H_
6 #define MOJO_PUBLIC_CPP_APPLICATION_RUN_APPLICATION_H_
7
8 #include <mojo/result.h>
9 #include <mojo/system/handle.h>
10
11 namespace mojo {
12
13 class ApplicationImplBase;
14
15 // Base class for options to |RunApplication()|. An implementation of these
16 // functions may (but need not, in which case no options are available)
17 // separately provide an implementation subclass, which would be specific to
18 // that implementation. (The "standalone" implementation has no options.)
19 class RunApplicationOptions {
20 protected:
21 RunApplicationOptions() {}
22 ~RunApplicationOptions() {}
23 };
24
25 // |RunApplication()| sets up a message (run) loop and runs the provided
26 // application implementation. The return value will be the one provided to
27 // |TerminateApplication()|.
28 //
29 // Typical use (where |MyApplicationImpl| is an implementation of
30 // |ApplicationImplBase|):
31 //
32 // MojoResult MojoMain(MojoHandle application_request_handle) {
33 // MyApplicationImpl my_app;
34 // return mojo::RunApplication(application_request_handle, &my_app);
35 // }
36 //
37 // Note that |RunApplication()| may also be used on secondary threads (that are
38 // not already running a message loop of some sort).
39 //
40 // |*application_impl| must remain alive until the message loop starts running
41 // (thus it may own itself). If |options| is non-null, then it must point to an
42 // instance of an implementation-specific subclass of |RunApplicationOptions|;
43 // |*options| must remain alive for the duration of the call.
44 MojoResult RunApplication(MojoHandle application_request_handle,
45 ApplicationImplBase* application_impl,
46 const RunApplicationOptions* options = nullptr);
47
48 // |TerminateApplication()| terminates the application that is running on the
49 // current thread. It may only be called from "inside" |RunApplication()| (i.e.,
50 // with |RunApplication()| on the stack, which means that the message loop is
51 // running). It causes |RunApplication()| to return "soon" (assuming the message
52 // loop is not blocked processing some task), with return value |result|. It may
53 // cause queued work to *not* be executed. It should be executed at most once
54 // (per |RunApplication()|).
55 void TerminateApplication(MojoResult result);
56
57 } // namespace mojo
58
59 #endif // MOJO_PUBLIC_CPP_APPLICATION_RUN_APPLICATION_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lib/service_provider_impl.cc ('k') | mojo/public/cpp/application/service_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698