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

Side by Side Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/Platform.java

Issue 29536629: Issue 5556 - Update to use libadblockplus revision hg:566f64c8a2a8 (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: Created Sept. 5, 2017, 12:59 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package org.adblockplus.libadblockplus;
19
20 public class Platform implements Disposable
21 {
22 private final Disposer disposer;
23 protected final long ptr;
24
25 static
26 {
27 System.loadLibrary("adblockplus-jni");
28 registerNatives();
29 }
30
31 public Platform(final LogSystem logSystem, final WebRequest webRequest, final String basePath)
32 {
33 this(ctor(logSystem, webRequest, basePath));
34 }
35
36 public Platform(final WebRequest webRequest, final String basePath)
37 {
38 this(null, webRequest, basePath);
39 }
40
41 public Platform()
42 {
43 this(null, null, null);
anton 2017/09/06 06:21:28 it would be great to have some comment, how it wor
sergei 2017/09/08 09:45:02 I have added the comment to the constructor above
44 }
45
46 protected Platform(final long ptr)
47 {
48 this.ptr = ptr;
49 this.disposer = new Disposer(this, new DisposeWrapper(ptr));
50 }
51
52 public void setUpJsEngine(final AppInfo appInfo)
53 {
54 setUpJsEngine(this.ptr, appInfo);
55 }
56
57 public JsEngine getJsEngine()
58 {
59 return new JsEngine(getJsEnginePtr(this.ptr));
anton 2017/09/06 06:21:27 why JsEngine accepts js engine ptr, but filter eng
anton 2017/09/06 06:21:28 what's the purpose of creating new instance every
sergei 2017/09/08 09:45:02 Short story is to keep it simple. The main thing
sergei 2017/09/08 09:45:02 I think that generally corresponding Java classes
anton 2017/09/08 10:19:19 I'd say `getter` task is to `get`, not `create`. O
sergei 2017/09/08 12:25:30 getXXX methods create the corresponding entities o
60 }
61
62 public void setUpFilterEngine(final IsAllowedConnectionCallback isSubscription DownloadAllowedCallback)
63 {
64 setUpFilterEngine(this.ptr, isSubscriptionDownloadAllowedCallback);
65 }
66
67 public FilterEngine getFilterEngine()
68 {
69 ensureFilterEngine(this.ptr);
anton 2017/09/06 06:21:28 what does `ensure..` do? it's absolutely unclear w
sergei 2017/09/08 09:45:02 Done. BTW, I expect that the interface of Platform
70 return new FilterEngine(this.ptr);
anton 2017/09/06 06:21:28 same here - what's the purpose of creating new ins
sergei 2017/09/08 09:45:02 see comment for getJsEngine
71 }
72
73 @Override
74 public void dispose()
75 {
76 this.disposer.dispose();
77 }
78
79 private final static class DisposeWrapper implements Disposable
80 {
81 private final long ptr;
82
83 public DisposeWrapper(final long ptr)
84 {
85 this.ptr = ptr;
86 }
87
88 @Override
89 public void dispose()
90 {
91 dtor(this.ptr);
92 }
93 }
94
95 private final static native void registerNatives();
96
97 private final static native long ctor(LogSystem logSystem, WebRequest webReque st, String basePath);
98
99 private final static native void setUpJsEngine(long ptr, AppInfo appInfo);
100
101 private final static native long getJsEnginePtr(long ptr);
102
103 private final static native void setUpFilterEngine(long ptr, IsAllowedConnecti onCallback isSubscriptionDownloadAllowedCallback);
104
105 private final static native void ensureFilterEngine(long ptr);
106
107 private final static native void dtor(long ptr);
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld