| 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/shell/in_process_dynamic_service_runner.h" | 5 #include "mojo/shell/in_process_dynamic_service_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (mojo_set_system_thunks_fn) { | 67 if (mojo_set_system_thunks_fn) { |
| 68 MojoSystemThunks system_thunks = MojoMakeSystemThunks(); | 68 MojoSystemThunks system_thunks = MojoMakeSystemThunks(); |
| 69 size_t expected_size = mojo_set_system_thunks_fn(&system_thunks); | 69 size_t expected_size = mojo_set_system_thunks_fn(&system_thunks); |
| 70 if (expected_size > sizeof(MojoSystemThunks)) { | 70 if (expected_size > sizeof(MojoSystemThunks)) { |
| 71 LOG(ERROR) | 71 LOG(ERROR) |
| 72 << "Invalid app library: expected MojoSystemThunks size: " | 72 << "Invalid app library: expected MojoSystemThunks size: " |
| 73 << expected_size; | 73 << expected_size; |
| 74 break; | 74 break; |
| 75 } | 75 } |
| 76 } else { | 76 } else { |
| 77 // In the component build, Mojo Apps link against mojo_system_impl. |
| 78 #if !defined(COMPONENT_BUILD) |
| 77 // Strictly speaking this is not required, but it's very unusual to have | 79 // Strictly speaking this is not required, but it's very unusual to have |
| 78 // an app that doesn't require the basic system library. | 80 // an app that doesn't require the basic system library. |
| 79 LOG(WARNING) << "MojoSetSystemThunks not found in app library"; | 81 LOG(WARNING) << "MojoSetSystemThunks not found in app library"; |
| 82 #endif |
| 80 } | 83 } |
| 81 | 84 |
| 82 typedef MojoResult (*MojoMainFunction)(MojoHandle); | 85 typedef MojoResult (*MojoMainFunction)(MojoHandle); |
| 83 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( | 86 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( |
| 84 app_library.GetFunctionPointer("MojoMain")); | 87 app_library.GetFunctionPointer("MojoMain")); |
| 85 if (!main_function) { | 88 if (!main_function) { |
| 86 LOG(ERROR) << "Entrypoint MojoMain not found"; | 89 LOG(ERROR) << "Entrypoint MojoMain not found"; |
| 87 break; | 90 break; |
| 88 } | 91 } |
| 89 | 92 |
| 90 // |MojoMain()| takes ownership of the service handle. | 93 // |MojoMain()| takes ownership of the service handle. |
| 91 MojoResult result = main_function(service_handle_.release().value()); | 94 MojoResult result = main_function(service_handle_.release().value()); |
| 92 if (result < MOJO_RESULT_OK) | 95 if (result < MOJO_RESULT_OK) |
| 93 LOG(ERROR) << "MojoMain returned an error: " << result; | 96 LOG(ERROR) << "MojoMain returned an error: " << result; |
| 94 } while (false); | 97 } while (false); |
| 95 | 98 |
| 96 bool success = app_completed_callback_runner_.Run(); | 99 bool success = app_completed_callback_runner_.Run(); |
| 97 app_completed_callback_runner_.Reset(); | 100 app_completed_callback_runner_.Reset(); |
| 98 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; | 101 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; |
| 99 } | 102 } |
| 100 | 103 |
| 101 } // namespace shell | 104 } // namespace shell |
| 102 } // namespace mojo | 105 } // namespace mojo |
| OLD | NEW |