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

Side by Side Diff: test/BaseJsTest.cpp

Issue 29499583: Issue 4938 - fix race conditions related to LazyFileSystem (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 27, 2017, 8:53 a.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
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 #include "BaseJsTest.h" 18 #include "BaseJsTest.h"
19 #include <AdblockPlus/FilterEngine.h>
20
21 using namespace AdblockPlus;
19 22
20 void DelayedTimer::ProcessImmediateTimers(DelayedTimer::SharedTasks& timerTasks) 23 void DelayedTimer::ProcessImmediateTimers(DelayedTimer::SharedTasks& timerTasks)
21 { 24 {
22 auto ii = timerTasks->begin(); 25 auto ii = timerTasks->begin();
23 while (ii != timerTasks->end()) 26 while (ii != timerTasks->end())
24 { 27 {
25 if (ii->timeout.count() == 0) 28 if (ii->timeout.count() == 0)
26 { 29 {
27 ii->callback(); 30 ii->callback();
28 ii = timerTasks->erase(ii); 31 ii = timerTasks->erase(ii);
(...skipping 13 matching lines...) Expand all
42 45
43 AdblockPlus::JsEnginePtr CreateJsEngine(JsEngineCreationParameters&& jsEngineCre ationParameters) 46 AdblockPlus::JsEnginePtr CreateJsEngine(JsEngineCreationParameters&& jsEngineCre ationParameters)
44 { 47 {
45 auto jsEngine = AdblockPlus::JsEngine::New(jsEngineCreationParameters.appInfo, 48 auto jsEngine = AdblockPlus::JsEngine::New(jsEngineCreationParameters.appInfo,
46 std::move(jsEngineCreationParameters.timer), 49 std::move(jsEngineCreationParameters.timer),
47 std::move(jsEngineCreationParameters.fileSystem), 50 std::move(jsEngineCreationParameters.fileSystem),
48 std::move(jsEngineCreationParameters.webRequest), 51 std::move(jsEngineCreationParameters.webRequest),
49 std::move(jsEngineCreationParameters.logSystem)); 52 std::move(jsEngineCreationParameters.logSystem));
50 return jsEngine; 53 return jsEngine;
51 } 54 }
55
56 FilterEnginePtr CreateFilterEngine(LazyFileSystem& fileSystem,
57 const JsEnginePtr& jsEngine,
58 const FilterEngine::CreationParameters& creationParams)
59 {
60 std::list<LazyFileSystem::Task> fileSystemTasks;
61 fileSystem.scheduler = [&fileSystemTasks](const LazyFileSystem::Task& task)
62 {
63 fileSystemTasks.emplace_back(task);
64 };
65 FilterEnginePtr retValue;
66 FilterEngine::CreateAsync(jsEngine, [&retValue, &fileSystem](const FilterEngin ePtr& filterEngine)
67 {
68 retValue = filterEngine;
69 fileSystem.scheduler = LazyFileSystem::ExecuteImmediately;
70 }, creationParams);
71 while (!retValue && !fileSystemTasks.empty())
72 {
73 (*fileSystemTasks.begin())();
74 fileSystemTasks.pop_front();
75 }
76 return retValue;
77 }
OLDNEW
« no previous file with comments | « test/BaseJsTest.h ('k') | test/FilterEngine.cpp » ('j') | test/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld