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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 10727002: Get rid of dependencies on v8.h in public header files (Closed)
Patch Set: Added helper class to make using v8 values via auto_ptr less awkward Created May 23, 2013, 4:08 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 | « no previous file | include/AdblockPlus/JsValue.h » ('j') | include/AdblockPlus/JsValue.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/JsEngine.h
===================================================================
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -17,41 +17,45 @@
#ifndef ADBLOCK_PLUS_JS_ENGINE_H
#define ADBLOCK_PLUS_JS_ENGINE_H
#include <map>
#include <stdexcept>
#include <stdint.h>
#include <string>
-#include <v8.h>
#include <AdblockPlus/AppInfo.h>
#include <AdblockPlus/tr1_functional.h>
#include <AdblockPlus/LogSystem.h>
#include <AdblockPlus/FileSystem.h>
#include <AdblockPlus/JsValue.h>
#include <AdblockPlus/WebRequest.h>
#include "tr1_memory.h"
+#include "V8ValueHolder.h"
+
+namespace v8
+{
+ class Arguments;
+ class Isolate;
+ class Context;
+ template <class T> class Handle;
Felix Dahlke 2013/05/24 15:45:41 I thought we agreed on "template<class T>" (no spa
+ template <class T> class Persistent;
+ typedef Handle<Value>(*InvocationCallback)(const Arguments &args);
+}
namespace AdblockPlus
{
- class JsError : public std::runtime_error
- {
- public:
- JsError(const v8::Handle<v8::Value> exception,
- const v8::Handle<v8::Message> message);
- };
-
class JsEngine;
typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr;
class JsEngine : public std::tr1::enable_shared_from_this<JsEngine>
{
friend class JsValue;
+ friend class JsContext;
public:
typedef std::tr1::function<void()> EventCallback;
typedef std::map<std::string, EventCallback> EventMap;
static JsEnginePtr New(const AppInfo& appInfo = AppInfo());
void SetEventCallback(const std::string& eventName, EventCallback callback);
void RemoveEventCallback(const std::string& eventName);
@@ -83,33 +87,21 @@ namespace AdblockPlus
FileSystemPtr GetFileSystem();
void SetFileSystem(FileSystemPtr val);
WebRequestPtr GetWebRequest();
void SetWebRequest(WebRequestPtr val);
LogSystemPtr GetLogSystem();
void SetLogSystem(LogSystemPtr val);
- class Context
- {
- public:
- Context(const JsEnginePtr jsEngine);
- virtual inline ~Context() {};
-
- private:
- const v8::Locker locker;
- const v8::HandleScope handleScope;
- const v8::Context::Scope contextScope;
- };
-
private:
JsEngine();
FileSystemPtr fileSystem;
WebRequestPtr webRequest;
LogSystemPtr logSystem;
v8::Isolate* isolate;
- v8::Persistent<v8::Context> context;
+ V8ValueHolder<v8::Context> context;
EventMap eventCallbacks;
};
}
#endif
« no previous file with comments | « no previous file | include/AdblockPlus/JsValue.h » ('j') | include/AdblockPlus/JsValue.h » ('J')

Powered by Google App Engine
This is Rietveld