Lines Matching refs:env
51 static void setStringField(JNIEnv* env, const jobject& object, const jfieldID& field, const String& str)
53 jstring jstr = wtfStringToJstring(env, str);
54 env->SetObjectField(object, field, jstr);
55 env->DeleteLocalRef(jstr);
58 static void setFieldFromHeaderIfPresent(CacheResult* result, const char* header, JNIEnv* env, const jobject& object, const jfieldID& field, bool allowEmptyString)
62 setStringField(env, object, field, value);
65 static String getCacheFileBaseDir(JNIEnv* env)
69 jclass cacheManagerClass = env->FindClass("android/webkit/CacheManager");
70 jmethodID getCacheFileBaseDirMethod = env->GetStaticMethodID(cacheManagerClass, "getCacheFileBaseDir", "()Ljava/io/File;");
71 jclass fileClass = env->FindClass("java/io/File");
72 jmethodID getPathMethod = env->GetMethodID(fileClass, "getPath", "()Ljava/lang/String;");
73 jobject fileObject = env->CallStaticObjectMethod(cacheManagerClass, getCacheFileBaseDirMethod);
74 baseDir = jstringToWtfString(env, static_cast<jstring>(env->CallObjectMethod(fileObject, getPathMethod)));
79 static jobject getCacheResult(JNIEnv* env, jobject, jstring url)
82 scoped_refptr<CacheResult> result = WebCache::get(false /*privateBrowsing*/)->getCacheResult(jstringToWtfString(env, url));
90 String urlWtfString = jstringToWtfString(env, url);
93 String filePath = pathByAppendingComponent(getCacheFileBaseDir(env), encodedUrl.data());
97 jclass cacheResultClass = env->FindClass("android/webkit/CacheManager$CacheResult");
98 jmethodID constructor = env->GetMethodID(cacheResultClass, "<init>", "()V");
100 jfieldID contentdispositionField = env->GetFieldID(cacheResultClass, "contentdisposition", "Ljava/lang/String;");
101 jfieldID contentLengthField = env->GetFieldID(cacheResultClass, "contentLength", "J");
102 jfieldID etagField = env->GetFieldID(cacheResultClass, "etag", "Ljava/lang/String;");
103 jfieldID encodingField = env->GetFieldID(cacheResultClass, "encoding", "Ljava/lang/String;");
104 jfieldID expiresField = env->GetFieldID(cacheResultClass, "expires", "J");
105 jfieldID expiresStringField = env->GetFieldID(cacheResultClass, "expiresString", "Ljava/lang/String;");
106 jfieldID httpStatusCodeField = env->GetFieldID(cacheResultClass, "httpStatusCode", "I");
107 jfieldID lastModifiedField = env->GetFieldID(cacheResultClass, "lastModified", "Ljava/lang/String;");
108 jfieldID localPathField = env->GetFieldID(cacheResultClass, "localPath", "Ljava/lang/String;");
109 jfieldID locationField = env->GetFieldID(cacheResultClass, "location", "Ljava/lang/String;");
110 jfieldID mimeTypeField = env->GetFieldID(cacheResultClass, "mimeType", "Ljava/lang/String;");
112 jobject javaResult = env->NewObject(cacheResultClass, constructor);
113 setFieldFromHeaderIfPresent(result.get(), "content-disposition", env, javaResult, contentdispositionField, true);
114 env->SetLongField(javaResult, contentLengthField, result->contentSize());
115 setFieldFromHeaderIfPresent(result.get(), "etag", env, javaResult, etagField, false);
116 setStringField(env, javaResult, encodingField, "TODO"); // TODO: Where does the Android stack set this?
117 env->SetLongField(javaResult, expiresField, result->expires());
118 env->SetIntField(javaResult, httpStatusCodeField, result->responseCode());
119 setFieldFromHeaderIfPresent(result.get(), "last-modified", env, javaResult, lastModifiedField, false);
120 setStringField(env, javaResult, localPathField, encodedUrl.data());
121 setFieldFromHeaderIfPresent(result.get(), "location", env, javaResult, locationField, false);
122 setStringField(env, javaResult, mimeTypeField, result->mimeType());
131 int registerCacheManager(JNIEnv* env)
134 jclass cacheManager = env->FindClass(javaCacheManagerClass);
136 env->DeleteLocalRef(cacheManager);
138 return jniRegisterNativeMethods(env, javaCacheManagerClass, gCacheManagerMethods, NELEM(gCacheManagerMethods));