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

Side by Side Diff: src/FilterEngine.cpp

Issue 11018003: Filter changed callback (Closed)
Patch Set: Created June 18, 2013, 11:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« libadblockplus.gyp ('K') | « libadblockplus.gyp ('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 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 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/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <algorithm> 18 #include <algorithm>
19 #include <cctype> 19 #include <cctype>
20 #include <functional> 20 #include <functional>
21 #include <string> 21 #include <string>
22 22
23 #include <AdblockPlus/LogSystem.h>
Andrey Novikov 2013/06/18 11:48:28 Forgot to remove this :(
23 #include <AdblockPlus.h> 24 #include <AdblockPlus.h>
24 #include "JsContext.h" 25 #include "JsContext.h"
25 #include "Thread.h" 26 #include "Thread.h"
26 27
27 using namespace AdblockPlus; 28 using namespace AdblockPlus;
28 29
29 extern std::string jsSources[]; 30 extern std::string jsSources[];
30 31
31 Filter::Filter(JsValuePtr value) 32 Filter::Filter(JsValuePtr value)
32 : JsValue(value) 33 : JsValue(value)
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 func->Call(params); 271 func->Call(params);
271 } 272 }
272 273
273 void FilterEngine::UpdateCheckDone(const std::string& eventName, FilterEngine::U pdaterCallback callback, JsValueList& params) 274 void FilterEngine::UpdateCheckDone(const std::string& eventName, FilterEngine::U pdaterCallback callback, JsValueList& params)
274 { 275 {
275 jsEngine->RemoveEventCallback(eventName); 276 jsEngine->RemoveEventCallback(eventName);
276 277
277 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt ring() : ""); 278 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt ring() : "");
278 callback(error); 279 callback(error);
279 } 280 }
281
282 void FilterEngine::SetFilterChangeCallback(FilterEngine::FilterChangeCallback ca llback)
283 {
284 std::string eventName = "filterChange";
Wladimir Palant 2013/06/18 15:02:15 The event name isn't dynamic, no real point passin
285
286 if (callback == 0)
287 jsEngine->RemoveEventCallback(eventName);
288 else
289 jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::FilterCh anged,
290 this, eventName, callback, std::tr1::placeholders::_1));
291 }
292
293 void FilterEngine::FilterChanged(const std::string& eventName, FilterEngine::Fil terChangeCallback callback, JsValueList& params)
294 {
295 AdblockPlus::LogSystemPtr log = jsEngine->GetLogSystem();
Andrey Novikov 2013/06/18 11:48:28 Forgot to remove this :(
296 std::string url(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsStri ng() : "");
297 std::string status(params.size() >= 2 && !params[1]->IsNull() ? params[1]->AsS tring() : "");
298 int64_t time(params.size() >= 3 && !params[2]->IsNull() ? params[2]->AsInt() : 0);
299 callback(url, status, time);
300 }
OLDNEW
« libadblockplus.gyp ('K') | « libadblockplus.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld