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

Side by Side Diff: src/plugin/AdblockPlusClient.cpp

Issue 5163396739629056: Issue #1234 - Remove CString from ShouldBlock(), IsElementHidden() declarations (Closed)
Patch Set: Created Sept. 30, 2014, 5:37 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 | « src/plugin/AdblockPlusClient.h ('k') | src/plugin/AdblockPlusDomTraverser.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 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 #include "PluginSettings.h" 2 #include "PluginSettings.h"
3 #include "PluginSystem.h" 3 #include "PluginSystem.h"
4 #include "PluginFilter.h" 4 #include "PluginFilter.h"
5 #include "PluginClientFactory.h" 5 #include "PluginClientFactory.h"
6 #include "PluginMutex.h" 6 #include "PluginMutex.h"
7 #include "PluginClass.h" 7 #include "PluginClass.h"
8 8
9 #include "AdblockPlusClient.h" 9 #include "AdblockPlusClient.h"
10 10
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 s_instance = client; 201 s_instance = client;
202 } 202 }
203 203
204 instance = s_instance; 204 instance = s_instance;
205 } 205 }
206 s_criticalSectionLocal.Unlock(); 206 s_criticalSectionLocal.Unlock();
207 207
208 return instance; 208 return instance;
209 } 209 }
210 210
211 211 bool CAdblockPlusClient::ShouldBlock(const std::wstring& src, int contentType, c onst std::wstring& domain, bool addDebug)
212 bool CAdblockPlusClient::ShouldBlock(CString src, int contentType, const CString & domain, bool addDebug)
213 { 212 {
214 bool isBlocked = false; 213 bool isBlocked = false;
215
216 bool isCached = false; 214 bool isCached = false;
217
218 CPluginSettings* settings = CPluginSettings::GetInstance();
219
220 m_criticalSectionCache.Lock(); 215 m_criticalSectionCache.Lock();
221 { 216 {
222 std::map<CString,bool>::iterator it = m_cacheBlockedSources.find(src); 217 auto it = m_cacheBlockedSources.find(src);
223 218
224 isCached = it != m_cacheBlockedSources.end(); 219 isCached = it != m_cacheBlockedSources.end();
225 if (isCached) 220 if (isCached)
226 { 221 {
227 isBlocked = it->second; 222 isBlocked = it->second;
228 } 223 }
229 } 224 }
230 m_criticalSectionCache.Unlock(); 225 m_criticalSectionCache.Unlock();
231 226
232 if (!isCached) 227 if (!isCached)
233 { 228 {
234 m_criticalSectionFilter.Lock(); 229 m_criticalSectionFilter.Lock();
235 { 230 {
236 isBlocked = m_filter->ShouldBlock(src, contentType, domain, addDebug); 231 isBlocked = m_filter->ShouldBlock(src, contentType, domain, addDebug);
237 } 232 }
238 m_criticalSectionFilter.Unlock(); 233 m_criticalSectionFilter.Unlock();
239 234
240
241 // Cache result, if content type is defined 235 // Cache result, if content type is defined
242 if (contentType != CFilter::contentTypeAny) 236 if (contentType != CFilter::contentTypeAny)
243 { 237 {
244 m_criticalSectionCache.Lock(); 238 m_criticalSectionCache.Lock();
245 { 239 {
246 m_cacheBlockedSources[src] = isBlocked; 240 m_cacheBlockedSources[src] = isBlocked;
247 } 241 }
248 m_criticalSectionCache.Unlock(); 242 m_criticalSectionCache.Unlock();
249 } 243 }
250 } 244 }
251
252
253 return isBlocked; 245 return isBlocked;
254 } 246 }
255 247
256 bool CAdblockPlusClient::IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& domain, const CString& indent, CPluginFilter* filter) 248 bool CAdblockPlusClient::IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::wstring& domain, const std::wstring& indent, CPluginFilter* filt er)
257 { 249 {
258 bool isHidden; 250 bool isHidden;
259 m_criticalSectionFilter.Lock(); 251 m_criticalSectionFilter.Lock();
260 { 252 {
261 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); 253 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent);
262 } 254 }
263 m_criticalSectionFilter.Unlock(); 255 m_criticalSectionFilter.Unlock();
264 return isHidden; 256 return isHidden;
265 } 257 }
266 258
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 DEBUG_GENERAL("CompareVersions"); 570 DEBUG_GENERAL("CompareVersions");
579 Communication::OutputBuffer request; 571 Communication::OutputBuffer request;
580 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2); 572 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2);
581 Communication::InputBuffer response; 573 Communication::InputBuffer response;
582 if (!CallEngine(request, response)) 574 if (!CallEngine(request, response))
583 return 0; 575 return 0;
584 int result; 576 int result;
585 response >> result; 577 response >> result;
586 return result; 578 return result;
587 } 579 }
OLDNEW
« no previous file with comments | « src/plugin/AdblockPlusClient.h ('k') | src/plugin/AdblockPlusDomTraverser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld