| Index: mojo/shell/in_process_dynamic_service_runner.cc
|
| diff --git a/mojo/shell/in_process_dynamic_service_runner.cc b/mojo/shell/in_process_dynamic_service_runner.cc
|
| index cc03a3b85b030b66492b5f0d556139746c3be3da..02cba0fd3d82ba74188ed60305c5d18fabeedf04 100644
|
| --- a/mojo/shell/in_process_dynamic_service_runner.cc
|
| +++ b/mojo/shell/in_process_dynamic_service_runner.cc
|
| @@ -7,41 +7,13 @@
|
| #include "base/bind.h"
|
| #include "base/callback_helpers.h"
|
| #include "base/location.h"
|
| -#include "base/logging.h"
|
| #include "base/message_loop/message_loop_proxy.h"
|
| -#include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h"
|
| -#include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h"
|
| -#include "mojo/public/platform/native/gles2_impl_thunks.h"
|
| -#include "mojo/public/platform/native/gles2_thunks.h"
|
| -#include "mojo/public/platform/native/system_thunks.h"
|
|
|
| namespace mojo {
|
| namespace shell {
|
|
|
| -namespace {
|
| -
|
| -template <typename Thunks>
|
| -bool SetThunks(Thunks (*make_thunks)(),
|
| - const char* function_name,
|
| - base::ScopedNativeLibrary* library) {
|
| - typedef size_t (*SetThunksFn)(const Thunks* thunks);
|
| - SetThunksFn set_thunks =
|
| - reinterpret_cast<SetThunksFn>(library->GetFunctionPointer(function_name));
|
| - if (!set_thunks)
|
| - return false;
|
| - Thunks thunks = make_thunks();
|
| - size_t expected_size = set_thunks(&thunks);
|
| - if (expected_size > sizeof(Thunks)) {
|
| - LOG(ERROR) << "Invalid app library: expected " << function_name
|
| - << " to return thunks of size: " << expected_size;
|
| - return false;
|
| - }
|
| - return true;
|
| -}
|
| -}
|
| -
|
| InProcessDynamicServiceRunner::InProcessDynamicServiceRunner(
|
| - Context* context) {
|
| + Context* context) : app_library_(nullptr) {
|
| }
|
|
|
| InProcessDynamicServiceRunner::~InProcessDynamicServiceRunner() {
|
| @@ -54,7 +26,8 @@ InProcessDynamicServiceRunner::~InProcessDynamicServiceRunner() {
|
| // It is important to let the thread exit before unloading the DSO because
|
| // the library may have registered thread-local data and destructors to run
|
| // on thread termination.
|
| - app_library_.Reset(base::NativeLibrary());
|
| + if (app_library_)
|
| + base::UnloadNativeLibrary(app_library_);
|
| }
|
|
|
| void InProcessDynamicServiceRunner::Start(
|
| @@ -81,78 +54,7 @@ void InProcessDynamicServiceRunner::Run() {
|
| DVLOG(2) << "Loading/running Mojo app in process from library: "
|
| << app_path_.value();
|
|
|
| - do {
|
| - base::NativeLibraryLoadError error;
|
| - app_library_.Reset(base::LoadNativeLibrary(app_path_, &error));
|
| - if (!app_library_.is_valid()) {
|
| - LOG(ERROR) << "Failed to load app library (error: " << error.ToString()
|
| - << ")";
|
| - break;
|
| - }
|
| - // Go shared library support requires us to initialize the runtime before we
|
| - // start running any go code. This is a temporary patch.
|
| - typedef void (*InitGoRuntimeFn)();
|
| - InitGoRuntimeFn runtime = reinterpret_cast<InitGoRuntimeFn>(
|
| - app_library_.GetFunctionPointer("InitGoRuntime"));
|
| - if (runtime) {
|
| - DVLOG(2) << "InitGoRuntime: Initializing Go Runtime found in app";
|
| - runtime();
|
| - }
|
| - if (!SetThunks(
|
| - &MojoMakeSystemThunks, "MojoSetSystemThunks", &app_library_)) {
|
| - // In the component build, Mojo Apps link against mojo_system_impl.
|
| -#if !defined(COMPONENT_BUILD)
|
| - // Strictly speaking this is not required, but it's very unusual to have
|
| - // an app that doesn't require the basic system library.
|
| - LOG(WARNING) << "MojoSetSystemThunks not found in app library";
|
| -#endif
|
| - }
|
| -
|
| - if (SetThunks(&MojoMakeGLES2ControlThunks,
|
| - "MojoSetGLES2ControlThunks",
|
| - &app_library_)) {
|
| - // If we have the control thunks, we probably also have the
|
| - // GLES2 implementation thunks.
|
| - if (!SetThunks(&MojoMakeGLES2ImplThunks,
|
| - "MojoSetGLES2ImplThunks",
|
| - &app_library_)) {
|
| - // In the component build, Mojo Apps link against mojo_gles2_impl.
|
| -#if !defined(COMPONENT_BUILD)
|
| - // Warn on this really weird case: The library requires the GLES2
|
| - // control functions, but doesn't require the GLES2 implementation.
|
| - LOG(WARNING) << app_path_.value()
|
| - << " has MojoSetGLES2ControlThunks, "
|
| - "but doesn't have MojoSetGLES2ImplThunks.";
|
| -#endif
|
| - }
|
| -
|
| - // If the application is using GLES2 extension points, register those
|
| - // thunks. Applications may use or not use any of these, so don't warn if
|
| - // they are missing.
|
| - SetThunks(MojoMakeGLES2ImplChromiumTextureMailboxThunks,
|
| - "MojoSetGLES2ImplChromiumTextureMailboxThunks",
|
| - &app_library_);
|
| - SetThunks(MojoMakeGLES2ImplChromiumSyncPointThunks,
|
| - "MojoSetGLES2ImplChromiumSyncPointThunks",
|
| - &app_library_);
|
| - }
|
| - // Unlike system thunks, we don't warn on a lack of GLES2 thunks because
|
| - // not everything is a visual app.
|
| -
|
| - typedef MojoResult (*MojoMainFunction)(MojoHandle);
|
| - MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>(
|
| - app_library_.GetFunctionPointer("MojoMain"));
|
| - if (!main_function) {
|
| - LOG(ERROR) << "Entrypoint MojoMain not found: " << app_path_.value();
|
| - break;
|
| - }
|
| -
|
| - // |MojoMain()| takes ownership of the service handle.
|
| - MojoResult result = main_function(service_handle_.release().value());
|
| - if (result < MOJO_RESULT_OK)
|
| - LOG(ERROR) << "MojoMain returned an error: " << result;
|
| - } while (false);
|
| -
|
| + app_library_ = LoadAndRunService(app_path_, service_handle_.Pass());
|
| app_completed_callback_runner_.Run();
|
| app_completed_callback_runner_.Reset();
|
| }
|
|
|