| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 void InProcessDynamicServiceRunner::Run() { | 49 void InProcessDynamicServiceRunner::Run() { |
| 50 DVLOG(2) << "Loading/running Mojo app from " << app_path_.value() | 50 DVLOG(2) << "Loading/running Mojo app from " << app_path_.value() |
| 51 << " in process"; | 51 << " in process"; |
| 52 | 52 |
| 53 base::ScopedClosureRunner app_deleter( | 53 base::ScopedClosureRunner app_deleter( |
| 54 base::Bind(base::IgnoreResult(&base::DeleteFile), app_path_, false)); | 54 base::Bind(base::IgnoreResult(&base::DeleteFile), app_path_, false)); |
| 55 | 55 |
| 56 do { | 56 do { |
| 57 std::string load_error; | 57 base::NativeLibraryLoadError error; |
| 58 base::ScopedNativeLibrary app_library( | 58 base::ScopedNativeLibrary app_library( |
| 59 base::LoadNativeLibrary(app_path_, &load_error)); | 59 base::LoadNativeLibrary(app_path_, &error)); |
| 60 if (!app_library.is_valid()) { | 60 if (!app_library.is_valid()) { |
| 61 LOG(ERROR) << "Failed to load library (error: " << load_error << ")"; | 61 LOG(ERROR) << "Failed to load library (error: " << error << ")"; |
| 62 break; | 62 break; |
| 63 } | 63 } |
| 64 | 64 |
| 65 typedef MojoResult (*MojoMainFunction)(MojoHandle); | 65 typedef MojoResult (*MojoMainFunction)(MojoHandle); |
| 66 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( | 66 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( |
| 67 app_library.GetFunctionPointer("MojoMain")); | 67 app_library.GetFunctionPointer("MojoMain")); |
| 68 if (!main_function) { | 68 if (!main_function) { |
| 69 LOG(ERROR) << "Entrypoint MojoMain not found"; | 69 LOG(ERROR) << "Entrypoint MojoMain not found"; |
| 70 break; | 70 break; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // |MojoMain()| takes ownership of the service handle. | 73 // |MojoMain()| takes ownership of the service handle. |
| 74 MojoResult result = main_function(service_handle_.release().value()); | 74 MojoResult result = main_function(service_handle_.release().value()); |
| 75 if (result < MOJO_RESULT_OK) | 75 if (result < MOJO_RESULT_OK) |
| 76 LOG(ERROR) << "MojoMain returned an error: " << result; | 76 LOG(ERROR) << "MojoMain returned an error: " << result; |
| 77 } while (false); | 77 } while (false); |
| 78 | 78 |
| 79 bool success = app_completed_callback_runner_.Run(); | 79 bool success = app_completed_callback_runner_.Run(); |
| 80 app_completed_callback_runner_.Reset(); | 80 app_completed_callback_runner_.Reset(); |
| 81 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; | 81 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace shell | 84 } // namespace shell |
| 85 } // namespace mojo | 85 } // namespace mojo |
| OLD | NEW |