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

Side by Side Diff: services/java_handler/java_handler.cc

Issue 1915403002: ApplicationImpl::ConnectToServiceDeprecated() -> mojo::ConnectToService() conversion, part 2. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 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
« no previous file with comments | « services/http_server/http_server_impl.cc ('k') | services/js/BUILD.gn » ('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 "services/java_handler/java_handler.h" 5 #include "services/java_handler/java_handler.h"
6 6
7 #include "base/android/base_jni_onload.h" 7 #include "base/android/base_jni_onload.h"
8 #include "base/android/base_jni_registrar.h" 8 #include "base/android/base_jni_registrar.h"
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/android/library_loader/library_loader_hooks.h" 11 #include "base/android/library_loader/library_loader_hooks.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.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/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "jni/JavaHandler_jni.h" 18 #include "jni/JavaHandler_jni.h"
19 #include "mojo/android/system/base_run_loop.h" 19 #include "mojo/android/system/base_run_loop.h"
20 #include "mojo/android/system/core_impl.h" 20 #include "mojo/android/system/core_impl.h"
21 #include "mojo/application/application_runner_chromium.h" 21 #include "mojo/application/application_runner_chromium.h"
22 #include "mojo/application/content_handler_factory.h" 22 #include "mojo/application/content_handler_factory.h"
23 #include "mojo/public/c/system/main.h" 23 #include "mojo/public/c/system/main.h"
24 #include "mojo/public/cpp/application/application_impl.h" 24 #include "mojo/public/cpp/application/application_impl.h"
25 #include "mojo/public/cpp/application/connect.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 { 33 namespace {
33 34
34 bool RegisterJNI(JNIEnv* env) { 35 bool RegisterJNI(JNIEnv* env) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ScopedJavaLocalRef<jstring> j_cache_dir = 85 ScopedJavaLocalRef<jstring> j_cache_dir =
85 ConvertUTF8ToJavaString(env, cache_dir.value()); 86 ConvertUTF8ToJavaString(env, cache_dir.value());
86 Java_JavaHandler_bootstrap( 87 Java_JavaHandler_bootstrap(
87 env, context, j_archive_path.obj(), j_cache_dir.obj(), 88 env, context, j_archive_path.obj(), j_cache_dir.obj(),
88 application_request.PassMessagePipe().release().value()); 89 application_request.PassMessagePipe().release().value());
89 } 90 }
90 91
91 void JavaHandler::Initialize(mojo::ApplicationImpl* app) { 92 void JavaHandler::Initialize(mojo::ApplicationImpl* app) {
92 tracing_.Initialize(app); 93 tracing_.Initialize(app);
93 handler_task_runner_ = base::MessageLoop::current()->task_runner(); 94 handler_task_runner_ = base::MessageLoop::current()->task_runner();
94 app->ConnectToServiceDeprecated("mojo:url_response_disk_cache", 95 mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache",
95 &url_response_disk_cache_); 96 GetProxy(&url_response_disk_cache_));
96 } 97 }
97 98
98 void JavaHandler::GetApplication(base::FilePath* archive_path, 99 void JavaHandler::GetApplication(base::FilePath* archive_path,
99 base::FilePath* cache_dir, 100 base::FilePath* cache_dir,
100 mojo::URLResponsePtr response, 101 mojo::URLResponsePtr response,
101 const base::Closure& callback) { 102 const base::Closure& callback) {
102 url_response_disk_cache_->UpdateAndGet( 103 url_response_disk_cache_->UpdateAndGet(
103 response.Pass(), 104 response.Pass(),
104 [archive_path, cache_dir, callback](mojo::Array<uint8_t> extracted_path, 105 [archive_path, cache_dir, callback](mojo::Array<uint8_t> extracted_path,
105 mojo::Array<uint8_t> cache_path) { 106 mojo::Array<uint8_t> cache_path) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return JNI_VERSION_1_4; 152 return JNI_VERSION_1_4;
152 } 153 }
153 154
154 // This is needed because the application needs to access the application 155 // This is needed because the application needs to access the application
155 // context. 156 // context.
156 extern "C" JNI_EXPORT void InitApplicationContext( 157 extern "C" JNI_EXPORT void InitApplicationContext(
157 const base::android::JavaRef<jobject>& context) { 158 const base::android::JavaRef<jobject>& context) {
158 JNIEnv* env = base::android::AttachCurrentThread(); 159 JNIEnv* env = base::android::AttachCurrentThread();
159 base::android::InitApplicationContext(env, context); 160 base::android::InitApplicationContext(env, context);
160 } 161 }
OLDNEW
« no previous file with comments | « services/http_server/http_server_impl.cc ('k') | services/js/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698