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

Delta Between Two Patch Sets: src/FilterEngine.cpp

Issue 29317074: Issue 2693 - Update adblockplus dependency (Closed)
Left Patch Set: address NITs Created July 2, 2015, 1:33 p.m.
Right Patch Set: rebase Created July 2, 2015, 1:37 p.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
« no previous file with change/comment | « libadblockplus.gyp ('k') | test/Notification.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 params.push_back(shared_from_this()); 127 params.push_back(shared_from_this());
128 JsValuePtr result = func->Call(params); 128 JsValuePtr result = func->Call(params);
129 return result->AsBool(); 129 return result->AsBool();
130 } 130 }
131 131
132 bool Subscription::operator==(const Subscription& subscription) const 132 bool Subscription::operator==(const Subscription& subscription) const
133 { 133 {
134 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring(); 134 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring();
135 } 135 }
136 136
137 FilterEngine::FilterEngine(JsEnginePtr jsEngine) 137 FilterEngine::FilterEngine(JsEnginePtr jsEngine,
138 const FilterEngine::Prefs& preconfiguredPrefs)
138 : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) 139 : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0)
139 { 140 {
140 jsEngine->SetEventCallback("_init", std::tr1::bind(&FilterEngine::InitDone, 141 jsEngine->SetEventCallback("_init", std::tr1::bind(&FilterEngine::InitDone,
141 this, std::tr1::placeholders::_1)); 142 this, std::tr1::placeholders::_1));
142 143
143 { 144 {
144 // Lock the JS engine while we are loading scripts, no timeouts should fire 145 // Lock the JS engine while we are loading scripts, no timeouts should fire
145 // until we are done. 146 // until we are done.
146 const JsContext context(jsEngine); 147 const JsContext context(jsEngine);
148
149 // Set the preconfigured prefs
150 JsValuePtr preconfiguredPrefsObject = jsEngine->NewObject();
151 for (FilterEngine::Prefs::const_iterator it = preconfiguredPrefs.begin();
152 it != preconfiguredPrefs.end(); it++)
153 {
154 preconfiguredPrefsObject->SetProperty(it->first, it->second);
155 }
156 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject) ;
157 // Load adblockplus scripts
147 for (int i = 0; !jsSources[i].empty(); i += 2) 158 for (int i = 0; !jsSources[i].empty(); i += 2)
148 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); 159 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
149 } 160 }
150 161
151 // TODO: This should really be implemented via a conditional variable 162 // TODO: This should really be implemented via a conditional variable
152 while (!initialized) 163 while (!initialized)
153 ::Sleep(10); 164 ::Sleep(10);
154 } 165 }
155 166
156 namespace 167 namespace
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 451
441 452
442 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) 453 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
443 { 454 {
444 JsValueList params; 455 JsValueList params;
445 params.push_back(jsEngine->NewValue(v1)); 456 params.push_back(jsEngine->NewValue(v1));
446 params.push_back(jsEngine->NewValue(v2)); 457 params.push_back(jsEngine->NewValue(v2));
447 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); 458 JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
448 return func->Call(params)->AsInt(); 459 return func->Call(params)->AsInt();
449 } 460 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld