| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 CATCH_THROW_AND_RETURN(env, 0) | 26 CATCH_THROW_AND_RETURN(env, 0) |
| 27 } | 27 } |
| 28 | 28 |
| 29 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 29 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) |
| 30 { | 30 { |
| 31 delete JniLongToTypePtr<JniLogSystemCallback>(ptr); | 31 delete JniLongToTypePtr<JniLogSystemCallback>(ptr); |
| 32 } | 32 } |
| 33 | 33 |
| 34 JniLogSystemCallback::JniLogSystemCallback(JNIEnv* env, jobject callbackObject) | 34 JniLogSystemCallback::JniLogSystemCallback(JNIEnv* env, jobject callbackObject) |
| 35 : JniCallbackBase(env, callbackObject), AdblockPlus::LogSystem() | 35 : JniCallbackBase(env, callbackObject), AdblockPlus::LogSystem(), logLevelClas
s(new JniGlobalReference<jclass>(env, env->FindClass(PKG("LogSystem$LogLevel")))
) |
| 36 { | 36 { |
| 37 logLevelClass.reset(new JniGlobalReference<jclass>(env, env->FindClass(PKG("Lo
gSystem$LogLevel")))); | |
| 38 } | 37 } |
| 39 | 38 |
| 40 void JniLogSystemCallback::operator()(AdblockPlus::LogSystem::LogLevel logLevel,
const std::string& message, const std::string& source) | 39 void JniLogSystemCallback::operator()(AdblockPlus::LogSystem::LogLevel logLevel,
const std::string& message, const std::string& source) |
| 41 { | 40 { |
| 42 JNIEnvAcquire env(GetJavaVM()); | 41 JNIEnvAcquire env(GetJavaVM()); |
| 43 | 42 |
| 44 jclass clazz = env->GetObjectClass(GetCallbackObject()); | 43 jclass clazz = env->GetObjectClass(GetCallbackObject()); |
| 45 jmethodID method = env->GetMethodID(clazz, "logCallback", "(" TYP("LogSystem$L
ogLevel") "Ljava/lang/String;Ljava/lang/String;)V"); | 44 jmethodID method = env->GetMethodID(clazz, "logCallback", "(" TYP("LogSystem$L
ogLevel") "Ljava/lang/String;Ljava/lang/String;)V"); |
| 46 | 45 |
| 47 // TODO: Set log level from Java and handle it here (to reduce C++->Java calls
) | 46 // TODO: Set log level from Java and handle it here (to reduce C++->Java calls
) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 static JNINativeMethod methods[] = | 88 static JNINativeMethod methods[] = |
| 90 { | 89 { |
| 91 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 90 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, |
| 92 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 91 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_LogSystem_
registerNatives(JNIEnv *env, jclass clazz) | 94 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_LogSystem_
registerNatives(JNIEnv *env, jclass clazz) |
| 96 { | 95 { |
| 97 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 96 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
| 98 } | 97 } |
| OLD | NEW |