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

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

Issue 11012013: Hanging resolved (critical sections unlocking) (Closed)
Patch Set: Created June 14, 2013, 12:17 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/AdblockPlusDomTraverser.cpp ('k') | no next file » | 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 2
3 #include "PluginFilter.h" 3 #include "PluginFilter.h"
4 4
5 #if (defined PRODUCT_ADBLOCKPLUS) 5 #if (defined PRODUCT_ADBLOCKPLUS)
6 #include "PluginSettings.h" 6 #include "PluginSettings.h"
7 #include "PluginClient.h" 7 #include "PluginClient.h"
8 #include "PluginClientFactory.h" 8 #include "PluginClientFactory.h"
9 #endif 9 #endif
10 10
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 { 279 {
280 CComBSTR tagName; 280 CComBSTR tagName;
281 tagName.ToLower(); 281 tagName.ToLower();
282 hr = pEl->get_tagName(&tagName); 282 hr = pEl->get_tagName(&tagName);
283 if ((hr != S_OK) || (tagName != CComBSTR(m_tag))) 283 if ((hr != S_OK) || (tagName != CComBSTR(m_tag)))
284 { 284 {
285 return false; 285 return false;
286 } 286 }
287 } 287 }
288 288
289
290 // Check attributes 289 // Check attributes
291 for (std::vector<CFilterElementHideAttrSelector>::const_iterator attrIt = m_at tributeSelectors.begin(); 290 for (std::vector<CFilterElementHideAttrSelector>::const_iterator attrIt = m_at tributeSelectors.begin();
292 attrIt != m_attributeSelectors.end(); ++ attrIt) 291 attrIt != m_attributeSelectors.end(); ++ attrIt)
293 { 292 {
294 CString value; 293 CString value;
295 bool attrFound = false; 294 bool attrFound = false;
296 if (attrIt->m_type == CFilterElementHideAttrType::STYLE) 295 if (attrIt->m_type == CFilterElementHideAttrType::STYLE)
297 { 296 {
298 CComPtr<IHTMLStyle> pStyle; 297 CComPtr<IHTMLStyle> pStyle;
299 if (SUCCEEDED(pEl->get_style(&pStyle)) && pStyle) 298 if (SUCCEEDED(pEl->get_style(&pStyle)) && pStyle)
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT agsNamed::const_iterator> idItEnum = 550 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT agsNamed::const_iterator> idItEnum =
552 m_elementHideTagsId.equal_range(std::make_pair(tag, id)); 551 m_elementHideTagsId.equal_range(std::make_pair(tag, id));
553 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++) 552 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++)
554 { 553 {
555 if (idIt->second.IsMatchFilterElementHide(pEl)) 554 if (idIt->second.IsMatchFilterElementHide(pEl))
556 { 555 {
557 #ifdef ENABLE_DEBUG_RESULT 556 #ifdef ENABLE_DEBUG_RESULT
558 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second .m_filterText) 557 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second .m_filterText)
559 CPluginDebug::DebugResultHiding(tag, "id:" + id, idIt->second.m_filt erText); 558 CPluginDebug::DebugResultHiding(tag, "id:" + id, idIt->second.m_filt erText);
560 #endif 559 #endif
560 s_criticalSectionFilterMap.Unlock();
561 return true; 561 return true;
562 } 562 }
563 } 563 }
564 564
565 // Search general id 565 // Search general id
566 idItEnum = m_elementHideTagsId.equal_range(std::make_pair("", id)); 566 idItEnum = m_elementHideTagsId.equal_range(std::make_pair("", id));
567 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++) 567 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++)
568 { 568 {
569 if (idIt->second.IsMatchFilterElementHide(pEl)) 569 if (idIt->second.IsMatchFilterElementHide(pEl))
570 { 570 {
571 #ifdef ENABLE_DEBUG_RESULT 571 #ifdef ENABLE_DEBUG_RESULT
572 DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m _filterText) 572 DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m _filterText)
573 CPluginDebug::DebugResultHiding(tag, "id:" + id, idIt->second.m_filt erText); 573 CPluginDebug::DebugResultHiding(tag, "id:" + id, idIt->second.m_filt erText);
574 #endif 574 #endif
575 s_criticalSectionFilterMap.Unlock();
575 return true; 576 return true;
576 } 577 }
577 } 578 }
578 } 579 }
579 580
580 // Search tag/className filters 581 // Search tag/className filters
581 if (!classNames.IsEmpty()) 582 if (!classNames.IsEmpty())
582 { 583 {
583 int pos = 0; 584 int pos = 0;
584 CString className = classNames.Tokenize(L" \t\n\r", pos); 585 CString className = classNames.Tokenize(L" \t\n\r", pos);
585 while (pos >= 0) 586 while (pos >= 0)
586 { 587 {
587 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHid eTagsNamed::const_iterator> classItEnum = 588 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHid eTagsNamed::const_iterator> classItEnum =
588 m_elementHideTagsClass.equal_range(std::make_pair(tag, className)); 589 m_elementHideTagsClass.equal_range(std::make_pair(tag, className));
589 590
590 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++classIt) 591 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++classIt)
591 { 592 {
592 if (classIt->second.IsMatchFilterElementHide(pEl)) 593 if (classIt->second.IsMatchFilterElementHide(pEl))
593 { 594 {
594 #ifdef ENABLE_DEBUG_RESULT 595 #ifdef ENABLE_DEBUG_RESULT
595 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt ->second.m_filterText) 596 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt ->second.m_filterText)
596 CPluginDebug::DebugResultHiding(tag, "class:" + className, classIt ->second.m_filterText); 597 CPluginDebug::DebugResultHiding(tag, "class:" + className, classIt ->second.m_filterText);
597 #endif 598 #endif
599 s_criticalSectionFilterMap.Unlock();
598 return true; 600 return true;
599 } 601 }
600 } 602 }
601 603
602 // Search general class name 604 // Search general class name
603 classItEnum = m_elementHideTagsClass.equal_range(std::make_pair("", clas sName)); 605 classItEnum = m_elementHideTagsClass.equal_range(std::make_pair("", clas sName));
604 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++ classIt) 606 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++ classIt)
605 { 607 {
606 if (classIt->second.IsMatchFilterElementHide(pEl)) 608 if (classIt->second.IsMatchFilterElementHide(pEl))
607 { 609 {
608 #ifdef ENABLE_DEBUG_RESULT 610 #ifdef ENABLE_DEBUG_RESULT
609 DEBUG_HIDE_EL(indent + "HideEl::Found (?/class) filter:" + classIt-> second.m_filterText) 611 DEBUG_HIDE_EL(indent + "HideEl::Found (?/class) filter:" + classIt-> second.m_filterText)
610 CPluginDebug::DebugResultHiding(tag, "class:" + className, classIt ->second.m_filterText); 612 CPluginDebug::DebugResultHiding(tag, "class:" + className, classIt ->second.m_filterText);
611 #endif 613 #endif
614 s_criticalSectionFilterMap.Unlock();
612 return true; 615 return true;
613 } 616 }
614 } 617 }
615 618
616 // Next class name 619 // Next class name
617 className = classNames.Tokenize(L" \t\n\r", pos); 620 className = classNames.Tokenize(L" \t\n\r", pos);
618 } 621 }
619 } 622 }
620 623
621 // Search tag filters 624 // Search tag filters
622 std::pair<TFilterElementHideTags::const_iterator, TFilterElementHideTags::co nst_iterator> tagItEnum 625 std::pair<TFilterElementHideTags::const_iterator, TFilterElementHideTags::co nst_iterator> tagItEnum
623 = m_elementHideTags.equal_range(tag); 626 = m_elementHideTags.equal_range(tag);
624 for (TFilterElementHideTags::const_iterator tagIt = tagItEnum.first; tagIt ! = tagItEnum.second; ++ tagIt) 627 for (TFilterElementHideTags::const_iterator tagIt = tagItEnum.first; tagIt ! = tagItEnum.second; ++ tagIt)
625 { 628 {
626 if (tagIt->second.IsMatchFilterElementHide(pEl)) 629 if (tagIt->second.IsMatchFilterElementHide(pEl))
627 { 630 {
628 #ifdef ENABLE_DEBUG_RESULT 631 #ifdef ENABLE_DEBUG_RESULT
629 DEBUG_HIDE_EL(indent + "HideEl::Found (tag) filter:" + tagIt->second.m_f ilterText) 632 DEBUG_HIDE_EL(indent + "HideEl::Found (tag) filter:" + tagIt->second.m_f ilterText)
630 CPluginDebug::DebugResultHiding(tag, "-", tagIt->second.m_filterText); 633 CPluginDebug::DebugResultHiding(tag, "-", tagIt->second.m_filterText);
631 #endif 634 #endif
635 s_criticalSectionFilterMap.Unlock();
632 return true; 636 return true;
633 } 637 }
634 } 638 }
635 } 639 }
636 s_criticalSectionFilterMap.Unlock(); 640 s_criticalSectionFilterMap.Unlock();
637 641
638 return false; 642 return false;
639 } 643 }
640 644
641 bool CPluginFilter::LoadHideFilters(std::vector<std::string> filters) 645 bool CPluginFilter::LoadHideFilters(std::vector<std::string> filters)
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 if (pos > 0 && domain.GetLength() + pos == subdomain.GetLength()) 913 if (pos > 0 && domain.GetLength() + pos == subdomain.GetLength())
910 { 914 {
911 if (subdomain.GetAt(pos - 1) == '.') 915 if (subdomain.GetAt(pos - 1) == '.')
912 { 916 {
913 return true; 917 return true;
914 } 918 }
915 } 919 }
916 920
917 return false; 921 return false;
918 } 922 }
OLDNEW
« no previous file with comments | « src/plugin/AdblockPlusDomTraverser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld