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

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

Issue 29377570: Issue 4931 - add possibility to not send data depending on connection properties (Closed)
Patch Set: Created Feb. 28, 2017, 2:22 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-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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 friend class JsValue; 81 friend class JsValue;
82 friend class JsContext; 82 friend class JsContext;
83 83
84 public: 84 public:
85 /** 85 /**
86 * Event callback function. 86 * Event callback function.
87 */ 87 */
88 typedef std::function<void(JsValueList& params)> EventCallback; 88 typedef std::function<void(JsValueList& params)> EventCallback;
89 89
90 /** 90 /**
91 * Callback function returning false when current connection is not allowed
92 * e.g. because it is a metered connection.
93 */
94 typedef std::function<bool()> IsConnectionAllowedCallback;
95
96 /**
91 * Maps events to callback functions. 97 * Maps events to callback functions.
92 */ 98 */
93 typedef std::map<std::string, EventCallback> EventMap; 99 typedef std::map<std::string, EventCallback> EventMap;
94 100
95 /** 101 /**
96 * Creates a new JavaScript engine instance. 102 * Creates a new JavaScript engine instance.
97 * @param appInfo Information about the app. 103 * @param appInfo Information about the app.
98 * @param isolate v8::Isolate wrapper. This parameter should be considered 104 * @param isolate v8::Isolate wrapper. This parameter should be considered
99 * as a temporary hack for tests, it will go away. Issue #3593. 105 * as a temporary hack for tests, it will go away. Issue #3593.
100 * @return New `JsEngine` instance. 106 * @return New `JsEngine` instance.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 221
216 /** 222 /**
217 * Sets the `WebRequest` implementation used for XMLHttpRequests. 223 * Sets the `WebRequest` implementation used for XMLHttpRequests.
218 * Setting this is optional, the engine will use a `DefaultWebRequest` 224 * Setting this is optional, the engine will use a `DefaultWebRequest`
219 * instance by default, which might be sufficient. 225 * instance by default, which might be sufficient.
220 * @param The `WebRequest` instance to use. 226 * @param The `WebRequest` instance to use.
221 */ 227 */
222 void SetWebRequest(WebRequestPtr val); 228 void SetWebRequest(WebRequestPtr val);
223 229
224 /** 230 /**
231 * Registers the callback function to check whether current connection is
232 * allowed for network requests.
233 * @param callback callback function.
234 */
235 void SetIsConnectionAllowedCallback(const IsConnectionAllowedCallback& callb ack);
236
237 /**
238 * Checks whether current connection is allowed. If
239 * IsConnectionAllowedCallback is not set then then it returns true.
240 */
241 bool IsConnectionAllowed();
242
243 /**
225 * @see `SetLogSystem()`. 244 * @see `SetLogSystem()`.
226 */ 245 */
227 LogSystemPtr GetLogSystem(); 246 LogSystemPtr GetLogSystem();
228 247
229 /** 248 /**
230 * Sets the `LogSystem` implementation used for logging (e.g. to handle 249 * Sets the `LogSystem` implementation used for logging (e.g. to handle
231 * `console.log()` calls from JavaScript). 250 * `console.log()` calls from JavaScript).
232 * Setting this is optional, the engine will use a `DefaultLogSystem` 251 * Setting this is optional, the engine will use a `DefaultLogSystem`
233 * instance by default, which might be sufficient. 252 * instance by default, which might be sufficient.
234 * @param The `LogSystem` instance to use. 253 * @param The `LogSystem` instance to use.
(...skipping 22 matching lines...) Expand all
257 276
258 /// Isolate must be disposed only after disposing of all objects which are 277 /// Isolate must be disposed only after disposing of all objects which are
259 /// using it. 278 /// using it.
260 ScopedV8IsolatePtr isolate; 279 ScopedV8IsolatePtr isolate;
261 280
262 FileSystemPtr fileSystem; 281 FileSystemPtr fileSystem;
263 WebRequestPtr webRequest; 282 WebRequestPtr webRequest;
264 LogSystemPtr logSystem; 283 LogSystemPtr logSystem;
265 std::unique_ptr<v8::Persistent<v8::Context>> context; 284 std::unique_ptr<v8::Persistent<v8::Context>> context;
266 EventMap eventCallbacks; 285 EventMap eventCallbacks;
286 IsConnectionAllowedCallback isConnectionAllowed;
267 }; 287 };
268 } 288 }
269 289
270 #endif 290 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | lib/prefs.js » ('j') | src/WebRequestJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld