| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ |
| 6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/public/cpp/system/core.h" | 10 #include "mojo/public/cpp/system/core.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 | 13 |
| 14 class ShellClient; | 14 class ShellClient; |
| 15 class ShellConnection; |
| 15 | 16 |
| 16 // A utility for running a chromium based mojo Application. The typical use | 17 // A utility for running a chromium based mojo Application. The typical use |
| 17 // case is to use when writing your MojoMain: | 18 // case is to use when writing your MojoMain: |
| 18 // | 19 // |
| 19 // MojoResult MojoMain(MojoHandle shell_handle) { | 20 // MojoResult MojoMain(MojoHandle shell_handle) { |
| 20 // mojo::ApplicationRunner runner(new MyDelegate()); | 21 // mojo::ApplicationRunner runner(new MyDelegate()); |
| 21 // return runner.Run(shell_handle); | 22 // return runner.Run(shell_handle); |
| 22 // } | 23 // } |
| 23 // | 24 // |
| 24 // ApplicationRunner takes care of chromium environment initialization and | 25 // ApplicationRunner takes care of chromium environment initialization and |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 // the application exits. | 40 // the application exits. |
| 40 // | 41 // |
| 41 // Iff |init_base| is true, the runner will perform some initialization of | 42 // Iff |init_base| is true, the runner will perform some initialization of |
| 42 // base globals (e.g. CommandLine and AtExitManager) before starting the | 43 // base globals (e.g. CommandLine and AtExitManager) before starting the |
| 43 // application. | 44 // application. |
| 44 MojoResult Run(MojoHandle shell_handle, bool init_base); | 45 MojoResult Run(MojoHandle shell_handle, bool init_base); |
| 45 | 46 |
| 46 // Calls Run above with |init_base| set to |true|. | 47 // Calls Run above with |init_base| set to |true|. |
| 47 MojoResult Run(MojoHandle shell_handle); | 48 MojoResult Run(MojoHandle shell_handle); |
| 48 | 49 |
| 50 // Allows the caller to shut down the connection with the shell. After the |
| 51 // shell notices the pipe has closed, it will no longer track an instance of |
| 52 // this application, though this application may continue to run and service |
| 53 // requests from others. |
| 54 void DestroyShellConnection(); |
| 55 |
| 49 private: | 56 private: |
| 57 scoped_ptr<ShellConnection> connection_; |
| 50 scoped_ptr<ShellClient> client_; | 58 scoped_ptr<ShellClient> client_; |
| 51 | 59 |
| 52 // MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as | 60 // MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as |
| 53 // the underlying message pump). | 61 // the underlying message pump). |
| 54 base::MessageLoop::Type message_loop_type_; | 62 base::MessageLoop::Type message_loop_type_; |
| 55 // Whether Run() has been called. | 63 // Whether Run() has been called. |
| 56 bool has_run_; | 64 bool has_run_; |
| 57 | 65 |
| 58 DISALLOW_COPY_AND_ASSIGN(ApplicationRunner); | 66 DISALLOW_COPY_AND_ASSIGN(ApplicationRunner); |
| 59 }; | 67 }; |
| 60 | 68 |
| 61 } // namespace mojo | 69 } // namespace mojo |
| 62 | 70 |
| 63 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ | 71 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ |
| OLD | NEW |