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

Delta Between Two Patch Sets: src/FilterEngine.cpp

Issue 29361562: Issue 3594 - remove circular references JsEngine-JsValue-JsEngine (Closed)
Left Patch Set: Created Nov. 3, 2016, 11:26 a.m.
Right Patch Set: temporary workaround for race condition Created Dec. 1, 2016, 10:26 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 else if (className == "ElemHideException") 47 else if (className == "ElemHideException")
48 return TYPE_ELEMHIDE_EXCEPTION; 48 return TYPE_ELEMHIDE_EXCEPTION;
49 else if (className == "CommentFilter") 49 else if (className == "CommentFilter")
50 return TYPE_COMMENT; 50 return TYPE_COMMENT;
51 else 51 else
52 return TYPE_INVALID; 52 return TYPE_INVALID;
53 } 53 }
54 54
55 bool Filter::IsListed() 55 bool Filter::IsListed()
56 { 56 {
57 JsContext context(m_jsEngine); 57 JsContext context(jsEngine);
58 JsValuePtr func = context.jsEngine().Evaluate("API.isListedFilter"); 58 JsValuePtr func = context.GetJsEngine().Evaluate("API.isListedFilter");
59 JsValueList params; 59 JsValueList params;
60 params.push_back(shared_from_this()); 60 params.push_back(shared_from_this());
61 return func->Call(params)->AsBool(); 61 return func->Call(params)->AsBool();
62 } 62 }
63 63
64 void Filter::AddToList() 64 void Filter::AddToList()
65 { 65 {
66 JsContext context(m_jsEngine); 66 JsContext context(jsEngine);
67 JsValuePtr func = context.jsEngine().Evaluate("API.addFilterToList"); 67 JsValuePtr func = context.GetJsEngine().Evaluate("API.addFilterToList");
68 JsValueList params; 68 JsValueList params;
69 params.push_back(shared_from_this()); 69 params.push_back(shared_from_this());
70 func->Call(params); 70 func->Call(params);
71 } 71 }
72 72
73 void Filter::RemoveFromList() 73 void Filter::RemoveFromList()
74 { 74 {
75 JsContext context(m_jsEngine); 75 JsContext context(jsEngine);
76 JsValuePtr func = context.jsEngine().Evaluate("API.removeFilterFromList"); 76 JsValuePtr func = context.GetJsEngine().Evaluate("API.removeFilterFromList");
77 JsValueList params; 77 JsValueList params;
78 params.push_back(shared_from_this()); 78 params.push_back(shared_from_this());
79 func->Call(params); 79 func->Call(params);
80 } 80 }
81 81
82 bool Filter::operator==(const Filter& filter) const 82 bool Filter::operator==(const Filter& filter) const
83 { 83 {
84 return GetProperty("text")->AsString() == filter.GetProperty("text")->AsString (); 84 return GetProperty("text")->AsString() == filter.GetProperty("text")->AsString ();
85 } 85 }
86 86
87 Subscription::Subscription(JsValue&& value) 87 Subscription::Subscription(JsValue&& value)
88 : JsValue(std::move(value)) 88 : JsValue(std::move(value))
89 { 89 {
90 if (!IsObject()) 90 if (!IsObject())
91 throw std::runtime_error("JavaScript value is not an object"); 91 throw std::runtime_error("JavaScript value is not an object");
92 } 92 }
93 93
94 bool Subscription::IsListed() 94 bool Subscription::IsListed()
95 { 95 {
96 JsContext context(m_jsEngine); 96 JsContext context(jsEngine);
97 JsValuePtr func = context.jsEngine().Evaluate("API.isListedSubscription"); 97 JsValuePtr func = context.GetJsEngine().Evaluate("API.isListedSubscription");
98 JsValueList params; 98 JsValueList params;
99 params.push_back(shared_from_this()); 99 params.push_back(shared_from_this());
100 return func->Call(params)->AsBool(); 100 return func->Call(params)->AsBool();
101 } 101 }
102 102
103 void Subscription::AddToList() 103 void Subscription::AddToList()
104 { 104 {
105 JsContext context(m_jsEngine); 105 JsContext context(jsEngine);
106 JsValuePtr func = context.jsEngine().Evaluate("API.addSubscriptionToList"); 106 JsValuePtr func = context.GetJsEngine().Evaluate("API.addSubscriptionToList");
107 JsValueList params; 107 JsValueList params;
108 params.push_back(shared_from_this()); 108 params.push_back(shared_from_this());
109 func->Call(params); 109 func->Call(params);
110 } 110 }
111 111
112 void Subscription::RemoveFromList() 112 void Subscription::RemoveFromList()
113 { 113 {
114 JsContext context(m_jsEngine); 114 JsContext context(jsEngine);
115 JsValuePtr func = context.jsEngine().Evaluate("API.removeSubscriptionFromList" ); 115 JsValuePtr func = context.GetJsEngine().Evaluate("API.removeSubscriptionFromLi st");
116 JsValueList params; 116 JsValueList params;
117 params.push_back(shared_from_this()); 117 params.push_back(shared_from_this());
118 func->Call(params); 118 func->Call(params);
119 } 119 }
120 120
121 void Subscription::UpdateFilters() 121 void Subscription::UpdateFilters()
122 { 122 {
123 JsContext context(m_jsEngine); 123 JsContext context(jsEngine);
124 JsValuePtr func = context.jsEngine().Evaluate("API.updateSubscription"); 124 JsValuePtr func = context.GetJsEngine().Evaluate("API.updateSubscription");
125 JsValueList params; 125 JsValueList params;
126 params.push_back(shared_from_this()); 126 params.push_back(shared_from_this());
127 func->Call(params); 127 func->Call(params);
128 } 128 }
129 129
130 bool Subscription::IsUpdating() 130 bool Subscription::IsUpdating()
131 { 131 {
132 JsContext context(m_jsEngine); 132 JsContext context(jsEngine);
133 JsValuePtr func = context.jsEngine().Evaluate("API.isSubscriptionUpdating"); 133 JsValuePtr func = context.GetJsEngine().Evaluate("API.isSubscriptionUpdating") ;
134 JsValueList params; 134 JsValueList params;
135 params.push_back(shared_from_this()); 135 params.push_back(shared_from_this());
136 JsValuePtr result = func->Call(params); 136 JsValuePtr result = func->Call(params);
137 return result->AsBool(); 137 return result->AsBool();
138 } 138 }
139 139
140 bool Subscription::operator==(const Subscription& subscription) const 140 bool Subscription::operator==(const Subscription& subscription) const
141 { 141 {
142 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring(); 142 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring();
143 } 143 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 514 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
515 if (filter) 515 if (filter)
516 { 516 {
517 return filter; 517 return filter;
518 } 518 }
519 currentUrl = parentUrl; 519 currentUrl = parentUrl;
520 } 520 }
521 while (urlIterator != documentUrls.end()); 521 while (urlIterator != documentUrls.end());
522 return FilterPtr(); 522 return FilterPtr();
523 } 523 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld