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

Side by Side Diff: src/FilterEngine.cpp

Issue 29367003: Issue #4711 - Rewrite legacy thread facilities
Patch Set: Created Dec. 7, 2016, 4:44 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
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 <algorithm> 18 #include <algorithm>
19 #include <cctype> 19 #include <cctype>
20 #include <functional> 20 #include <functional>
21 #include <string> 21 #include <string>
22 #include <thread>
22 23
23 #include <AdblockPlus.h> 24 #include <AdblockPlus.h>
24 #include "JsContext.h" 25 #include "JsContext.h"
25 #include "Thread.h"
26 26
27 using namespace AdblockPlus; 27 using namespace AdblockPlus;
28 28
29 extern std::string jsSources[]; 29 extern std::string jsSources[];
30 30
31 Filter::Filter(JsValue&& value) 31 Filter::Filter(JsValue&& value)
32 : JsValue(std::move(value)) 32 : JsValue(std::move(value))
33 { 33 {
34 if (!IsObject()) 34 if (!IsObject())
35 throw std::runtime_error("JavaScript value is not an object"); 35 throw std::runtime_error("JavaScript value is not an object");
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 preconfiguredPrefsObject->SetProperty(it->first, it->second); 154 preconfiguredPrefsObject->SetProperty(it->first, it->second);
155 } 155 }
156 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject) ; 156 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject) ;
157 // Load adblockplus scripts 157 // Load adblockplus scripts
158 for (int i = 0; !jsSources[i].empty(); i += 2) 158 for (int i = 0; !jsSources[i].empty(); i += 2)
159 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); 159 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
160 } 160 }
161 161
162 // TODO: This should really be implemented via a conditional variable 162 // TODO: This should really be implemented via a conditional variable
163 while (!initialized) 163 while (!initialized)
164 ::Sleep(10); 164 ::std::this_thread::sleep_for(std::chrono::milliseconds(10));;
165 } 165 }
166 166
167 namespace 167 namespace
168 { 168 {
169 typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap; 169 typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap;
170 170
171 ContentTypeMap CreateContentTypeMap() 171 ContentTypeMap CreateContentTypeMap()
172 { 172 {
173 ContentTypeMap contentTypes; 173 ContentTypeMap contentTypes;
174 contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER"; 174 contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER";
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 506 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
507 if (filter) 507 if (filter)
508 { 508 {
509 return filter; 509 return filter;
510 } 510 }
511 currentUrl = parentUrl; 511 currentUrl = parentUrl;
512 } 512 }
513 while (urlIterator != documentUrls.end()); 513 while (urlIterator != documentUrls.end());
514 return FilterPtr(); 514 return FilterPtr();
515 } 515 }
OLDNEW
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/GlobalJsObject.cpp » ('j') | src/GlobalJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld