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

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

Issue 29543810: Issue 5118 - Lock the platform interfaces before use (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added missing LogSystem Created Sept. 13, 2017, 5:46 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 | « no previous file | src/ConsoleJsObject.cpp » ('j') | src/Platform.cpp » ('J')
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-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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 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 void WithWebRequest(const WithWebRequestCallback&);
122 */
123 IWebRequest& GetWebRequest();
124 118
125 /** 119 typedef std::function<void(LogSystem&)> WithLogSystemCallback;
126 * @return The LogSystem implementation. 120 void WithLogSystem(const WithLogSystemCallback&);
127 */
128 LogSystem& GetLogSystem();
129 121
130 private: 122 private:
131 LogSystemPtr logSystem; 123 LogSystemPtr logSystem;
132 TimerPtr timer; 124 TimerPtr timer;
133 FileSystemPtr fileSystem; 125 FileSystemPtr fileSystem;
134 WebRequestPtr webRequest; 126 WebRequestPtr webRequest;
135 // used for creation and deletion of modules. 127 // used for creation and deletion of modules.
136 std::mutex modulesMutex; 128 std::mutex modulesMutex;
129 std::recursive_mutex interfacesMutex;
sergei 2017/09/13 19:20:53 What do you think about making the methods WithSom
hub 2017/09/13 19:50:49 I can do that.
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 */
145 class DefaultPlatformBuilder : public Platform::CreationParameters 138 class DefaultPlatformBuilder : public Platform::CreationParameters
146 { 139 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | src/ConsoleJsObject.cpp » ('j') | src/Platform.cpp » ('J')

Powered by Google App Engine
This is Rietveld