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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29409580: Issue 5013 - Make parameter const ref when applicable. (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Rebased Created April 12, 2017, 8:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/AdblockPlus/JsEngine.h
===================================================================
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -88,17 +88,17 @@
{
friend class JsValue;
friend class JsContext;
public:
/**
* Event callback function.
*/
- typedef std::function<void(JsValueList& params)> EventCallback;
+ typedef std::function<void(const JsValueList& params)> EventCallback;
/**
* Callback function returning false when current connection is not allowed
* e.g. because it is a metered connection.
*/
typedef std::function<bool()> IsConnectionAllowedCallback;
/**
@@ -119,30 +119,30 @@
const ScopedV8IsolatePtr& isolate = ScopedV8IsolatePtr(new ScopedV8Isolate()));
/**
* Registers the callback function for an event.
* @param eventName Event name. Note that this can be any string - it's a
* general purpose event handling mechanism.
* @param callback Event callback function.
*/
- void SetEventCallback(const std::string& eventName, EventCallback callback);
+ void SetEventCallback(const std::string& eventName, const EventCallback& callback);
/**
* Removes the callback function for an event.
* @param eventName Event name.
*/
void RemoveEventCallback(const std::string& eventName);
/**
* Triggers an event.
* @param eventName Event name.
* @param params Event parameters.
*/
- void TriggerEvent(const std::string& eventName, JsValueList& params);
+ void TriggerEvent(const std::string& eventName, const JsValueList& params);
/**
* Evaluates a JavaScript expression.
* @param source JavaScript expression to evaluate.
* @param filename Optional file name for the expression, used in error
* messages.
* @return Result of the evaluated expression.
*/
@@ -187,17 +187,17 @@
/**
* Creates a JavaScript function that invokes a C++ callback.
* @param callback C++ callback to invoke. The callback receives a
* `v8::Arguments` object and can use `FromArguments()` to retrieve
* the current `JsEngine`.
* @return New `JsValue` instance.
*/
- JsValuePtr NewCallback(v8::InvocationCallback callback);
+ JsValuePtr NewCallback(const v8::InvocationCallback& callback);
/**
* Returns a `JsEngine` instance contained in a `v8::Arguments` object.
* Use this in callbacks created via `NewCallback()` to retrieve the current
* `JsEngine`.
* @param arguments `v8::Arguments` object containing the `JsEngine`
* instance.
* @return `JsEngine` instance from `v8::Arguments`.
@@ -225,30 +225,30 @@
FileSystemPtr GetFileSystem() const;
/**
* Sets the `FileSystem` implementation used for all file I/O.
* Setting this is optional, the engine will use a `DefaultFileSystem`
* instance by default, which might be sufficient.
* @param The `FileSystem` instance to use.
*/
- void SetFileSystem(FileSystemPtr val);
+ void SetFileSystem(const FileSystemPtr& val);
/**
* @see `SetWebRequest()`.
*/
WebRequestPtr GetWebRequest() const;
/**
* Sets the `WebRequest` implementation used for XMLHttpRequests.
* Setting this is optional, the engine will use a `DefaultWebRequest`
* instance by default, which might be sufficient.
* @param The `WebRequest` instance to use.
*/
- void SetWebRequest(WebRequestPtr val);
+ void SetWebRequest(const WebRequestPtr& val);
/**
* Registers the callback function to check whether current connection is
* allowed for network requests.
* @param callback callback function.
*/
void SetIsConnectionAllowedCallback(const IsConnectionAllowedCallback& callback);
@@ -265,41 +265,41 @@
/**
* Sets the `LogSystem` implementation used for logging (e.g. to handle
* `console.log()` calls from JavaScript).
* Setting this is optional, the engine will use a `DefaultLogSystem`
* instance by default, which might be sufficient.
* @param The `LogSystem` instance to use.
*/
- void SetLogSystem(LogSystemPtr val);
+ void SetLogSystem(const LogSystemPtr& val);
/**
* Sets a global property that can be accessed by all the scripts.
* @param name Name of the property to set.
* @param value Value of the property to set.
*/
- void SetGlobalProperty(const std::string& name, AdblockPlus::JsValuePtr value);
+ void SetGlobalProperty(const std::string& name, const AdblockPlus::JsValuePtr& value);
/**
* Returns a pointer to associated v8::Isolate.
*/
v8::Isolate* GetIsolate()
{
return isolate->Get();
}
private:
struct TimerTask
{
~TimerTask();
std::vector<std::unique_ptr<v8::Persistent<v8::Value>>> arguments;
};
typedef std::list<TimerTask> TimerTasks;
- void CallTimerTask(TimerTasks::const_iterator timerTaskIterator);
+ void CallTimerTask(const TimerTasks::const_iterator& timerTaskIterator);
explicit JsEngine(const ScopedV8IsolatePtr& isolate, TimerPtr timer);
JsValuePtr GetGlobalObject();
/// Isolate must be disposed only after disposing of all objects which are
/// using it.
ScopedV8IsolatePtr isolate;

Powered by Google App Engine
This is Rietveld