OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_APPLICATION_APPLICATION_RUNNER_H_ |
| 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_RUNNER_H_ |
| 7 |
| 8 #include "mojo/public/cpp/system/core.h" |
| 9 |
| 10 namespace mojo { |
| 11 |
| 12 class ApplicationDelegate; |
| 13 |
| 14 // A utility for running an Application. The typical use case is to use |
| 15 // when writing your MojoMain: |
| 16 // |
| 17 // extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( |
| 18 // MojoHandle shell_handle) { |
| 19 // return mojo::ApplicationRunner(new MyApplicationDelegate()) |
| 20 // .Run(shell_handle); |
| 21 // } |
| 22 // |
| 23 // ApplicationRunner takes care of mojo environment initialization and |
| 24 // shutdown, and starting a RunLoop from which your application can run and |
| 25 // ultimately Quit(). |
| 26 class ApplicationRunner { |
| 27 public: |
| 28 // Takes ownership of |delegate|. |
| 29 explicit ApplicationRunner(ApplicationDelegate* delegate); |
| 30 ~ApplicationRunner(); |
| 31 |
| 32 // Once the various parameters have been set above, use Run to initialize an |
| 33 // ApplicationImpl wired to the provided delegate, and run a RunLoop until |
| 34 // the application exits. |
| 35 MojoResult Run(MojoHandle shell_handle); |
| 36 |
| 37 private: |
| 38 ApplicationDelegate* delegate_; |
| 39 |
| 40 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationRunner); |
| 41 }; |
| 42 |
| 43 } // namespace mojo |
| 44 |
| 45 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_RUNNER_H_ |
OLD | NEW |