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

Delta Between Two Patch Sets: src/FilterEngine.cpp

Issue 4578638519336960: Issue 1296 - Add SetUpdateAvailableCallback (Closed)
Left Patch Set: Created Sept. 18, 2014, 3:12 p.m.
Right Patch Set: Fix typo, only invoke callback when the updater passes a URL Created Sept. 19, 2014, 2:51 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
« no previous file with change/comment | « include/AdblockPlus/FilterEngine.h ('k') | test/FilterEngine.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 350
351 void FilterEngine::RemoveUpdateAvailableCallback() 351 void FilterEngine::RemoveUpdateAvailableCallback()
352 { 352 {
353 jsEngine->RemoveEventCallback("updateAvailable"); 353 jsEngine->RemoveEventCallback("updateAvailable");
354 } 354 }
355 355
356 void FilterEngine::UpdateAvailable( 356 void FilterEngine::UpdateAvailable(
357 FilterEngine::UpdateAvailableCallback callback, JsValueList& params) 357 FilterEngine::UpdateAvailableCallback callback, JsValueList& params)
358 { 358 {
359 callback(params[0]->AsString()); 359 if (params.size() >= 1 && !params[0]->IsNull())
Wladimir Palant 2014/09/18 19:44:17 I'd rather not crash if the JS code unexpectedly d
Felix Dahlke 2014/09/19 02:51:41 Knowing that the updater actually ensures a valid
360 callback(params[0]->AsString());
360 } 361 }
361 362
362 void FilterEngine::ForceUpdateCheck( 363 void FilterEngine::ForceUpdateCheck(
363 FilterEngine::UpdateCheckDoneCallback callback) 364 FilterEngine::UpdateCheckDoneCallback callback)
364 { 365 {
365 std::string eventName = "updateCheckDone"; 366 std::string eventName = "updateCheckDone";
366 eventName += ++updateCheckId; 367 eventName += ++updateCheckId;
367 368
368 jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::UpdateChec kDone, 369 jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::UpdateChec kDone,
369 this, eventName, callback, std::tr1::placeholders::_1)); 370 this, eventName, callback, std::tr1::placeholders::_1));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 403 }
403 404
404 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) 405 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
405 { 406 {
406 JsValueList params; 407 JsValueList params;
407 params.push_back(jsEngine->NewValue(v1)); 408 params.push_back(jsEngine->NewValue(v1));
408 params.push_back(jsEngine->NewValue(v2)); 409 params.push_back(jsEngine->NewValue(v2));
409 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); 410 JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
410 return func->Call(params)->AsInt(); 411 return func->Call(params)->AsInt();
411 } 412 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld