Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 *response, "status"); | 76 *response, "status"); |
77 sResponse.responseStatus = JniGetIntField(*env, | 77 sResponse.responseStatus = JniGetIntField(*env, |
78 serverResponseClass->Get(), *response, "responseStatus"); | 78 serverResponseClass->Get(), *response, "responseStatus"); |
79 sResponse.responseText = JniGetStringField(*env, | 79 sResponse.responseText = JniGetStringField(*env, |
80 serverResponseClass->Get(), *response, "response"); | 80 serverResponseClass->Get(), *response, "response"); |
81 | 81 |
82 // map headers | 82 // map headers |
83 jobjectArray responseHeadersArray = JniGetStringArrayField(*env, | 83 jobjectArray responseHeadersArray = JniGetStringArrayField(*env, |
84 serverResponseClass->Get(), *response, "headers"); | 84 serverResponseClass->Get(), *response, "headers"); |
85 | 85 |
86 if (responseHeadersArray) { | 86 if (responseHeadersArray) |
René Jeschke
2016/07/12 16:22:53
Please pay attention to our coding style, opening
anton
2016/07/13 06:49:52
Acknowledged.
| |
87 { | |
87 int itemsCount = env->GetArrayLength(responseHeadersArray) / 2; | 88 int itemsCount = env->GetArrayLength(responseHeadersArray) / 2; |
88 for (int i=0; i<itemsCount; i++) { | 89 for (int i = 0; i < itemsCount; i++) |
89 // key | 90 { |
René Jeschke
2016/07/12 16:22:53
This comment is not needed, the variable name spea
anton
2016/07/13 06:49:52
Acknowledged.
| |
90 jstring jKey = (jstring)env->GetObjectArrayElement(responseHeadersArra y, i * 2); | 91 jstring jKey = (jstring)env->GetObjectArrayElement(responseHeadersArra y, i * 2); |
91 std::string stdKey = JniJavaToStdString(*env, jKey); | 92 std::string stdKey = JniJavaToStdString(*env, jKey); |
92 | 93 |
93 // value | |
René Jeschke
2016/07/12 16:22:53
See // key
anton
2016/07/13 06:49:52
Acknowledged.
| |
94 jstring jValue = (jstring)env->GetObjectArrayElement(responseHeadersAr ray, i * 2 + 1); | 94 jstring jValue = (jstring)env->GetObjectArrayElement(responseHeadersAr ray, i * 2 + 1); |
95 std::string stdValue = JniJavaToStdString(*env, jValue); | 95 std::string stdValue = JniJavaToStdString(*env, jValue); |
96 | 96 |
97 std::pair<std::string,std::string> keyValue(stdKey, stdValue); | 97 std::pair<std::string,std::string> keyValue(stdKey, stdValue); |
98 sResponse.responseHeaders.push_back(keyValue); | 98 sResponse.responseHeaders.push_back(keyValue); |
99 } | 99 } |
100 } | 100 } |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
(...skipping 17 matching lines...) Expand all Loading... | |
121 static JNINativeMethod methods[] = | 121 static JNINativeMethod methods[] = |
122 { | 122 { |
123 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 123 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, |
124 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 124 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
125 }; | 125 }; |
126 | 126 |
127 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest _registerNatives(JNIEnv *env, jclass clazz) | 127 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest _registerNatives(JNIEnv *env, jclass clazz) |
128 { | 128 { |
129 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 129 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
130 } | 130 } |
LEFT | RIGHT |