OLD | NEW |
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 12 matching lines...) Expand all Loading... |
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 "FilterEngine.h" |
28 #include <mutex> | 28 #include <mutex> |
29 #include <future> | 29 #include <future> |
30 | 30 |
31 namespace AdblockPlus | 31 namespace AdblockPlus |
32 { | 32 { |
33 class IV8IsolateProvider; | 33 struct IV8IsolateProvider; |
34 class JsEngine; | 34 class JsEngine; |
35 | 35 |
36 /** | 36 /** |
37 * AdblockPlus platform is the main component providing access to other | 37 * AdblockPlus platform is the main component providing access to other |
38 * modules. | 38 * modules. |
39 * | 39 * |
40 * It manages the functionality modules, e.g. JsEngine and FilterEngine as | 40 * It manages the functionality modules, e.g. JsEngine and FilterEngine as |
41 * well as allows to correctly work with asynchronous functionality. | 41 * well as allows to correctly work with asynchronous functionality. |
42 */ | 42 */ |
43 class Platform | 43 class Platform |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 const OnFilterEngineCreatedCallback& onCreated = OnFilterEngineCreatedCall
back()); | 100 const OnFilterEngineCreatedCallback& onCreated = OnFilterEngineCreatedCall
back()); |
101 | 101 |
102 /** | 102 /** |
103 * Synchronous equivalent of `CreateFilterEngineAsync`. | 103 * Synchronous equivalent of `CreateFilterEngineAsync`. |
104 * Internally it blocks and waits for finishing of certain asynchronous | 104 * Internally it blocks and waits for finishing of certain asynchronous |
105 * operations, please ensure that provided implementation does not lead to | 105 * operations, please ensure that provided implementation does not lead to |
106 * a dead lock. | 106 * a dead lock. |
107 */ | 107 */ |
108 FilterEngine& GetFilterEngine(); | 108 FilterEngine& GetFilterEngine(); |
109 | 109 |
110 /** | 110 typedef std::function<void(ITimer&)> WithTimerCallback; |
111 * @return The asynchronous ITimer implementation. | 111 virtual void WithTimer(const WithTimerCallback&); |
112 */ | |
113 ITimer& GetTimer(); | |
114 | 112 |
115 /** | 113 typedef std::function<void(IFileSystem&)> WithFileSystemCallback; |
116 * @return The asynchronous IFileSystem implementation. | 114 virtual void WithFileSystem(const WithFileSystemCallback&); |
117 */ | |
118 IFileSystem& GetFileSystem(); | |
119 | 115 |
120 /** | 116 typedef std::function<void(IWebRequest&)> WithWebRequestCallback; |
121 * @return The asynchronous IWebRequest implementation. | 117 virtual void WithWebRequest(const WithWebRequestCallback&); |
122 */ | |
123 IWebRequest& GetWebRequest(); | |
124 | 118 |
125 /** | 119 typedef std::function<void(LogSystem&)> WithLogSystemCallback; |
126 * @return The LogSystem implementation. | 120 virtual void WithLogSystem(const WithLogSystemCallback&); |
127 */ | |
128 LogSystem& GetLogSystem(); | |
129 | 121 |
130 private: | 122 protected: |
131 LogSystemPtr logSystem; | 123 LogSystemPtr logSystem; |
132 TimerPtr timer; | 124 TimerPtr timer; |
133 FileSystemPtr fileSystem; | 125 FileSystemPtr fileSystem; |
134 WebRequestPtr webRequest; | 126 WebRequestPtr webRequest; |
| 127 private: |
135 // used for creation and deletion of modules. | 128 // used for creation and deletion of modules. |
136 std::mutex modulesMutex; | 129 std::mutex modulesMutex; |
137 std::shared_ptr<JsEngine> jsEngine; | 130 std::shared_ptr<JsEngine> jsEngine; |
138 std::shared_future<FilterEnginePtr> filterEngine; | 131 std::shared_future<FilterEnginePtr> filterEngine; |
139 }; | 132 }; |
140 | 133 |
141 /** | 134 /** |
142 * A helper class allowing to construct a default Platform and to obtain | 135 * A helper class allowing to construct a default Platform and to obtain |
143 * the Scheduler used by Platform before the latter is constructed. | 136 * the Scheduler used by Platform before the latter is constructed. |
144 */ | 137 */ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 * when a corresponding field is nullptr and with a default Scheduler. | 172 * when a corresponding field is nullptr and with a default Scheduler. |
180 */ | 173 */ |
181 std::unique_ptr<Platform> CreatePlatform(); | 174 std::unique_ptr<Platform> CreatePlatform(); |
182 private: | 175 private: |
183 std::shared_ptr<Scheduler> asyncExecutor; | 176 std::shared_ptr<Scheduler> asyncExecutor; |
184 Scheduler defaultScheduler; | 177 Scheduler defaultScheduler; |
185 }; | 178 }; |
186 } | 179 } |
187 | 180 |
188 #endif // ADBLOCK_PLUS_PLATFORM_H | 181 #endif // ADBLOCK_PLUS_PLATFORM_H |
OLD | NEW |