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

Side by Side Diff: include/AdblockPlus/FilterEngine.h

Issue 29409580: Issue 5013 - Make parameter const ref when applicable. (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 11, 2017, 1:58 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
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 */ 199 */
200 typedef std::function<void(const std::string&)> UpdateCheckDoneCallback; 200 typedef std::function<void(const std::string&)> UpdateCheckDoneCallback;
201 201
202 /** 202 /**
203 * Callback type invoked when the filters change. 203 * Callback type invoked when the filters change.
204 * The first parameter is the action event code (see 204 * The first parameter is the action event code (see
205 * [FilterNotifier.triggerListeners](https://adblockplus.org/jsdoc/adblockpl uscore/FilterNotifier.html#.triggerListeners) 205 * [FilterNotifier.triggerListeners](https://adblockplus.org/jsdoc/adblockpl uscore/FilterNotifier.html#.triggerListeners)
206 * for the full list). 206 * for the full list).
207 * The second parameter is the filter/subscription object affected, if any. 207 * The second parameter is the filter/subscription object affected, if any.
208 */ 208 */
209 typedef std::function<void(const std::string&, const JsValuePtr)> FilterChan geCallback; 209 typedef std::function<void(const std::string&, const JsValuePtr&)> FilterCha ngeCallback;
210 210
211 /** 211 /**
212 * Container of name-value pairs representing a set of preferences. 212 * Container of name-value pairs representing a set of preferences.
213 */ 213 */
214 typedef std::map<std::string, AdblockPlus::JsValuePtr> Prefs; 214 typedef std::map<std::string, AdblockPlus::JsValuePtr> Prefs;
215 215
216 /** 216 /**
217 * Callback type invoked when a new notification should be shown. 217 * Callback type invoked when a new notification should be shown.
218 * The parameter is the Notification object to be shown. 218 * The parameter is the Notification object to be shown.
219 */ 219 */
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 * @param pref Preference name. 428 * @param pref Preference name.
429 * @return Preference value, or `null` if it doesn't exist. 429 * @return Preference value, or `null` if it doesn't exist.
430 */ 430 */
431 JsValuePtr GetPref(const std::string& pref) const; 431 JsValuePtr GetPref(const std::string& pref) const;
432 432
433 /** 433 /**
434 * Sets a preference value. 434 * Sets a preference value.
435 * @param pref Preference name. 435 * @param pref Preference name.
436 * @param value New value of the preference. 436 * @param value New value of the preference.
437 */ 437 */
438 void SetPref(const std::string& pref, JsValuePtr value); 438 void SetPref(const std::string& pref, const JsValuePtr& value);
439 439
440 /** 440 /**
441 * Extracts the host from a URL. 441 * Extracts the host from a URL.
442 * @param url URL to extract the host from. 442 * @param url URL to extract the host from.
443 * @return Extracted host. 443 * @return Extracted host.
444 */ 444 */
445 std::string GetHostFromURL(const std::string& url) const; 445 std::string GetHostFromURL(const std::string& url) const;
446 446
447 /** 447 /**
448 * Sets the callback invoked when an application update becomes available. 448 * Sets the callback invoked when an application update becomes available.
449 * @param callback Callback to invoke. 449 * @param callback Callback to invoke.
450 */ 450 */
451 void SetUpdateAvailableCallback(UpdateAvailableCallback callback); 451 void SetUpdateAvailableCallback(const UpdateAvailableCallback& callback);
452 452
453 /** 453 /**
454 * Removes the callback invoked when an application update becomes 454 * Removes the callback invoked when an application update becomes
455 * available. 455 * available.
456 */ 456 */
457 void RemoveUpdateAvailableCallback(); 457 void RemoveUpdateAvailableCallback();
458 458
459 /** 459 /**
460 * Forces an immediate update check. 460 * Forces an immediate update check.
461 * `FilterEngine` will automatically check for updates in regular intervals, 461 * `FilterEngine` will automatically check for updates in regular intervals,
462 * so applications should only call this when the user triggers an update 462 * so applications should only call this when the user triggers an update
463 * check manually. 463 * check manually.
464 * @param callback Optional callback to invoke when the update check is 464 * @param callback Optional callback to invoke when the update check is
465 * finished. The string parameter will be empty when the update check 465 * finished. The string parameter will be empty when the update check
466 * succeeded, or contain an error message if it failed. 466 * succeeded, or contain an error message if it failed.
467 * Note that the callback will be invoked whether updates are 467 * Note that the callback will be invoked whether updates are
468 * available or not - to react to updates being available, use 468 * available or not - to react to updates being available, use
469 * `FilterEngine::SetUpdateAvailableCallback()`. 469 * `FilterEngine::SetUpdateAvailableCallback()`.
470 */ 470 */
471 void ForceUpdateCheck(const UpdateCheckDoneCallback& callback = UpdateCheckD oneCallback()); 471 void ForceUpdateCheck(const UpdateCheckDoneCallback& callback = UpdateCheckD oneCallback());
472 472
473 /** 473 /**
474 * Sets the callback invoked when the filters change. 474 * Sets the callback invoked when the filters change.
475 * @param callback Callback to invoke. 475 * @param callback Callback to invoke.
476 */ 476 */
477 void SetFilterChangeCallback(FilterChangeCallback callback); 477 void SetFilterChangeCallback(const FilterChangeCallback& callback);
478 478
479 /** 479 /**
480 * Removes the callback invoked when the filters change. 480 * Removes the callback invoked when the filters change.
481 */ 481 */
482 void RemoveFilterChangeCallback(); 482 void RemoveFilterChangeCallback();
483 483
484 /** 484 /**
485 * Stores the value indicating what connection types are allowed, it is 485 * Stores the value indicating what connection types are allowed, it is
486 * passed to CreateParameters::isConnectionAllowed callback. 486 * passed to CreateParameters::isConnectionAllowed callback.
487 * @param value Stored value. nullptr means removing of any previously 487 * @param value Stored value. nullptr means removing of any previously
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 JsEnginePtr jsEngine; 527 JsEnginePtr jsEngine;
528 bool firstRun; 528 bool firstRun;
529 int updateCheckId; 529 int updateCheckId;
530 static const std::map<ContentType, std::string> contentTypes; 530 static const std::map<ContentType, std::string> contentTypes;
531 531
532 explicit FilterEngine(const JsEnginePtr& jsEngine); 532 explicit FilterEngine(const JsEnginePtr& jsEngine);
533 533
534 FilterPtr CheckFilterMatch(const std::string& url, 534 FilterPtr CheckFilterMatch(const std::string& url,
535 ContentTypeMask contentTypeMask, 535 ContentTypeMask contentTypeMask,
536 const std::string& documentUrl) const; 536 const std::string& documentUrl) const;
537 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params) const; 537 void UpdateAvailable(const UpdateAvailableCallback& callback, const JsValueL ist& params) const;
538 void UpdateCheckDone(const std::string& eventName, 538 void UpdateCheckDone(const std::string& eventName,
539 UpdateCheckDoneCallback callback, JsValueList& params); 539 const UpdateCheckDoneCallback& callback, const JsValueL ist& params);
540 void FilterChanged(FilterChangeCallback callback, JsValueList& params) const ; 540 void FilterChanged(const FilterChangeCallback& callback, const JsValueList& params) const;
541 void ShowNotification(const ShowNotificationCallback& callback, 541 void ShowNotification(const ShowNotificationCallback& callback,
542 const JsValueList& params) const; 542 const JsValueList& params) const;
543 FilterPtr GetWhitelistingFilter(const std::string& url, 543 FilterPtr GetWhitelistingFilter(const std::string& url,
544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; 544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const;
545 FilterPtr GetWhitelistingFilter(const std::string& url, 545 FilterPtr GetWhitelistingFilter(const std::string& url,
546 ContentTypeMask contentTypeMask, 546 ContentTypeMask contentTypeMask,
547 const std::vector<std::string>& documentUrls) const; 547 const std::vector<std::string>& documentUrls) const;
548 }; 548 };
549 } 549 }
550 550
551 #endif 551 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld