| 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/android/android_handler.h" | 5 #include "shell/android/android_handler.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/scoped_native_library.h" | 16 #include "base/scoped_native_library.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "jni/AndroidHandler_jni.h" | 19 #include "jni/AndroidHandler_jni.h" |
| 20 #include "mojo/data_pipe_utils/data_pipe_utils.h" | 20 #include "mojo/data_pipe_utils/data_pipe_utils.h" |
| 21 #include "mojo/public/c/system/main.h" | 21 #include "mojo/public/c/system/main.h" |
| 22 #include "mojo/public/cpp/application/application_impl.h" | 22 #include "mojo/public/cpp/application/application_impl.h" |
| 23 #include "mojo/public/cpp/application/connect.h" |
| 23 #include "shell/android/run_android_application_function.h" | 24 #include "shell/android/run_android_application_function.h" |
| 24 #include "shell/native_application_support.h" | 25 #include "shell/native_application_support.h" |
| 25 | 26 |
| 26 using base::android::AttachCurrentThread; | 27 using base::android::AttachCurrentThread; |
| 27 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
| 28 using base::android::ConvertJavaStringToUTF8; | 29 using base::android::ConvertJavaStringToUTF8; |
| 29 using base::android::ConvertUTF8ToJavaString; | 30 using base::android::ConvertUTF8ToJavaString; |
| 30 using base::android::GetApplicationContext; | 31 using base::android::GetApplicationContext; |
| 31 | 32 |
| 32 namespace shell { | 33 namespace shell { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 RunAndroidApplicationFn run_android_application_fn = &RunAndroidApplication; | 119 RunAndroidApplicationFn run_android_application_fn = &RunAndroidApplication; |
| 119 Java_AndroidHandler_bootstrap( | 120 Java_AndroidHandler_bootstrap( |
| 120 env, GetApplicationContext(), tracing_id, j_extracted_dir.obj(), | 121 env, GetApplicationContext(), tracing_id, j_extracted_dir.obj(), |
| 121 j_cache_dir.obj(), | 122 j_cache_dir.obj(), |
| 122 application_request.PassMessagePipe().release().value(), | 123 application_request.PassMessagePipe().release().value(), |
| 123 reinterpret_cast<jlong>(run_android_application_fn)); | 124 reinterpret_cast<jlong>(run_android_application_fn)); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void AndroidHandler::Initialize(mojo::ApplicationImpl* app) { | 127 void AndroidHandler::Initialize(mojo::ApplicationImpl* app) { |
| 127 handler_task_runner_ = base::MessageLoop::current()->task_runner(); | 128 handler_task_runner_ = base::MessageLoop::current()->task_runner(); |
| 128 app->ConnectToServiceDeprecated("mojo:url_response_disk_cache", | 129 mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache", |
| 129 &url_response_disk_cache_); | 130 GetProxy(&url_response_disk_cache_)); |
| 130 } | 131 } |
| 131 | 132 |
| 132 bool AndroidHandler::ConfigureIncomingConnection( | 133 bool AndroidHandler::ConfigureIncomingConnection( |
| 133 mojo::ApplicationConnection* connection) { | 134 mojo::ApplicationConnection* connection) { |
| 134 connection->AddService(&content_handler_factory_); | 135 connection->AddService(&content_handler_factory_); |
| 135 return true; | 136 return true; |
| 136 } | 137 } |
| 137 | 138 |
| 138 void AndroidHandler::ExtractApplication(base::FilePath* extracted_dir, | 139 void AndroidHandler::ExtractApplication(base::FilePath* extracted_dir, |
| 139 base::FilePath* cache_dir, | 140 base::FilePath* cache_dir, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return ConvertUTF8ToJavaString(env, temporary_file.value()).Release(); | 178 return ConvertUTF8ToJavaString(env, temporary_file.value()).Release(); |
| 178 } | 179 } |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 | 182 |
| 182 bool RegisterAndroidHandlerJni(JNIEnv* env) { | 183 bool RegisterAndroidHandlerJni(JNIEnv* env) { |
| 183 return RegisterNativesImpl(env); | 184 return RegisterNativesImpl(env); |
| 184 } | 185 } |
| 185 | 186 |
| 186 } // namespace shell | 187 } // namespace shell |
| OLD | NEW |