| 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" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 // Run the application. | 77 // Run the application. |
| 78 RunNativeApplication(app_library, application_request.Pass()); | 78 RunNativeApplication(app_library, application_request.Pass()); |
| 79 // TODO(vtl): See note about unloading and thread-local destructors above | 79 // TODO(vtl): See note about unloading and thread-local destructors above |
| 80 // declaration of |LoadNativeApplication()|. | 80 // declaration of |LoadNativeApplication()|. |
| 81 base::UnloadNativeLibrary(app_library); | 81 base::UnloadNativeLibrary(app_library); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 AndroidHandler::AndroidHandler() : content_handler_factory_(this) { | 86 AndroidHandler::AndroidHandler() {} |
| 87 } | |
| 88 | 87 |
| 89 AndroidHandler::~AndroidHandler() { | 88 AndroidHandler::~AndroidHandler() {} |
| 90 } | |
| 91 | 89 |
| 92 void AndroidHandler::RunApplication( | 90 void AndroidHandler::RunApplication( |
| 93 mojo::InterfaceRequest<mojo::Application> application_request, | 91 mojo::InterfaceRequest<mojo::Application> application_request, |
| 94 mojo::URLResponsePtr response) { | 92 mojo::URLResponsePtr response) { |
| 95 JNIEnv* env = AttachCurrentThread(); | 93 JNIEnv* env = AttachCurrentThread(); |
| 96 uintptr_t tracing_id = reinterpret_cast<uintptr_t>(this); | 94 uintptr_t tracing_id = reinterpret_cast<uintptr_t>(this); |
| 97 TRACE_EVENT_ASYNC_BEGIN1("android_handler", "AndroidHandler::RunApplication", | 95 TRACE_EVENT_ASYNC_BEGIN1("android_handler", "AndroidHandler::RunApplication", |
| 98 tracing_id, "url", std::string(response->url)); | 96 tracing_id, "url", std::string(response->url)); |
| 99 base::FilePath extracted_dir; | 97 base::FilePath extracted_dir; |
| 100 base::FilePath cache_dir; | 98 base::FilePath cache_dir; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 126 | 124 |
| 127 void AndroidHandler::Initialize(mojo::ApplicationImpl* app) { | 125 void AndroidHandler::Initialize(mojo::ApplicationImpl* app) { |
| 128 handler_task_runner_ = base::MessageLoop::current()->task_runner(); | 126 handler_task_runner_ = base::MessageLoop::current()->task_runner(); |
| 129 mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache", | 127 mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache", |
| 130 GetProxy(&url_response_disk_cache_)); | 128 GetProxy(&url_response_disk_cache_)); |
| 131 } | 129 } |
| 132 | 130 |
| 133 bool AndroidHandler::ConfigureIncomingConnection( | 131 bool AndroidHandler::ConfigureIncomingConnection( |
| 134 mojo::ServiceProviderImpl* service_provider_impl) { | 132 mojo::ServiceProviderImpl* service_provider_impl) { |
| 135 service_provider_impl->AddService<mojo::ContentHandler>( | 133 service_provider_impl->AddService<mojo::ContentHandler>( |
| 136 content_handler_factory_.GetInterfaceRequestHandler()); | 134 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(this)); |
| 137 return true; | 135 return true; |
| 138 } | 136 } |
| 139 | 137 |
| 140 void AndroidHandler::ExtractApplication(base::FilePath* extracted_dir, | 138 void AndroidHandler::ExtractApplication(base::FilePath* extracted_dir, |
| 141 base::FilePath* cache_dir, | 139 base::FilePath* cache_dir, |
| 142 mojo::URLResponsePtr response, | 140 mojo::URLResponsePtr response, |
| 143 const base::Closure& callback) { | 141 const base::Closure& callback) { |
| 144 url_response_disk_cache_->UpdateAndGetExtracted( | 142 url_response_disk_cache_->UpdateAndGetExtracted( |
| 145 response.Pass(), | 143 response.Pass(), |
| 146 [extracted_dir, cache_dir, callback](mojo::Array<uint8_t> extracted_path, | 144 [extracted_dir, cache_dir, callback](mojo::Array<uint8_t> extracted_path, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return ConvertUTF8ToJavaString(env, temporary_file.value()).Release(); | 177 return ConvertUTF8ToJavaString(env, temporary_file.value()).Release(); |
| 180 } | 178 } |
| 181 } | 179 } |
| 182 } | 180 } |
| 183 | 181 |
| 184 bool RegisterAndroidHandlerJni(JNIEnv* env) { | 182 bool RegisterAndroidHandlerJni(JNIEnv* env) { |
| 185 return RegisterNativesImpl(env); | 183 return RegisterNativesImpl(env); |
| 186 } | 184 } |
| 187 | 185 |
| 188 } // namespace shell | 186 } // namespace shell |
| OLD | NEW |