 Issue 29594607:
  Issue 5143 - Convert ElemHideEmulation to C++  (Closed) 
  Base URL: https://hg.adblockplus.org/adblockpluscore/
    
  
    Issue 29594607:
  Issue 5143 - Convert ElemHideEmulation to C++  (Closed) 
  Base URL: https://hg.adblockplus.org/adblockpluscore/| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-present eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 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/>. | |
| 16 */ | |
| 17 | |
| 18 #pragma once | |
| 19 | |
| 20 #include <vector> | |
| 21 | |
| 22 #include "bindings/runtime.h" | |
| 23 #include "intrusive_ptr.h" | |
| 24 #include "filter/ElemHideBase.h" | |
| 25 | |
| 26 class _ElemHideEmulation_FilterList : public ref_counted | |
| 
sergei
2017/11/16 09:58:07
IMO it's not a good idea to have names starting wi
 
hub
2017/11/20 19:16:01
That was part of the "spec" but indeed it conflict
 | |
| 27 { | |
| 28 std::vector<ElemHideBasePtr> mFilters; | |
| 29 public: | |
| 30 size_t BINDINGS_EXPORTED GetFilterCount() const | |
| 31 { | |
| 32 return mFilters.size(); | |
| 33 } | |
| 34 ElemHideBase* BINDINGS_EXPORTED FilterAt(size_t idx) | |
| 35 { | |
| 36 return mFilters[idx].get(); | |
| 37 } | |
| 38 | |
| 39 void push_back(ElemHideBasePtr filter) | |
| 
sergei
2017/11/16 09:58:07
What about using r-value or l-value reference here
 
hub
2017/11/20 19:16:01
r-value is impossible: we don't want to move the v
 
sergei
2018/01/25 16:04:00
Acknowledged. Perhaps we should revisit such metho
 
hub
2018/01/25 19:05:26
Looking at the use case, move doesn't make sense h
 | |
| 40 { | |
| 41 mFilters.push_back(filter); | |
| 42 } | |
| 43 | |
| 44 }; | |
| 45 | |
| 46 class ElemHideEmulation : public ref_counted | |
| 47 { | |
| 48 StringMap<ElemHideBasePtr> mFilters; | |
| 49 | |
| 50 static ElemHideEmulation* mInstance; | |
| 51 | |
| 52 public: | |
| 53 static ElemHideEmulation* BINDINGS_EXPORTED GetInstance() | |
| 
sergei
2017/11/16 09:58:07
IMO the growth of usage of the singleton pattern i
 
hub
2017/11/20 19:16:00
yes.
 | |
| 54 { | |
| 55 return mInstance; | |
| 56 } | |
| 57 | |
| 58 void BINDINGS_EXPORTED Add(ElemHideBase&); | |
| 59 void BINDINGS_EXPORTED Remove(ElemHideBase&); | |
| 60 void BINDINGS_EXPORTED Clear(); | |
| 61 _ElemHideEmulation_FilterList* BINDINGS_EXPORTED GetRulesForDomain(DependentSt ring&); | |
| 62 }; | |
| OLD | NEW |