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

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

Issue 1067173003: Remove mojo:: part of mojo::shell:: nested namespace in //shell. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
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/native_application_support.h" 17 #include "shell/native_application_support.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 {
26 namespace shell { 25 namespace shell {
27 26
28 namespace { 27 namespace {
29 28
30 // This function loads the application library, sets the application context and 29 // This function loads the application library, sets the application context and
31 // 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
32 // 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
33 // to the helper libbootstrap.so. 32 // to the helper libbootstrap.so.
34 void RunAndroidApplication(JNIEnv* env, 33 void RunAndroidApplication(JNIEnv* env,
35 jobject j_context, 34 jobject j_context,
36 const base::FilePath& app_path, 35 const base::FilePath& app_path,
37 jint j_handle) { 36 jint j_handle) {
38 InterfaceRequest<Application> application_request = 37 mojo::InterfaceRequest<mojo::Application> application_request =
39 MakeRequest<Application>(MakeScopedHandle(MessagePipeHandle(j_handle))); 38 mojo::MakeRequest<mojo::Application>(
39 mojo::MakeScopedHandle(mojo::MessagePipeHandle(j_handle)));
40 40
41 // Load the library, so that we can set the application context there if 41 // Load the library, so that we can set the application context there if
42 // needed. 42 // needed.
43 // TODO(vtl): We'd use a ScopedNativeLibrary, but it doesn't have .get()! 43 // TODO(vtl): We'd use a ScopedNativeLibrary, but it doesn't have .get()!
44 base::NativeLibrary app_library = 44 base::NativeLibrary app_library =
45 LoadNativeApplication(app_path, NativeApplicationCleanup::DELETE); 45 LoadNativeApplication(app_path, NativeApplicationCleanup::DELETE);
46 if (!app_library) 46 if (!app_library)
47 return; 47 return;
48 48
49 // Set the application context if needed. Most applications will need to 49 // Set the application context if needed. Most applications will need to
(...skipping 21 matching lines...) Expand all
71 71
72 } // namespace 72 } // namespace
73 73
74 AndroidHandler::AndroidHandler() : content_handler_factory_(this) { 74 AndroidHandler::AndroidHandler() : content_handler_factory_(this) {
75 } 75 }
76 76
77 AndroidHandler::~AndroidHandler() { 77 AndroidHandler::~AndroidHandler() {
78 } 78 }
79 79
80 void AndroidHandler::RunApplication( 80 void AndroidHandler::RunApplication(
81 InterfaceRequest<Application> application_request, 81 mojo::InterfaceRequest<mojo::Application> application_request,
82 URLResponsePtr response) { 82 mojo::URLResponsePtr response) {
83 JNIEnv* env = AttachCurrentThread(); 83 JNIEnv* env = AttachCurrentThread();
84 ScopedJavaLocalRef<jstring> j_archive_path = 84 ScopedJavaLocalRef<jstring> j_archive_path =
85 Java_AndroidHandler_getNewTempArchivePath(env, GetApplicationContext()); 85 Java_AndroidHandler_getNewTempArchivePath(env, GetApplicationContext());
86 base::FilePath archive_path( 86 base::FilePath archive_path(
87 ConvertJavaStringToUTF8(env, j_archive_path.obj())); 87 ConvertJavaStringToUTF8(env, j_archive_path.obj()));
88 88
89 common::BlockingCopyToFile(response->body.Pass(), archive_path); 89 mojo::common::BlockingCopyToFile(response->body.Pass(), archive_path);
90 RunAndroidApplicationFn run_android_application_fn = &RunAndroidApplication; 90 RunAndroidApplicationFn run_android_application_fn = &RunAndroidApplication;
91 Java_AndroidHandler_bootstrap( 91 Java_AndroidHandler_bootstrap(
92 env, GetApplicationContext(), j_archive_path.obj(), 92 env, GetApplicationContext(), j_archive_path.obj(),
93 application_request.PassMessagePipe().release().value(), 93 application_request.PassMessagePipe().release().value(),
94 reinterpret_cast<jlong>(run_android_application_fn)); 94 reinterpret_cast<jlong>(run_android_application_fn));
95 } 95 }
96 96
97 void AndroidHandler::Initialize(ApplicationImpl* app) { 97 void AndroidHandler::Initialize(mojo::ApplicationImpl* app) {
98 } 98 }
99 99
100 bool AndroidHandler::ConfigureIncomingConnection( 100 bool AndroidHandler::ConfigureIncomingConnection(
101 ApplicationConnection* connection) { 101 mojo::ApplicationConnection* connection) {
102 connection->AddService(&content_handler_factory_); 102 connection->AddService(&content_handler_factory_);
103 connection->AddService(&intent_receiver_manager_factory_); 103 connection->AddService(&intent_receiver_manager_factory_);
104 return true; 104 return true;
105 } 105 }
106 106
107 bool RegisterAndroidHandlerJni(JNIEnv* env) { 107 bool RegisterAndroidHandlerJni(JNIEnv* env) {
108 return RegisterNativesImpl(env); 108 return RegisterNativesImpl(env);
109 } 109 }
110 110
111 } // namespace shell 111 } // namespace shell
112 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698