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 "shell/native_application_support.h" | 5 #include "shell/native_application_support.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" | 10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" |
(...skipping 24 matching lines...) Expand all Loading... |
35 if (expected_size > sizeof(Thunks)) { | 35 if (expected_size > sizeof(Thunks)) { |
36 LOG(ERROR) << "Invalid app library: expected " << function_name | 36 LOG(ERROR) << "Invalid app library: expected " << function_name |
37 << " to return thunks of size: " << expected_size; | 37 << " to return thunks of size: " << expected_size; |
38 return false; | 38 return false; |
39 } | 39 } |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 base::NativeLibrary LoadNativeApplication(const base::FilePath& app_path, | 45 base::NativeLibrary LoadNativeApplication(const base::FilePath& app_path) { |
46 NativeApplicationCleanup cleanup) { | |
47 DVLOG(2) << "Loading Mojo app in process from library: " << app_path.value(); | 46 DVLOG(2) << "Loading Mojo app in process from library: " << app_path.value(); |
48 | 47 |
49 base::NativeLibraryLoadError error; | 48 base::NativeLibraryLoadError error; |
50 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); | 49 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); |
51 if (cleanup == NativeApplicationCleanup::DELETE) | |
52 DeleteFile(app_path, false); | |
53 LOG_IF(ERROR, !app_library) | 50 LOG_IF(ERROR, !app_library) |
54 << "Failed to load app library (error: " << error.ToString() << ")"; | 51 << "Failed to load app library (error: " << error.ToString() << ")"; |
55 return app_library; | 52 return app_library; |
56 } | 53 } |
57 | 54 |
58 bool RunNativeApplication( | 55 bool RunNativeApplication( |
59 base::NativeLibrary app_library, | 56 base::NativeLibrary app_library, |
60 mojo::InterfaceRequest<mojo::Application> application_request) { | 57 mojo::InterfaceRequest<mojo::Application> application_request) { |
61 // Tolerate |app_library| being null, to make life easier for callers. | 58 // Tolerate |app_library| being null, to make life easier for callers. |
62 if (!app_library) | 59 if (!app_library) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 117 } |
121 // |MojoMain()| takes ownership of the Application request handle. | 118 // |MojoMain()| takes ownership of the Application request handle. |
122 MojoHandle handle = application_request.PassMessagePipe().release().value(); | 119 MojoHandle handle = application_request.PassMessagePipe().release().value(); |
123 MojoResult result = main_function(handle); | 120 MojoResult result = main_function(handle); |
124 LOG_IF(ERROR, result != MOJO_RESULT_OK) | 121 LOG_IF(ERROR, result != MOJO_RESULT_OK) |
125 << "MojoMain returned error (result: " << result << ")"; | 122 << "MojoMain returned error (result: " << result << ")"; |
126 return true; | 123 return true; |
127 } | 124 } |
128 | 125 |
129 } // namespace shell | 126 } // namespace shell |
OLD | NEW |