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 #include "mojo/public/cpp/application/application_runner.h" | |
6 | |
7 #include "mojo/public/cpp/application/application_delegate.h" | |
8 #include "mojo/public/cpp/application/application_impl.h" | |
9 #include "mojo/public/cpp/environment/environment.h" | |
10 #include "mojo/public/cpp/utility/run_loop.h" | |
11 | |
12 namespace mojo { | |
13 | |
14 // static | |
15 void ApplicationImpl::Terminate() { | |
16 RunLoop::current()->Quit(); | |
17 } | |
18 | |
19 ApplicationRunner::ApplicationRunner(ApplicationDelegate* delegate) | |
20 : delegate_(delegate) { | |
21 } | |
22 ApplicationRunner::~ApplicationRunner() { | |
23 assert(!delegate_); | |
24 } | |
25 | |
26 MojoResult ApplicationRunner::Run(MojoHandle shell_handle) { | |
27 Environment env; | |
28 { | |
29 RunLoop loop; | |
30 ApplicationImpl app(delegate_, shell_handle); | |
31 loop.Run(); | |
32 } | |
33 | |
34 delete delegate_; | |
35 delegate_ = nullptr; | |
36 return MOJO_RESULT_OK; | |
37 } | |
38 | |
39 } // namespace mojo | |
OLD | NEW |