Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: libadblockplus-android/jni/JniJsEngine.cpp

Issue 29422558: Issue 5167 - Update to use libadblockplus revision dca8df9af1a7 (Closed)
Left Patch Set: using move ctors, reverted some unrelated changes Created April 27, 2017, 6:19 a.m.
Right Patch Set: updated dependencies (..-binaries) Created May 10, 2017, 6:54 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « libadblockplus-android/jni/JniFilterEngine.cpp ('k') | libadblockplus-android/jni/JniJsValue.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 { 49 {
50 delete JniLongToTypePtr<AdblockPlus::JsEnginePtr>(ptr); 50 delete JniLongToTypePtr<AdblockPlus::JsEnginePtr>(ptr);
51 } 51 }
52 52
53 static void JNICALL JniSetEventCallback(JNIEnv* env, jclass clazz, jlong ptr, js tring jEventName, jlong jCallbackPtr) 53 static void JNICALL JniSetEventCallback(JNIEnv* env, jclass clazz, jlong ptr, js tring jEventName, jlong jCallbackPtr)
54 { 54 {
55 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr); 55 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr);
56 56
57 JniEventCallback* callback = JniLongToTypePtr<JniEventCallback>(jCallbackPtr); 57 JniEventCallback* callback = JniLongToTypePtr<JniEventCallback>(jCallbackPtr);
58 std::string eventName = JniJavaToStdString(env, jEventName); 58 std::string eventName = JniJavaToStdString(env, jEventName);
59 AdblockPlus::JsEngine::EventCallback eCallback = 59
60 std::bind(&JniEventCallback::Callback, callback, std::placeholders::_1); 60 auto eCallback = [callback](AdblockPlus::JsValueList&& params)
61 {
62 callback->Callback(std::move(params));
63 };
61 64
62 try 65 try
63 { 66 {
64 engine->SetEventCallback(eventName, eCallback); 67 engine->SetEventCallback(eventName, eCallback);
65 } 68 }
66 CATCH_AND_THROW(env) 69 CATCH_AND_THROW(env)
67 } 70 }
68 71
69 static void JNICALL JniRemoveEventCallback(JNIEnv* env, jclass clazz, jlong ptr, jstring jEventName) 72 static void JNICALL JniRemoveEventCallback(JNIEnv* env, jclass clazz, jlong ptr, jstring jEventName)
70 { 73 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 for (jsize i = 0; i < length; i++) 111 for (jsize i = 0; i < length; i++)
109 { 112 {
110 args.push_back(JniGetJsValue(ptrs[i])); 113 args.push_back(JniGetJsValue(ptrs[i]));
111 } 114 }
112 115
113 env->ReleasePrimitiveArrayCritical(jJsPtrs, ptrs, JNI_ABORT); 116 env->ReleasePrimitiveArrayCritical(jJsPtrs, ptrs, JNI_ABORT);
114 } 117 }
115 118
116 try 119 try
117 { 120 {
118 engine->TriggerEvent(eventName, args); 121 engine->TriggerEvent(eventName, std::move(args));
119 } 122 }
120 CATCH_AND_THROW(env) 123 CATCH_AND_THROW(env)
121 } 124 }
122 125
123 static void JNICALL JniSetDefaultFileSystem(JNIEnv* env, jclass clazz, jlong ptr , jstring jBasePath) 126 static void JNICALL JniSetDefaultFileSystem(JNIEnv* env, jclass clazz, jlong ptr , jstring jBasePath)
124 { 127 {
125 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr); 128 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr);
126 129
127 try 130 try
128 { 131 {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 249
247 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, 250 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue },
248 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue } , 251 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue } ,
249 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni NewStringValue } 252 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni NewStringValue }
250 }; 253 };
251 254
252 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r egisterNatives(JNIEnv *env, jclass clazz) 255 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r egisterNatives(JNIEnv *env, jclass clazz)
253 { 256 {
254 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 257 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
255 } 258 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld