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 Aug. 7, 2014, 2:20 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 #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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 Communication::OutputBuffer request; 542 Communication::OutputBuffer request;
551 request << Communication::PROC_GET_HOST << ToUtf8String(url); 543 request << Communication::PROC_GET_HOST << ToUtf8String(url);
552 544
553 Communication::InputBuffer response; 545 Communication::InputBuffer response;
554 if (!CallEngine(request, response)) 546 if (!CallEngine(request, response))
555 return L""; 547 return L"";
556 std::string host; 548 std::string host;
557 response >> host; 549 response >> host;
558 return ToUtf16String(host); 550 return ToUtf16String(host);
559 } 551 }
OLDNEW

Powered by Google App Engine
This is Rietveld