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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "base/scoped_native_library.h" | 13 #include "base/scoped_native_library.h" |
14 #include "mojo/public/platform/native/mojo_core.h" | |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 namespace shell { | 17 namespace shell { |
17 | 18 |
18 InProcessDynamicServiceRunner::InProcessDynamicServiceRunner( | 19 InProcessDynamicServiceRunner::InProcessDynamicServiceRunner( |
19 Context* /*context*/) | 20 Context* /*context*/) |
20 : thread_(this, "app_thread") { | 21 : thread_(this, "app_thread") { |
21 } | 22 } |
22 | 23 |
23 InProcessDynamicServiceRunner::~InProcessDynamicServiceRunner() { | 24 InProcessDynamicServiceRunner::~InProcessDynamicServiceRunner() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 do { | 57 do { |
57 base::NativeLibraryLoadError error; | 58 base::NativeLibraryLoadError error; |
58 base::ScopedNativeLibrary app_library( | 59 base::ScopedNativeLibrary app_library( |
59 base::LoadNativeLibrary(app_path_, &error)); | 60 base::LoadNativeLibrary(app_path_, &error)); |
60 if (!app_library.is_valid()) { | 61 if (!app_library.is_valid()) { |
61 LOG(ERROR) << "Failed to load library (error: " << error.ToString() | 62 LOG(ERROR) << "Failed to load library (error: " << error.ToString() |
62 << ")"; | 63 << ")"; |
63 break; | 64 break; |
64 } | 65 } |
65 | 66 |
67 typedef MojoResult (*SetMojoCoreFn)(MojoCore*); | |
68 SetMojoCoreFn set_mojo_core_fn = reinterpret_cast<SetMojoCoreFn>( | |
viettrungluu
2014/04/09 20:26:52
static_cast
DaveMoore
2014/04/09 22:49:08
static_casts aren't allowed on things like this:
| |
69 app_library.GetFunctionPointer("SetMojoCore")); | |
70 if (!set_mojo_core_fn) { | |
71 LOG(ERROR) << "Entrypoint SetMojoCore not found"; | |
72 break; | |
73 } | |
74 MojoCore mojo_core_impl = GetMojoCoreImpl(); | |
75 MojoResult set_result = set_mojo_core_fn(&mojo_core_impl); | |
76 if (set_result != MOJO_RESULT_OK) { | |
77 LOG(ERROR) | |
78 << "Invalid DSO. Expected MojoCore size: " | |
79 << mojo_core_impl.size; | |
80 } | |
81 | |
66 typedef MojoResult (*MojoMainFunction)(MojoHandle); | 82 typedef MojoResult (*MojoMainFunction)(MojoHandle); |
67 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( | 83 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( |
68 app_library.GetFunctionPointer("MojoMain")); | 84 app_library.GetFunctionPointer("MojoMain")); |
69 if (!main_function) { | 85 if (!main_function) { |
70 LOG(ERROR) << "Entrypoint MojoMain not found"; | 86 LOG(ERROR) << "Entrypoint MojoMain not found"; |
71 break; | 87 break; |
72 } | 88 } |
73 | 89 |
74 // |MojoMain()| takes ownership of the service handle. | 90 // |MojoMain()| takes ownership of the service handle. |
75 MojoResult result = main_function(service_handle_.release().value()); | 91 MojoResult result = main_function(service_handle_.release().value()); |
76 if (result < MOJO_RESULT_OK) | 92 if (result < MOJO_RESULT_OK) |
77 LOG(ERROR) << "MojoMain returned an error: " << result; | 93 LOG(ERROR) << "MojoMain returned an error: " << result; |
78 } while (false); | 94 } while (false); |
79 | 95 |
80 bool success = app_completed_callback_runner_.Run(); | 96 bool success = app_completed_callback_runner_.Run(); |
81 app_completed_callback_runner_.Reset(); | 97 app_completed_callback_runner_.Reset(); |
82 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; | 98 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; |
83 } | 99 } |
84 | 100 |
85 } // namespace shell | 101 } // namespace shell |
86 } // namespace mojo | 102 } // namespace mojo |
OLD | NEW |