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

Issue 29536629: Issue 5556 - Update to use libadblockplus revision hg:566f64c8a2a8 (Closed)

Created:
Sept. 5, 2017, 12:59 p.m. by sergei
Modified:
Sept. 11, 2017, 12:31 p.m.
Reviewers:
diegocarloslima, anton, jens
CC:
Felix Dahlke, René Jeschke
Base URL:
github.com:abby-sergz/libadblockplus-android.git
Visibility:
Public.

Description

add Platform class because new libadblockplus has it, namely AdblockPlus::Platform, which is basically an entry point and it's responsible for JsEngine, FilterEngine and platform dependent functionality, e.g. File System. Therefore Java JsEngine and FilterEngine are not disposable anymore because the corresponding instances of C++ classes are destroyed when Platform is destroyed. # based on https://codereview.adblockplus.org/29536604/ COLLABORATOR=anton@adblockplus.org

Patch Set 1 #

Total comments: 31

Patch Set 2 : address comments #

Patch Set 3 : update dependencies #

Total comments: 2

Patch Set 4 : address comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+334 lines, -311 lines) Patch
M dependencies View 1 2 1 chunk +1 line, -1 line 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java View 1 3 chunks +3 lines, -0 lines 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AppInfoJsObjectTest.java View 3 chunks +5 lines, -4 lines 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/BaseFilterEngineTest.java View 3 chunks +2 lines, -3 lines 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/BaseJsEngineTest.java View 2 chunks +2 lines, -31 lines 0 comments Download
A + libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/BasePlatformTest.java View 2 chunks +8 lines, -10 lines 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/IsAllowedConnectionCallbackTest.java View 2 chunks +4 lines, -4 lines 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java View 1 chunk +1 line, -1 line 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UpdateCheckTest.java View 2 chunks +7 lines, -5 lines 0 comments Download
M libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UpdaterTest.java View 2 chunks +4 lines, -4 lines 0 comments Download
M libadblockplus-android/jni/Android.mk View 1 chunk +1 line, -0 lines 0 comments Download
M libadblockplus-android/jni/JniCallbacks.h View 1 chunk +2 lines, -2 lines 0 comments Download
M libadblockplus-android/jni/JniFilter.cpp View 1 1 chunk +3 lines, -0 lines 0 comments Download
M libadblockplus-android/jni/JniFilterEngine.cpp View 1 5 chunks +7 lines, -60 lines 0 comments Download
D libadblockplus-android/jni/JniJsEngine.h View 1 chunk +0 lines, -30 lines 0 comments Download
M libadblockplus-android/jni/JniJsEngine.cpp View 2 chunks +1 line, -58 lines 0 comments Download
M libadblockplus-android/jni/JniNotification.cpp View 1 1 chunk +3 lines, -0 lines 0 comments Download
A + libadblockplus-android/jni/JniPlatform.h View 1 chunk +9 lines, -5 lines 0 comments Download
A libadblockplus-android/jni/JniPlatform.cpp View 1 chunk +144 lines, -0 lines 0 comments Download
M libadblockplus-android/src/org/adblockplus/libadblockplus/Filter.java View 1 1 chunk +2 lines, -1 line 0 comments Download
M libadblockplus-android/src/org/adblockplus/libadblockplus/FilterEngine.java View 1 4 chunks +6 lines, -38 lines 0 comments Download
M libadblockplus-android/src/org/adblockplus/libadblockplus/JsEngine.java View 4 chunks +2 lines, -41 lines 0 comments Download
M libadblockplus-android/src/org/adblockplus/libadblockplus/Notification.java View 1 1 chunk +1 line, -0 lines 0 comments Download
A libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java View 1 2 3 1 chunk +108 lines, -0 lines 0 comments Download
M libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java View 4 chunks +8 lines, -13 lines 0 comments Download

Messages

