| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/app_container.h" | 5 #include "mojo/shell/app_container.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/native_library.h" | 11 #include "base/native_library.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "mojo/public/system/core.h" | 14 #include "mojo/public/system/core.h" |
| 15 #include "mojo/services/native_viewport/native_viewport_controller.h" |
| 15 #include "mojo/shell/context.h" | 16 #include "mojo/shell/context.h" |
| 16 | 17 |
| 17 typedef MojoResult (*MojoMainFunction)(mojo::Handle pipe); | 18 typedef MojoResult (*MojoMainFunction)(mojo::Handle pipe); |
| 18 | 19 |
| 19 namespace mojo { | 20 namespace mojo { |
| 20 namespace shell { | 21 namespace shell { |
| 21 | 22 |
| 22 void LaunchAppOnThread( | 23 void LaunchAppOnThread( |
| 23 const base::FilePath& app_path, | 24 const base::FilePath& app_path, |
| 24 Handle app_handle) { | 25 Handle app_handle) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 base::Bind(&LaunchAppOnThread, app_path, app_handle), | 83 base::Bind(&LaunchAppOnThread, app_path, app_handle), |
| 83 base::Bind(&AppContainer::AppCompleted, weak_factory_.GetWeakPtr())); | 84 base::Bind(&AppContainer::AppCompleted, weak_factory_.GetWeakPtr())); |
| 84 | 85 |
| 85 const char* hello_msg = "Hello"; | 86 const char* hello_msg = "Hello"; |
| 86 result = WriteMessage(shell_handle_, hello_msg, | 87 result = WriteMessage(shell_handle_, hello_msg, |
| 87 static_cast<uint32_t>(strlen(hello_msg)+1), | 88 static_cast<uint32_t>(strlen(hello_msg)+1), |
| 88 NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE); | 89 NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE); |
| 89 if (result < MOJO_RESULT_OK) { | 90 if (result < MOJO_RESULT_OK) { |
| 90 // Failure.. | 91 // Failure.. |
| 91 } | 92 } |
| 93 |
| 94 // TODO(beng): This should be created on demand by the NativeViewportService |
| 95 // when it is retrieved by the app. |
| 96 native_viewport_controller_.reset( |
| 97 new services::NativeViewportController(shell_handle_)); |
| 92 } | 98 } |
| 93 | 99 |
| 94 void AppContainer::AppCompleted() { | 100 void AppContainer::AppCompleted() { |
| 101 native_viewport_controller_->Close(); |
| 102 |
| 95 thread_.reset(); | 103 thread_.reset(); |
| 96 Close(shell_handle_); | 104 Close(shell_handle_); |
| 97 | |
| 98 // Probably want to do something more sophisticated here, like notify someone | |
| 99 // else to do this. | |
| 100 base::MessageLoop::current()->Quit(); | |
| 101 } | 105 } |
| 102 | 106 |
| 103 } // namespace shell | 107 } // namespace shell |
| 104 } // namespace mojo | 108 } // namespace mojo |
| OLD | NEW |