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