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

Side by Side Diff: src/FilterEngine.cpp

Issue 29389580: Issue 1397 - FilterEngine::ForceUpdateCheck crashes when passed a 0 std::function (Closed)
Patch Set: Created March 20, 2017, 2:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/api.js ('k') | test/FilterEngine.cpp » ('j') | 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 <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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 492 }
493 493
494 void FilterEngine::UpdateAvailable( 494 void FilterEngine::UpdateAvailable(
495 FilterEngine::UpdateAvailableCallback callback, JsValueList& params) 495 FilterEngine::UpdateAvailableCallback callback, JsValueList& params)
496 { 496 {
497 if (params.size() >= 1 && !params[0]->IsNull()) 497 if (params.size() >= 1 && !params[0]->IsNull())
498 callback(params[0]->AsString()); 498 callback(params[0]->AsString());
499 } 499 }
500 500
501 void FilterEngine::ForceUpdateCheck( 501 void FilterEngine::ForceUpdateCheck(
502 FilterEngine::UpdateCheckDoneCallback callback) 502 const FilterEngine::UpdateCheckDoneCallback& callback)
503 { 503 {
504 std::string eventName = "_updateCheckDone";
505 eventName += ++updateCheckId;
506
507 jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDone ,
508 this, eventName, callback, std::placeholders::_1));
509
510 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck"); 504 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck");
511 JsValueList params; 505 JsValueList params;
512 params.push_back(jsEngine->NewValue(eventName)); 506 if (callback)
507 {
508 std::string eventName = "_updateCheckDone" + std::to_string(++updateCheckId) ;
509 jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDo ne,
510 this, eventName, callback, std::placeholders::_1));
511 params.push_back(jsEngine->NewValue(eventName));
512 }
513 func->Call(params); 513 func->Call(params);
514 } 514 }
515 515
516 void FilterEngine::UpdateCheckDone(const std::string& eventName, 516 void FilterEngine::UpdateCheckDone(const std::string& eventName,
517 FilterEngine::UpdateCheckDoneCallback callback, JsValueList& params) 517 FilterEngine::UpdateCheckDoneCallback callback, JsValueList& params)
518 { 518 {
519 jsEngine->RemoveEventCallback(eventName); 519 jsEngine->RemoveEventCallback(eventName);
520 520
521 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt ring() : ""); 521 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt ring() : "");
522 callback(error); 522 callback(error);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 604 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
605 if (filter) 605 if (filter)
606 { 606 {
607 return filter; 607 return filter;
608 } 608 }
609 currentUrl = parentUrl; 609 currentUrl = parentUrl;
610 } 610 }
611 while (urlIterator != documentUrls.end()); 611 while (urlIterator != documentUrls.end());
612 return FilterPtr(); 612 return FilterPtr();
613 } 613 }
OLDNEW
« no previous file with comments | « lib/api.js ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld