Changeset 80103 in webkit
- Timestamp:
- Mar 2, 2011 1:49:39 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/Android.v8bindings.mk
r75313 r80103 179 179 bridge/jni/v8/JavaClassV8.cpp \ 180 180 bridge/jni/v8/JavaInstanceV8.cpp \ 181 bridge/jni/v8/JavaNPObject.cpp 181 bridge/jni/v8/JavaNPObject.cpp \ 182 bridge/jni/v8/JobjectWrapper.cpp -
trunk/Source/WebCore/ChangeLog
r80102 r80103 1 2011-03-02 Steve Block <steveblock@google.com> 2 3 Reviewed by Jeremy Orlow. 4 5 JObjectWrapper should be moved to its own file 6 https://bugs.webkit.org/show_bug.cgi?id=55384 7 8 No new tests, refactoring only. 9 10 * Android.v8bindings.mk: 11 * WebCore.gypi: 12 * bridge/jni/v8/JNIBridgeV8.cpp: 13 (JavaField::JavaField): 14 * bridge/jni/v8/JNIBridgeV8.h: 15 * bridge/jni/v8/JavaInstanceV8.cpp: 16 (JavaInstance::JavaInstance): 17 * bridge/jni/v8/JavaInstanceV8.h: 18 * bridge/jni/v8/JobjectWrapper.cpp: Copied from Source/WebCore/bridge/jni/v8/JNIBridgeV8.h. 19 (JobjectWrapper::JobjectWrapper): 20 (JobjectWrapper::~JobjectWrapper): 21 * bridge/jni/v8/JobjectWrapper.h: Copied from Source/WebCore/bridge/jni/v8/JNIBridgeV8.h. 22 (JSC::Bindings::JobjectWrapper::instance): 23 (JSC::Bindings::JobjectWrapper::setInstance): 24 (JSC::Bindings::JobjectWrapper::ref): 25 (JSC::Bindings::JobjectWrapper::deref): 26 1 27 2011-02-25 Andrey Kosyakov <caseq@chromium.org> 2 28 -
trunk/Source/WebCore/WebCore.gypi
r80102 r80103 1022 1022 'bridge/jni/v8/JavaNPObjectV8.h', 1023 1023 'bridge/jni/v8/JavaStringV8.h', 1024 'bridge/jni/v8/JobjectWrapper.cpp', 1025 'bridge/jni/v8/JobjectWrapper.h', 1024 1026 'css/CSSBorderImageValue.cpp', 1025 1027 'css/CSSBorderImageValue.h', -
trunk/Source/WebCore/bridge/jni/v8/JNIBridgeV8.cpp
r79998 r80103 43 43 m_name = JavaString(env, fieldName); 44 44 45 m_field = new J ObjectWrapper(aField);45 m_field = new JobjectWrapper(aField); 46 46 } 47 47 -
trunk/Source/WebCore/bridge/jni/v8/JNIBridgeV8.h
r79998 r80103 30 30 31 31 #include "JNIBridge.h" // For JavaString 32 #include "J avaInstanceV8.h" // For JObjectWrapper32 #include "JobjectWrapper.h" 33 33 34 34 namespace JSC { … … 49 49 JavaString m_type; 50 50 JNIType m_JNIType; 51 RefPtr<J ObjectWrapper> m_field;51 RefPtr<JobjectWrapper> m_field; 52 52 }; 53 53 -
trunk/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp
r79998 r80103 34 34 #include "JavaClassV8.h" 35 35 36 #include <assert.h>37 38 36 using namespace JSC::Bindings; 39 37 40 38 JavaInstance::JavaInstance(jobject instance) 41 39 { 42 m_instance = new J ObjectWrapper(instance);40 m_instance = new JobjectWrapper(instance); 43 41 m_class = 0; 44 42 } … … 155 153 } 156 154 157 JObjectWrapper::JObjectWrapper(jobject instance)158 : m_refCount(0)159 {160 assert(instance);161 162 // Cache the JNIEnv used to get the global ref for this java instanace.163 // It'll be used to delete the reference.164 m_env = getJNIEnv();165 166 m_instance = m_env->NewGlobalRef(instance);167 168 if (!m_instance)169 fprintf(stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance);170 }171 172 JObjectWrapper::~JObjectWrapper()173 {174 m_env->DeleteGlobalRef(m_instance);175 }176 177 155 #endif // ENABLE(JAVA_BRIDGE) -
trunk/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h
r79998 r80103 31 31 32 32 #include "JNIUtility.h" 33 #include "JobjectWrapper.h" 33 34 #include "npruntime.h" 34 35 … … 43 44 44 45 class JavaClass; 45 46 class JObjectWrapper {47 friend class RefPtr<JObjectWrapper>;48 friend class JavaField;49 friend class JavaInstance;50 51 public:52 jobject instance() const { return m_instance; }53 void setInstance(jobject instance) { m_instance = instance; }54 55 void ref() { m_refCount++; }56 void deref()57 {58 if (!(--m_refCount))59 delete this;60 }61 62 protected:63 JObjectWrapper(jobject);64 ~JObjectWrapper();65 66 jobject m_instance;67 68 private:69 JNIEnv* m_env;70 unsigned int m_refCount;71 };72 46 73 47 class JavaInstance : public RefCounted<JavaInstance> { … … 89 63 90 64 protected: 91 RefPtr<J ObjectWrapper> m_instance;65 RefPtr<JobjectWrapper> m_instance; 92 66 mutable JavaClass* m_class; 93 67 -
trunk/Source/WebCore/bridge/jni/v8/JobjectWrapper.cpp
r80102 r80103 1 1 /* 2 * Copyright 201 0, The Android Open Source Project2 * Copyright 2011, The Android Open Source Project 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #i fndef JNIBridgeV8_h27 # define JNIBridgeV8_h26 #include "config.h" 27 #include "JobjectWrapper.h" 28 28 29 29 #if ENABLE(JAVA_BRIDGE) 30 30 31 #include "JNIBridge.h" // For JavaString 32 #include "JavaInstanceV8.h" // For JObjectWrapper 31 #include <assert.h> 33 32 34 namespace JSC { 33 using namespace JSC::Bindings; 35 34 36 namespace Bindings { 35 JobjectWrapper::JobjectWrapper(jobject instance) 36 : m_refCount(0) 37 { 38 assert(instance); 37 39 38 class JavaField { 39 public: 40 JavaField(JNIEnv*, jobject aField);40 // Cache the JNIEnv used to get the global ref for this java instanace. 41 // It'll be used to delete the reference. 42 m_env = getJNIEnv(); 41 43 42 const JavaString& name() const { return m_name; } 43 const char* type() const { return m_type.utf8(); } 44 m_instance = m_env->NewGlobalRef(instance); 44 45 45 JNIType getJNIType() const { return m_JNIType; } 46 if (!m_instance) 47 fprintf(stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance); 48 } 46 49 47 private: 48 JavaString m_name; 49 JavaString m_type; 50 JNIType m_JNIType; 51 RefPtr<JObjectWrapper> m_field; 52 }; 53 54 } // namespace Bindings 55 56 } // namespace JSC 50 JobjectWrapper::~JobjectWrapper() 51 { 52 m_env->DeleteGlobalRef(m_instance); 53 } 57 54 58 55 #endif // ENABLE(JAVA_BRIDGE) 59 60 #endif // JNIBridgeV8_h -
trunk/Source/WebCore/bridge/jni/v8/JobjectWrapper.h
r80102 r80103 1 1 /* 2 * Copyright 201 0, The Android Open Source Project2 * Copyright 2011, The Android Open Source Project 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef J NIBridgeV8_h27 #define J NIBridgeV8_h26 #ifndef JobjectWrapper_h 27 #define JobjectWrapper_h 28 28 29 29 #if ENABLE(JAVA_BRIDGE) 30 30 31 #include "JNIBridge.h" // For JavaString 32 #include "JavaInstanceV8.h" // For JObjectWrapper 31 #include "JNIUtility.h" 33 32 34 33 namespace JSC { … … 36 35 namespace Bindings { 37 36 38 class JavaField { 37 class JobjectWrapper { 38 friend class JavaField; 39 friend class JavaInstance; 40 39 41 public: 40 JavaField(JNIEnv*, jobject aField); 42 jobject instance() const { return m_instance; } 43 void setInstance(jobject instance) { m_instance = instance; } 41 44 42 const JavaString& name() const { return m_name; } 43 const char* type() const { return m_type.utf8(); } 45 void ref() { m_refCount++; } 46 void deref() 47 { 48 if (!(--m_refCount)) 49 delete this; 50 } 44 51 45 JNIType getJNIType() const { return m_JNIType; } 52 protected: 53 JobjectWrapper(jobject); 54 ~JobjectWrapper(); 55 56 jobject m_instance; 46 57 47 58 private: 48 JavaString m_name; 49 JavaString m_type; 50 JNIType m_JNIType; 51 RefPtr<JObjectWrapper> m_field; 59 JNIEnv* m_env; 60 unsigned int m_refCount; 52 61 }; 53 62 … … 57 66 58 67 #endif // ENABLE(JAVA_BRIDGE) 59 60 #endif // JNIBridgeV8_h 68 #endif // JobjectWrapper_h
Note: See TracChangeset
for help on using the changeset viewer.