Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: mojo/shell/in_process_dynamic_service_runner.cc

Issue 231353002: Make mojo_system static and mojo_system_impl a component, never use both (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the mac loader path dependencies Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/public/system/core_private.cc ('k') | mojo/system/core.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system_thunks.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
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 MojoSetSystemThunksFn mojo_set_system_thunks_fn =
68 reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer(
69 "MojoSetSystemThunks"));
70 if (mojo_set_system_thunks_fn) {
71 MojoSystemThunks system_thunks = MojoMakeSystemThunks();
72 size_t expected_size = mojo_set_system_thunks_fn(&system_thunks);
73 if (expected_size > sizeof(MojoSystemThunks)) {
74 LOG(ERROR)
75 << "Invalid DSO. Expected MojoSystemThunks size: "
76 << expected_size;
77 break;
78 }
79 }
80
66 typedef MojoResult (*MojoMainFunction)(MojoHandle); 81 typedef MojoResult (*MojoMainFunction)(MojoHandle);
67 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( 82 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>(
68 app_library.GetFunctionPointer("MojoMain")); 83 app_library.GetFunctionPointer("MojoMain"));
69 if (!main_function) { 84 if (!main_function) {
70 LOG(ERROR) << "Entrypoint MojoMain not found"; 85 LOG(ERROR) << "Entrypoint MojoMain not found";
71 break; 86 break;
72 } 87 }
73 88
74 // |MojoMain()| takes ownership of the service handle. 89 // |MojoMain()| takes ownership of the service handle.
75 MojoResult result = main_function(service_handle_.release().value()); 90 MojoResult result = main_function(service_handle_.release().value());
76 if (result < MOJO_RESULT_OK) 91 if (result < MOJO_RESULT_OK)
77 LOG(ERROR) << "MojoMain returned an error: " << result; 92 LOG(ERROR) << "MojoMain returned an error: " << result;
78 } while (false); 93 } while (false);
79 94
80 bool success = app_completed_callback_runner_.Run(); 95 bool success = app_completed_callback_runner_.Run();
81 app_completed_callback_runner_.Reset(); 96 app_completed_callback_runner_.Reset();
82 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback"; 97 LOG_IF(ERROR, !success) << "Failed post run app_completed_callback";
83 } 98 }
84 99
85 } // namespace shell 100 } // namespace shell
86 } // namespace mojo 101 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/system/core_private.cc ('k') | mojo/system/core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698