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

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

Issue 1464313002: Move //service/android to //service/java_handler (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 1 month 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
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/android/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"
(...skipping 29 matching lines...) Expand all
45 return false; 45 return false;
46 46
47 return true; 47 return true;
48 } 48 }
49 49
50 } // namespace 50 } // namespace
51 51
52 namespace services { 52 namespace services {
53 namespace android { 53 namespace android {
54 54
55 JavaHandler::JavaHandler() : content_handler_factory_(this) { 55 JavaHandler::JavaHandler() : content_handler_factory_(this) {}
56 }
57 56
58 JavaHandler::~JavaHandler() { 57 JavaHandler::~JavaHandler() {}
59 }
60 58
61 void JavaHandler::RunApplication( 59 void JavaHandler::RunApplication(
62 mojo::InterfaceRequest<mojo::Application> application_request, 60 mojo::InterfaceRequest<mojo::Application> application_request,
63 mojo::URLResponsePtr response) { 61 mojo::URLResponsePtr response) {
64 TRACE_EVENT_BEGIN1("java_handler", "JavaHandler::RunApplication", "url", 62 TRACE_EVENT_BEGIN1("java_handler", "JavaHandler::RunApplication", "url",
65 std::string(response->url)); 63 std::string(response->url));
66 JNIEnv* env = base::android::AttachCurrentThread(); 64 JNIEnv* env = base::android::AttachCurrentThread();
67 base::FilePath archive_path; 65 base::FilePath archive_path;
68 base::FilePath cache_dir; 66 base::FilePath cache_dir;
69 { 67 {
70 base::MessageLoop loop; 68 base::MessageLoop loop;
71 handler_task_runner_->PostTask( 69 handler_task_runner_->PostTask(
72 FROM_HERE, 70 FROM_HERE,
73 base::Bind(&JavaHandler::GetApplication, base::Unretained(this), 71 base::Bind(&JavaHandler::GetApplication, base::Unretained(this),
74 base::Unretained(&archive_path), 72 base::Unretained(&archive_path),
75 base::Unretained(&cache_dir), base::Passed(response.Pass()), 73 base::Unretained(&cache_dir), base::Passed(response.Pass()),
76 base::Bind(base::IgnoreResult( 74 base::Bind(base::IgnoreResult(
77 &base::SingleThreadTaskRunner::PostTask), 75 &base::SingleThreadTaskRunner::PostTask),
78 loop.task_runner(), FROM_HERE, 76 loop.task_runner(), FROM_HERE,
79 base::MessageLoop::QuitWhenIdleClosure()))); 77 base::MessageLoop::QuitWhenIdleClosure())));
80 base::RunLoop().Run(); 78 base::RunLoop().Run();
81 } 79 }
82 80
83
84 jobject context = base::android::GetApplicationContext(); 81 jobject context = base::android::GetApplicationContext();
85 ScopedJavaLocalRef<jstring> j_archive_path = 82 ScopedJavaLocalRef<jstring> j_archive_path =
86 ConvertUTF8ToJavaString(env, archive_path.value()); 83 ConvertUTF8ToJavaString(env, archive_path.value());
87 ScopedJavaLocalRef<jstring> j_cache_dir = 84 ScopedJavaLocalRef<jstring> j_cache_dir =
88 ConvertUTF8ToJavaString(env, cache_dir.value()); 85 ConvertUTF8ToJavaString(env, cache_dir.value());
89 Java_JavaHandler_bootstrap( 86 Java_JavaHandler_bootstrap(
90 env, context, j_archive_path.obj(), j_cache_dir.obj(), 87 env, context, j_archive_path.obj(), j_cache_dir.obj(),
91 application_request.PassMessagePipe().release().value()); 88 application_request.PassMessagePipe().release().value());
92 } 89 }
93 90
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return JNI_VERSION_1_4; 151 return JNI_VERSION_1_4;
155 } 152 }
156 153
157 // This is needed because the application needs to access the application 154 // This is needed because the application needs to access the application
158 // context. 155 // context.
159 extern "C" JNI_EXPORT void InitApplicationContext( 156 extern "C" JNI_EXPORT void InitApplicationContext(
160 const base::android::JavaRef<jobject>& context) { 157 const base::android::JavaRef<jobject>& context) {
161 JNIEnv* env = base::android::AttachCurrentThread(); 158 JNIEnv* env = base::android::AttachCurrentThread();
162 base::android::InitApplicationContext(env, context); 159 base::android::InitApplicationContext(env, context);
163 } 160 }
164
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698