Total messages: 9
sergei
Sept. 5, 2017, 1:27 p.m. (2017-09-05 13:27:01 UTC) #1
anton
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp File libadblockplus-android/jni/JniFilterEngine.cpp (right): https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode51 libadblockplus-android/jni/JniFilterEngine.cpp:51: AdblockPlus::FilterEngine& GetFilterEngineRef(jlong ptr) rename to `platformPtr` https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode57 libadblockplus-android/jni/JniFilterEngine.cpp:57: static ...
Sept. 6, 2017, 6:21 a.m. (2017-09-06 06:21:28 UTC) #2
sergei
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp File libadblockplus-android/jni/JniFilterEngine.cpp (right): https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode51 libadblockplus-android/jni/JniFilterEngine.cpp:51: AdblockPlus::FilterEngine& GetFilterEngineRef(jlong ptr) On 2017/09/06 06:21:27, anton wrote: > ...
Sept. 8, 2017, 9:45 a.m. (2017-09-08 09:45:03 UTC) #3
anton
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp File libadblockplus-android/jni/JniFilterEngine.cpp (right): https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode57 libadblockplus-android/jni/JniFilterEngine.cpp:57: static jboolean JNICALL JniIsFirstRun(JNIEnv* env, jclass clazz, jlong ptr) ...
Sept. 8, 2017, 10:19 a.m. (2017-09-08 10:19:19 UTC) #4
anton
https://codereview.adblockplus.org/29536629/diff/29539610/libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java File libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java (right): https://codereview.adblockplus.org/29536629/diff/29539610/libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java#newcode31 libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java:31: // If an interface parameter value is null then ...
Sept. 8, 2017, 10:54 a.m. (2017-09-08 10:54:23 UTC) #5
sergei
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp File libadblockplus-android/jni/JniFilterEngine.cpp (right): https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode57 libadblockplus-android/jni/JniFilterEngine.cpp:57: static jboolean JNICALL JniIsFirstRun(JNIEnv* env, jclass clazz, jlong ptr) ...
Sept. 8, 2017, 12:25 p.m. (2017-09-08 12:25:31 UTC) #6
diegocarloslima
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp File libadblockplus-android/jni/JniFilterEngine.cpp (right): https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode57 libadblockplus-android/jni/JniFilterEngine.cpp:57: static jboolean JNICALL JniIsFirstRun(JNIEnv* env, jclass clazz, jlong ptr) ...
Sept. 8, 2017, 8:42 p.m. (2017-09-08 20:42:42 UTC) #7
anton
On 2017/09/08 12:25:31, sergei wrote: > https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp > File libadblockplus-android/jni/JniFilterEngine.cpp (right): > > https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-android/jni/JniFilterEngine.cpp#newcode57 > ...
Sept. 11, 2017, 9:24 a.m. (2017-09-11 09:24:00 UTC) #8
diegocarloslima
Sept. 11, 2017, 12:16 p.m. (2017-09-11 12:16:55 UTC) #9
On 2017/09/11 09:24:00, anton wrote:
> On 2017/09/08 12:25:31, sergei wrote:
> >
>
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-andr...
> > File libadblockplus-android/jni/JniFilterEngine.cpp (right):
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-andr...
> > libadblockplus-android/jni/JniFilterEngine.cpp:57: static jboolean JNICALL
> > JniIsFirstRun(JNIEnv* env, jclass clazz, jlong ptr)
> > On 2017/09/08 10:19:18, anton wrote:
> > > On 2017/09/08 09:45:01, sergei wrote:
> > > > On 2017/09/06 06:21:27, anton wrote:
> > > > > i'd suggest to rename all `ptr` to `platformPtr` in all methods
> > > > 
> > > > I'm not sure that there is a real necessity in it because here `ptr`
plays
> a
> > > > role of an opaque pointer and since we are not working with it directly
> only
> > > > through GetFilterEngineRef I would propose to leave `ptr` argument in
> these
> > > > methods, but rename it only where its nature is actually used, namely in
> > > > GetFilterEngineRef and in JniUpdateFiltersAsync. What do you think about
> it?
> > > > BTW, just below we even use generic `engine` however we keep in mind the
> > > actual
> > > > kind of the engine.
> > > 
> > > i'd prefer it to be renamed as previously it was c++ filter engine ref
> > actually
> > > and now it's platform actually (JniPlatform instance to be more detailed).
> > This
> > > could introduce misunderstanding.
> > 
> > I would like to wait for the third opinion here. I think that the only
meaning
> > `ptr` is  carrying here is a native pointer held by Java class and it should
> not
> > show in each method what is actually behind it. Why should it generate a lot
> of
> > changes if we change the nature of this pointer if it's used as an opaque
> > integer value?
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-andr...
> > File
> libadblockplus-android/src/org/adblockplus/libadblockplus/FilterEngine.java
> > (right):
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-andr...
> >
>
libadblockplus-android/src/org/adblockplus/libadblockplus/FilterEngine.java:38:
> > FilterEngine(/* JniPlatform */long ptr)
> > On 2017/09/08 10:19:19, anton wrote:
> > > On 2017/09/08 09:45:01, sergei wrote:
> > > > On 2017/09/06 06:21:27, anton wrote:
> > > > > `public` here is required. Otherwise it's `package` so it's working
for
> > the
> > > > > classes from the same package only.
> > > > 
> > > > I actually wanted it, so FilterEngine can be created only by a class
from
> > this
> > > > package, namely only by Platform.
> > > 
> > > Let's make it `public`.
> > > We did not introduce `package` scope in files though we could do it as the
> > point
> > > is absolutely the same and i don't see any sense to do it in 1 particular
> > case.
> > 
> > But in this case anyone can call a constructor of FilterEngine, it
definitely
> > should not be public, it should be private but in Java there is no concept
of
> > friend classes, so the choice is between protected and no modifier which is
> > package-private. Protected makes a little sense because it's rather for
> > inheritance but the class if final, so package private describes the
intention
> > better than other modifiers.
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-andr...
> > File libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java
> > (right):
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29536630/libadblockplus-andr...
> > libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java:59:
> > return new JsEngine(getJsEnginePtr(this.ptr));
> > On 2017/09/08 10:19:19, anton wrote:
> > > On 2017/09/08 09:45:02, sergei wrote:
> > > > On 2017/09/06 06:21:28, anton wrote:
> > > > > what's the purpose of creating new instance every time it's requested?
> why
> > > not
> > > > > create it once in `setUpJsEngine` and save as private property? 
> > > > 
> > > > Short story is to keep it simple.
> > > > 
> > > > The main thing here and for FilterEngine is that I tried to stay closer
to
> > C++
> > > > interface where Platform returns references to JsEngine and to
> FilterEngine.
> > > > Another thing is that, although it's a tiny thing, I guess, we should
not
> > pay
> > > > for what we don't use, so if we don't use Java JsEngine (it's used only
in
> > > > tests) we should not fiddle around with it. Let's say one constructs
> > Platform
> > > > and calls getFilterEngine, in this case the member Platform.jsEngine
would
> > be
> > > > null which looks confusing. One could of course initialize it anyway
when
> > it's
> > > > created but there are actually several ways to cause a creation of
> JsEngine
> > > and
> > > > I would assume that the interface of AdblockPlus::Platform is not stable
> > yet,
> > > so
> > > > I would propose to wait with such additional functionality in
> > > > libadblockplus-android. The idea is maybe not bad, so if there are some
> > > > objections then I would propose to make it but under another issue. What
> is
> > > your
> > > > opinion?
> > > 
> > > I'd say `getter` task is to `get`, not `create`. Otherwise i'd prefer it
to
> be
> > > renamed to 'create..' or 'build..'.
> > >  I'd still prefer both engines to be created in `setUp..` methods and just
> > > returned in getters.
> > getXXX methods create the corresponding entities only once and only if they
> are
> > not created yet, so they are rather getters. What concerns creation of Java
> > classes I think it's fine because they are merely tiny wrappers, similar to
> > std::shared_ptr, for example, so they cannot be counted as the creation of
the
> > entities. BTW, setUp methods are optional and IMO it's a bad design when one
> has
> > to call methods in a specific order, until it's in the aim of a class, so I
> > would like to avoid asking firstly call some `create` method and only then
one
> > may call a getter, in the latter case I would rather remove getters.
> > I would say that the only "stable" method here is setUpJsEngine, I think it
> will
> > stay unchanged, others are not too important right now.
> > getJsEngine - it exists only to allow users to get access to internals, e.g.
> in
> > tests, or where we are not ready yet. Normally it should not be used.
> > setUpFilterEngine - should be actually called `createFilterEngineAsync` as
> it's
> > called in libadblockplus, but I made it simpler here for present.
> > getFilterEngine - here and in libadblockplus it exists only to simplify the
> > starting to work with libadblockplus, namely one should not care about
> > synchronization with asynchronous creation of FilterEngine if all interfaces
> > have a default implementation. I would like to remove this method, at least
in
> > libadblockplus-android, but it will be possible only after switching to
> > `createFilterEngineAsync` everywhere which is not a small change.
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29539610/libadblockplus-andr...
> > File libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java
> > (right):
> > 
> >
>
https://codereview.adblockplus.org/29536629/diff/29539610/libadblockplus-andr...
> > libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java:31:
//
> > If an interface parameter value is null then a default implementation is
> > On 2017/09/08 10:54:22, anton wrote:
> > > it would be better to have javadoc (/**, not just comment) here
> > 
> > Done.
> 
> LGTM

LGTM

Powered by Google App Engine
This is Rietveld