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

Side by Side Diff: shell/android/android_handler.cc

Issue 981733002: Rename {In,OutOf}ProcessDynamicServiceRunner -> ...NativeRunner. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove incorrect/flaky NOTREACHED() Created 5 years, 9 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
« no previous file with comments | « shell/BUILD.gn ('k') | shell/android/native_viewport_application_loader.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 "shell/android/android_handler.h" 5 #include "shell/android/android_handler.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/scoped_native_library.h" 11 #include "base/scoped_native_library.h"
12 #include "jni/AndroidHandler_jni.h" 12 #include "jni/AndroidHandler_jni.h"
13 #include "mojo/common/data_pipe_utils.h" 13 #include "mojo/common/data_pipe_utils.h"
14 #include "mojo/public/c/system/main.h" 14 #include "mojo/public/c/system/main.h"
15 #include "mojo/public/cpp/application/application_impl.h" 15 #include "mojo/public/cpp/application/application_impl.h"
16 #include "shell/android/run_android_application_function.h" 16 #include "shell/android/run_android_application_function.h"
17 #include "shell/dynamic_service_runner.h" 17 #include "shell/dynamic_service_runner.h"
18 18
19 using base::android::AttachCurrentThread; 19 using base::android::AttachCurrentThread;
20 using base::android::ScopedJavaLocalRef; 20 using base::android::ScopedJavaLocalRef;
21 using base::android::ConvertJavaStringToUTF8; 21 using base::android::ConvertJavaStringToUTF8;
22 using base::android::ConvertUTF8ToJavaString; 22 using base::android::ConvertUTF8ToJavaString;
23 using base::android::GetApplicationContext; 23 using base::android::GetApplicationContext;
24 24
25 namespace mojo { 25 namespace mojo {
26 26
27 namespace { 27 namespace {
28
28 // This function loads the application library, sets the application context and 29 // This function loads the application library, sets the application context and
29 // thunks and calls into the application MojoMain. To ensure that the thunks are 30 // thunks and calls into the application MojoMain. To ensure that the thunks are
30 // set correctly we keep it in the Mojo shell .so and pass the function pointer 31 // set correctly we keep it in the Mojo shell .so and pass the function pointer
31 // to the helper libbootstrap.so. 32 // to the helper libbootstrap.so.
32 void RunAndroidApplication(JNIEnv* env, 33 void RunAndroidApplication(JNIEnv* env,
33 jobject j_context, 34 jobject j_context,
34 const base::FilePath& app_path, 35 const base::FilePath& app_path,
35 jint j_handle) { 36 jint j_handle) {
36 InterfaceRequest<Application> application_request = MakeRequest<Application>( 37 InterfaceRequest<Application> application_request =
37 MakeScopedHandle(mojo::MessagePipeHandle(j_handle))); 38 MakeRequest<Application>(MakeScopedHandle(MessagePipeHandle(j_handle)));
38 39
39 // Load the library, so that we can set the application context there if 40 // Load the library, so that we can set the application context there if
40 // needed. 41 // needed.
41 base::NativeLibraryLoadError error; 42 base::NativeLibraryLoadError error;
42 base::ScopedNativeLibrary app_library( 43 base::ScopedNativeLibrary app_library(
43 base::LoadNativeLibrary(app_path, &error)); 44 base::LoadNativeLibrary(app_path, &error));
44 if (!app_library.is_valid()) { 45 if (!app_library.is_valid()) {
45 LOG(ERROR) << "Failed to load app library (error: " << error.ToString() 46 LOG(ERROR) << "Failed to load app library (error: " << error.ToString()
46 << ")"; 47 << ")";
47 return; 48 return;
(...skipping 12 matching lines...) Expand all
60 if (init_application_context) { 61 if (init_application_context) {
61 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, j_context); 62 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, j_context);
62 init_application_context(scoped_context); 63 init_application_context(scoped_context);
63 } 64 }
64 65
65 // Run the application. 66 // Run the application.
66 base::ScopedNativeLibrary app_library_from_runner( 67 base::ScopedNativeLibrary app_library_from_runner(
67 shell::LoadAndRunNativeApplication(app_path, NativeRunner::DeleteAppPath, 68 shell::LoadAndRunNativeApplication(app_path, NativeRunner::DeleteAppPath,
68 application_request.Pass())); 69 application_request.Pass()));
69 } 70 }
71
70 } // namespace 72 } // namespace
71 73
72 AndroidHandler::AndroidHandler() : content_handler_factory_(this) { 74 AndroidHandler::AndroidHandler() : content_handler_factory_(this) {
73 } 75 }
74 76
75 AndroidHandler::~AndroidHandler() { 77 AndroidHandler::~AndroidHandler() {
76 } 78 }
77 79
78 void AndroidHandler::RunApplication( 80 void AndroidHandler::RunApplication(
79 InterfaceRequest<Application> application_request, 81 InterfaceRequest<Application> application_request,
(...skipping 19 matching lines...) Expand all
99 ApplicationConnection* connection) { 101 ApplicationConnection* connection) {
100 connection->AddService(&content_handler_factory_); 102 connection->AddService(&content_handler_factory_);
101 return true; 103 return true;
102 } 104 }
103 105
104 bool RegisterAndroidHandlerJni(JNIEnv* env) { 106 bool RegisterAndroidHandlerJni(JNIEnv* env) {
105 return RegisterNativesImpl(env); 107 return RegisterNativesImpl(env);
106 } 108 }
107 109
108 } // namespace mojo 110 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/BUILD.gn ('k') | shell/android/native_viewport_application_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698