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

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

Issue 29369365: Issue #4692 - Rewrite `SetTimeout` facility to avoid `JsValuePtr` and `JsValueList`
Patch Set: Created Dec. 19, 2016, 10:24 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 | « no previous file | libadblockplus.gyp » ('j') | src/GlobalJsObject.cpp » ('J')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 typedef std::shared_ptr<ScopedV8Isolate> ScopedV8IsolatePtr; 75 typedef std::shared_ptr<ScopedV8Isolate> ScopedV8IsolatePtr;
76 76
77 struct ImmediateSingleUseThreadType {}; ///< Marker class for scheduling polic y 77 struct ImmediateSingleUseThreadType {}; ///< Marker class for scheduling polic y
78 extern const ImmediateSingleUseThreadType ImmediateSingleUseThread; ///< Dummy constant for scheduling policy 78 extern const ImmediateSingleUseThreadType ImmediateSingleUseThread; ///< Dummy constant for scheduling policy
79 79
80 /** 80 /**
81 * JavaScript engine used by `FilterEngine`, wraps v8. 81 * JavaScript engine used by `FilterEngine`, wraps v8.
82 */ 82 */
83 class JsEngine : public std::enable_shared_from_this<JsEngine> 83 class JsEngine : public std::enable_shared_from_this<JsEngine>
84 { 84 {
85 friend class JsValue;
86 friend class JsContext;
87
88 public: 85 public:
89 /** 86 /**
90 * Event callback function. 87 * Event callback function.
91 */ 88 */
92 typedef std::function<void(JsValueList& params)> EventCallback; 89 typedef std::function<void(JsValueList& params)> EventCallback;
93 90
94 /** 91 /**
95 * Maps events to callback functions. 92 * Maps events to callback functions.
96 */ 93 */
97 typedef std::map<std::string, EventCallback> EventMap; 94 typedef std::map<std::string, EventCallback> EventMap;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 void SetGlobalProperty(const std::string& name, AdblockPlus::JsValuePtr valu e); 263 void SetGlobalProperty(const std::string& name, AdblockPlus::JsValuePtr valu e);
267 264
268 /** 265 /**
269 * Returns a pointer to associated v8::Isolate. 266 * Returns a pointer to associated v8::Isolate.
270 */ 267 */
271 v8::Isolate* GetIsolate() 268 v8::Isolate* GetIsolate()
272 { 269 {
273 return isolate->Get(); 270 return isolate->Get();
274 } 271 }
275 272
276 private: 273 protected:
277 explicit JsEngine(const ScopedV8IsolatePtr& isolate); 274 explicit JsEngine(const ScopedV8IsolatePtr& isolate);
278 275
276 /**
277 * Retrieve the global object as a JsValuePtr
278 *
279 * \par Precondition
280 * - Requires a v8 execution scope already present
281 */
279 JsValuePtr GetGlobalObject(); 282 JsValuePtr GetGlobalObject();
280 283
281 /// Isolate must be disposed only after disposing of all objects which are 284 /// Isolate must be disposed only after disposing of all objects which are
282 /// using it. 285 /// using it.
283 ScopedV8IsolatePtr isolate; 286 ScopedV8IsolatePtr isolate;
284 287
285 FileSystemPtr fileSystem; 288 FileSystemPtr fileSystem;
286 WebRequestPtr webRequest; 289 WebRequestPtr webRequest;
287 LogSystemPtr logSystem; 290 LogSystemPtr logSystem;
288 std::unique_ptr<v8::Persistent<v8::Context>> context;
289 EventMap eventCallbacks; 291 EventMap eventCallbacks;
290 292
291 // Forward declaration for PImpl idiom 293 // Forward declaration for PImpl idiom
292 class SchedulerImpl; 294 class SchedulerImpl;
293 /** 295 /**
294 * Scheduler for tasks executed under the current engine. 296 * Scheduler for tasks executed under the current engine.
295 * 297 *
296 * \par Invariant 298 * \par Invariant
297 * `bool(scheduler)` is always true 299 * `bool(scheduler)` is always true
298 */ 300 */
299 std::unique_ptr<SchedulerImpl> scheduler; 301 std::unique_ptr<SchedulerImpl> scheduler;
300 }; 302 };
301 } 303 }
302 304
303 #endif 305 #endif
OLDNEW
« no previous file with comments | « no previous file | libadblockplus.gyp » ('j') | src/GlobalJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld