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

Delta Between Two Patch Sets: 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
Left Patch Set: Created Sept. 5, 2017, 12:59 p.m.
Right Patch Set: address comment Created Sept. 8, 2017, 12:20 p.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
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 10 matching lines...) Expand all
21 { 21 {
22 private final Disposer disposer; 22 private final Disposer disposer;
23 protected final long ptr; 23 protected final long ptr;
24 24
25 static 25 static
26 { 26 {
27 System.loadLibrary("adblockplus-jni"); 27 System.loadLibrary("adblockplus-jni");
28 registerNatives(); 28 registerNatives();
29 } 29 }
30 30
31 /**
32 * If an interface parameter value is null then a default implementation is
33 * chosen.
34 * If basePath is null then paths are not resolved to a full path, thus
35 * current working directory is used.
36 */
31 public Platform(final LogSystem logSystem, final WebRequest webRequest, final String basePath) 37 public Platform(final LogSystem logSystem, final WebRequest webRequest, final String basePath)
32 { 38 {
33 this(ctor(logSystem, webRequest, basePath)); 39 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 } 40 }
45 41
46 protected Platform(final long ptr) 42 protected Platform(final long ptr)
47 { 43 {
48 this.ptr = ptr; 44 this.ptr = ptr;
49 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); 45 this.disposer = new Disposer(this, new DisposeWrapper(ptr));
50 } 46 }
51 47
52 public void setUpJsEngine(final AppInfo appInfo) 48 public void setUpJsEngine(final AppInfo appInfo)
53 { 49 {
54 setUpJsEngine(this.ptr, appInfo); 50 setUpJsEngine(this.ptr, appInfo);
55 } 51 }
56 52
57 public JsEngine getJsEngine() 53 public JsEngine getJsEngine()
58 { 54 {
59 return new JsEngine(getJsEnginePtr(this.ptr)); 55 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 } 56 }
61 57
62 public void setUpFilterEngine(final IsAllowedConnectionCallback isSubscription DownloadAllowedCallback) 58 public void setUpFilterEngine(final IsAllowedConnectionCallback isSubscription DownloadAllowedCallback)
63 { 59 {
64 setUpFilterEngine(this.ptr, isSubscriptionDownloadAllowedCallback); 60 setUpFilterEngine(this.ptr, isSubscriptionDownloadAllowedCallback);
65 } 61 }
66 62
67 public FilterEngine getFilterEngine() 63 public FilterEngine getFilterEngine()
68 { 64 {
65 // Initially FilterEngine is not constructed when Platform is instantiated
66 // and in addition FilterEngine is being created asynchronously, the call
67 // of `ensureFilterEngine` causes a construction of FilterEngine if it's
68 // not created yet and waits for it.
69 ensureFilterEngine(this.ptr); 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); 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 } 71 }
72 72
73 @Override 73 @Override
74 public void dispose() 74 public void dispose()
75 { 75 {
76 this.disposer.dispose(); 76 this.disposer.dispose();
77 } 77 }
78 78
79 private final static class DisposeWrapper implements Disposable 79 private final static class DisposeWrapper implements Disposable
80 { 80 {
(...skipping 18 matching lines...) Expand all
99 private final static native void setUpJsEngine(long ptr, AppInfo appInfo); 99 private final static native void setUpJsEngine(long ptr, AppInfo appInfo);
100 100
101 private final static native long getJsEnginePtr(long ptr); 101 private final static native long getJsEnginePtr(long ptr);
102 102
103 private final static native void setUpFilterEngine(long ptr, IsAllowedConnecti onCallback isSubscriptionDownloadAllowedCallback); 103 private final static native void setUpFilterEngine(long ptr, IsAllowedConnecti onCallback isSubscriptionDownloadAllowedCallback);
104 104
105 private final static native void ensureFilterEngine(long ptr); 105 private final static native void ensureFilterEngine(long ptr);
106 106
107 private final static native void dtor(long ptr); 107 private final static native void dtor(long ptr);
108 } 108 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld