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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29377570: Issue 4931 - add possibility to not send data depending on connection properties (Closed)
Patch Set: address comment Created March 16, 2017, 2:38 p.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
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | lib/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/JsEngine.h
diff --git a/include/AdblockPlus/JsEngine.h b/include/AdblockPlus/JsEngine.h
index 3f43388620da169d6b457b4e8ef35caaadea1605..02981488444a28021431447a13b3b79e6fa098c8 100644
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -23,6 +23,7 @@
#include <stdexcept>
#include <stdint.h>
#include <string>
+#include <mutex>
#include <AdblockPlus/AppInfo.h>
#include <AdblockPlus/LogSystem.h>
#include <AdblockPlus/FileSystem.h>
@@ -88,6 +89,12 @@ namespace AdblockPlus
typedef std::function<void(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;
+
+ /**
* Maps events to callback functions.
*/
typedef std::map<std::string, EventCallback> EventMap;
@@ -222,6 +229,19 @@ namespace AdblockPlus
void SetWebRequest(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);
+
+ /**
+ * Checks whether current connection is allowed. If
+ * IsConnectionAllowedCallback is not set then then it returns true.
+ */
+ bool IsConnectionAllowed();
+
+ /**
* @see `SetLogSystem()`.
*/
LogSystemPtr GetLogSystem();
@@ -264,6 +284,8 @@ namespace AdblockPlus
LogSystemPtr logSystem;
std::unique_ptr<v8::Persistent<v8::Context>> context;
EventMap eventCallbacks;
+ std::mutex isConnectionAllowedMutex;
+ IsConnectionAllowedCallback isConnectionAllowed;
};
}
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld