| 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 "services/shell/runner/host/native_application_support.h" | 5 #include "services/shell/runner/host/native_application_support.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "mojo/public/platform/native/system_thunks.h" | 13 #include "mojo/edk/embedder/entrypoints.h" |
| 14 #include "mojo/public/c/system/thunks.h" |
| 14 | 15 |
| 15 namespace shell { | 16 namespace shell { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 template <typename Thunks> | 20 template <typename Thunks> |
| 20 bool SetThunks(Thunks (*make_thunks)(), | 21 bool SetThunks(Thunks (*make_thunks)(), |
| 21 const char* function_name, | 22 const char* function_name, |
| 22 base::NativeLibrary library) { | 23 base::NativeLibrary library) { |
| 23 typedef size_t (*SetThunksFn)(const Thunks* thunks); | 24 typedef size_t (*SetThunksFn)(const Thunks* thunks); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 | 50 |
| 50 bool RunNativeApplication(base::NativeLibrary app_library, | 51 bool RunNativeApplication(base::NativeLibrary app_library, |
| 51 mojom::ShellClientRequest request) { | 52 mojom::ShellClientRequest request) { |
| 52 // Tolerate |app_library| being null, to make life easier for callers. | 53 // Tolerate |app_library| being null, to make life easier for callers. |
| 53 if (!app_library) | 54 if (!app_library) |
| 54 return false; | 55 return false; |
| 55 | 56 |
| 56 // Thunks aren't needed/used in component build, since the thunked methods | 57 // Thunks aren't needed/used in component build, since the thunked methods |
| 57 // just live in their own dynamically loaded library. | 58 // just live in their own dynamically loaded library. |
| 58 #if !defined(COMPONENT_BUILD) | 59 #if !defined(COMPONENT_BUILD) |
| 59 if (!SetThunks(&MojoMakeSystemThunks, "MojoSetSystemThunks", app_library)) { | 60 if (!SetThunks(&mojo::edk::MakeSystemThunks, "MojoSetSystemThunks", |
| 61 app_library)) { |
| 60 LOG(ERROR) << "MojoSetSystemThunks not found"; | 62 LOG(ERROR) << "MojoSetSystemThunks not found"; |
| 61 return false; | 63 return false; |
| 62 } | 64 } |
| 63 | 65 |
| 64 #if !defined(OS_WIN) | 66 #if !defined(OS_WIN) |
| 65 // On Windows, initializing base::CommandLine with null parameters gets the | 67 // On Windows, initializing base::CommandLine with null parameters gets the |
| 66 // process's command line from the OS. Other platforms need it to be passed | 68 // process's command line from the OS. Other platforms need it to be passed |
| 67 // in. This needs to be passed in before the app initializes the command line, | 69 // in. This needs to be passed in before the app initializes the command line, |
| 68 // which is done as soon as it loads. | 70 // which is done as soon as it loads. |
| 69 typedef void (*InitCommandLineArgs)(int, const char* const*); | 71 typedef void (*InitCommandLineArgs)(int, const char* const*); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 93 // |MojoMain()| takes ownership of the service handle. | 95 // |MojoMain()| takes ownership of the service handle. |
| 94 MojoHandle handle = request.PassMessagePipe().release().value(); | 96 MojoHandle handle = request.PassMessagePipe().release().value(); |
| 95 MojoResult result = main_function(handle); | 97 MojoResult result = main_function(handle); |
| 96 if (result != MOJO_RESULT_OK) { | 98 if (result != MOJO_RESULT_OK) { |
| 97 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; | 99 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; |
| 98 } | 100 } |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 | 103 |
| 102 } // namespace shell | 104 } // namespace shell |
| OLD | NEW |