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

Side by Side Diff: include/AdblockPlus/Platform.h

Issue 29508555: Issue 5450 - move FilterEngine into Platform (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: fix typos Created Aug. 7, 2017, 1:03 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
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | shell/src/Main.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 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/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef ADBLOCK_PLUS_PLATFORM_H 18 #ifndef ADBLOCK_PLUS_PLATFORM_H
19 #define ADBLOCK_PLUS_PLATFORM_H 19 #define ADBLOCK_PLUS_PLATFORM_H
20 20
21 #include "LogSystem.h" 21 #include "LogSystem.h"
22 #include "ITimer.h" 22 #include "ITimer.h"
23 #include "IFileSystem.h" 23 #include "IFileSystem.h"
24 #include "IWebRequest.h" 24 #include "IWebRequest.h"
25 #include "AppInfo.h" 25 #include "AppInfo.h"
26 #include "Scheduler.h" 26 #include "Scheduler.h"
27 #include "FilterEngine.h"
27 #include <mutex> 28 #include <mutex>
29 #include <future>
28 30
29 namespace AdblockPlus 31 namespace AdblockPlus
30 { 32 {
31 /** 33 /**
32 * A factory to construct DefaultTimer. 34 * A factory to construct DefaultTimer.
33 */ 35 */
34 TimerPtr CreateDefaultTimer(); 36 TimerPtr CreateDefaultTimer();
35 37
36 /** 38 /**
37 * A factory to construct DefaultFileSystem. 39 * A factory to construct DefaultFileSystem.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 */ 72 */
71 struct CreationParameters 73 struct CreationParameters
72 { 74 {
73 LogSystemPtr logSystem; 75 LogSystemPtr logSystem;
74 TimerPtr timer; 76 TimerPtr timer;
75 WebRequestPtr webRequest; 77 WebRequestPtr webRequest;
76 FileSystemPtr fileSystem; 78 FileSystemPtr fileSystem;
77 }; 79 };
78 80
79 /** 81 /**
82 * Callback type invoked when FilterEngine is created.
83 */
84 typedef std::function<void(const FilterEnginePtr&)> OnFilterEngineCreatedCal lback;
85
86 /**
80 * Platform constructor. 87 * Platform constructor.
81 * 88 *
82 * When a parameter value is nullptr the corresponding default 89 * When a parameter value is nullptr the corresponding default
83 * implementation is chosen. 90 * implementation is chosen.
84 */ 91 */
85 explicit Platform(CreationParameters&& creationParameters = CreationParamete rs()); 92 explicit Platform(CreationParameters&& creationParameters = CreationParamete rs());
86 ~Platform(); 93 ~Platform();
87 94
88 /** 95 /**
89 * Ensures that JsEngine is constructed. 96 * Ensures that JsEngine is constructed.
90 * 97 *
91 * @param appInfo Information about the app, if jsEngine is already present 98 * @param appInfo Information about the app, if jsEngine is already present
92 * then the value is ignored. 99 * then the value is ignored.
93 */ 100 */
94 void SetUpJsEngine(const AppInfo& appInfo = AppInfo()); 101 void SetUpJsEngine(const AppInfo& appInfo = AppInfo());
95 102
96 /** 103 /**
97 * Retrieves the `JsEngine` instance. It calls SetUpJsEngine if JsEngine is 104 * Retrieves the `JsEngine` instance. It calls SetUpJsEngine if JsEngine is
98 * not initialized yet. 105 * not initialized yet.
99 */ 106 */
100 std::shared_ptr<JsEngine> GetJsEngine(); 107 std::shared_ptr<JsEngine> GetJsEngine();
101 108
102 /** 109 /**
110 * Ensures that FilterEngine is constructed. Only the first call is effectiv e.
111 *
112 * @param parameters optional creation parameters.
113 * @param onCreated A callback which is called when FilterEngine is ready
114 * for use.
115 */
116 void CreateFilterEngineAsync(const FilterEngine::CreationParameters& paramet ers = FilterEngine::CreationParameters(),
117 const OnFilterEngineCreatedCallback& onCreated = OnFilterEngineCreatedCall back());
118
119 /**
120 * Synchronous equivalent of `CreateFilterEngineAsync`.
121 * Internally it blocks and waits for finishing of certain asynchronous
122 * operations, please ensure that provided implementation does not lead to
123 * a dead lock.
124 */
125 FilterEnginePtr GetFilterEngine();
126
127 /**
103 * @return The asynchronous ITimer implementation. 128 * @return The asynchronous ITimer implementation.
104 */ 129 */
105 ITimer& GetTimer(); 130 ITimer& GetTimer();
106 131
107 /** 132 /**
108 * @return The asynchronous IFileSystem implementation. 133 * @return The asynchronous IFileSystem implementation.
109 */ 134 */
110 IFileSystem& GetFileSystem(); 135 IFileSystem& GetFileSystem();
111 136
112 /** 137 /**
113 * @return The asynchronous IWebRequest implementation. 138 * @return The asynchronous IWebRequest implementation.
114 */ 139 */
115 IWebRequest& GetWebRequest(); 140 IWebRequest& GetWebRequest();
116 141
117 /** 142 /**
118 * @see `SetLogSystem()`. 143 * @see `SetLogSystem()`.
119 */ 144 */
120 LogSystem& GetLogSystem(); 145 LogSystem& GetLogSystem();
121 146
122 private: 147 private:
123 LogSystemPtr logSystem; 148 LogSystemPtr logSystem;
124 TimerPtr timer; 149 TimerPtr timer;
125 FileSystemPtr fileSystem; 150 FileSystemPtr fileSystem;
126 WebRequestPtr webRequest; 151 WebRequestPtr webRequest;
127 // used for creation and deletion of modules. 152 // used for creation and deletion of modules.
128 std::mutex modulesMutex; 153 std::mutex modulesMutex;
129 std::shared_ptr<JsEngine> jsEngine; 154 std::shared_ptr<JsEngine> jsEngine;
155 std::shared_future<FilterEnginePtr> filterEngine;
130 }; 156 };
131 } 157 }
132 158
133 #endif // ADBLOCK_PLUS_PLATFORM_H 159 #endif // ADBLOCK_PLUS_PLATFORM_H
OLDNEW
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | shell/src/Main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld