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

Unified Diff: ui/android/resources/resource_manager_impl.cc

Issue 1419843002: Hold a reference to any kind of context in WindowAndroid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass Context instead of WindowAndroid from native ResourceManager to java side. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/android/resources/resource_manager_impl.cc
diff --git a/ui/android/resources/resource_manager_impl.cc b/ui/android/resources/resource_manager_impl.cc
index 37f9aeaedb87a1fddb484ccbb20169d576d81d8b..d9caec004d4d1a646add630e72fee9748928eae9 100644
--- a/ui/android/resources/resource_manager_impl.cc
+++ b/ui/android/resources/resource_manager_impl.cc
@@ -9,6 +9,7 @@
#include "cc/resources/scoped_ui_resource.h"
#include "jni/ResourceManager_jni.h"
#include "ui/android/resources/ui_resource_provider.h"
+#include "ui/android/window_android.h"
#include "ui/gfx/android/java_bitmap.h"
namespace ui {
@@ -20,11 +21,21 @@ ResourceManagerImpl* ResourceManagerImpl::FromJavaObject(jobject jobj) {
jobj));
}
-ResourceManagerImpl::ResourceManagerImpl() : host_(nullptr) {
+ResourceManagerImpl::ResourceManagerImpl(gfx::NativeWindow native_window)
+ : host_(nullptr) {
boliu 2015/10/26 16:31:49 This constructorcan call through to the one below,
gsennton 2015/10/26 16:48:47 Done.
JNIEnv* env = base::android::AttachCurrentThread();
java_obj_.Reset(env, Java_ResourceManager_create(
- env, base::android::GetApplicationContext(),
- reinterpret_cast<intptr_t>(this)).obj());
+ env, native_window->GetJavaDisplayContext().obj(),
+ reinterpret_cast<intptr_t>(this))
+ .obj());
+ DCHECK(!java_obj_.is_null());
+}
+
+ResourceManagerImpl::ResourceManagerImpl(jobject context) : host_(nullptr) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ java_obj_.Reset(env, Java_ResourceManager_create(
+ env, context, reinterpret_cast<intptr_t>(this))
+ .obj());
DCHECK(!java_obj_.is_null());
}

Powered by Google App Engine
This is Rietveld 408576698