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/runner/native_application_support.h" | 5 #include "mojo/runner/native_application_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 if (expected_size > sizeof(Thunks)) { | 40 if (expected_size > sizeof(Thunks)) { |
41 LOG(ERROR) << "Invalid app library: expected " << function_name | 41 LOG(ERROR) << "Invalid app library: expected " << function_name |
42 << " to return thunks of size: " << expected_size; | 42 << " to return thunks of size: " << expected_size; |
43 return false; | 43 return false; |
44 } | 44 } |
45 return true; | 45 return true; |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 base::NativeLibrary LoadNativeApplication( | 50 base::NativeLibrary LoadNativeApplication(const base::FilePath& app_path) { |
51 const base::FilePath& app_path, | |
52 shell::NativeApplicationCleanup cleanup) { | |
53 DVLOG(2) << "Loading Mojo app in process from library: " << app_path.value(); | 51 DVLOG(2) << "Loading Mojo app in process from library: " << app_path.value(); |
54 | 52 |
55 base::NativeLibraryLoadError error; | 53 base::NativeLibraryLoadError error; |
56 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); | 54 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); |
57 if (cleanup == shell::NativeApplicationCleanup::DELETE) | |
58 DeleteFile(app_path, false); | |
59 LOG_IF(ERROR, !app_library) | 55 LOG_IF(ERROR, !app_library) |
60 << "Failed to load app library (error: " << error.ToString() << ")"; | 56 << "Failed to load app library (error: " << error.ToString() << ")"; |
61 return app_library; | 57 return app_library; |
62 } | 58 } |
63 | 59 |
64 bool RunNativeApplication(base::NativeLibrary app_library, | 60 bool RunNativeApplication(base::NativeLibrary app_library, |
65 InterfaceRequest<Application> application_request) { | 61 InterfaceRequest<Application> application_request) { |
66 // Tolerate |app_library| being null, to make life easier for callers. | 62 // Tolerate |app_library| being null, to make life easier for callers. |
67 if (!app_library) | 63 if (!app_library) |
68 return false; | 64 return false; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 MojoHandle handle = application_request.PassMessagePipe().release().value(); | 147 MojoHandle handle = application_request.PassMessagePipe().release().value(); |
152 MojoResult result = main_function(handle); | 148 MojoResult result = main_function(handle); |
153 if (result != MOJO_RESULT_OK) { | 149 if (result != MOJO_RESULT_OK) { |
154 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; | 150 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; |
155 } | 151 } |
156 return true; | 152 return true; |
157 } | 153 } |
158 | 154 |
159 } // namespace runner | 155 } // namespace runner |
160 } // namespace mojo | 156 } // namespace mojo |
OLD | NEW |