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

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

Issue 5163715573841920: Issue 768 - Switch from TR1 to C++11 (Closed)
Patch Set: Created July 11, 2014, 2: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
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef ADBLOCK_PLUS_JS_ENGINE_H 18 #ifndef ADBLOCK_PLUS_JS_ENGINE_H
19 #define ADBLOCK_PLUS_JS_ENGINE_H 19 #define ADBLOCK_PLUS_JS_ENGINE_H
20 20
21 #include <functional>
21 #include <map> 22 #include <map>
23 #include <memory>
22 #include <stdexcept> 24 #include <stdexcept>
23 #include <stdint.h> 25 #include <stdint.h>
24 #include <string> 26 #include <string>
25 #include <AdblockPlus/AppInfo.h> 27 #include <AdblockPlus/AppInfo.h>
26 #include <AdblockPlus/tr1_functional.h>
27 #include <AdblockPlus/LogSystem.h> 28 #include <AdblockPlus/LogSystem.h>
28 #include <AdblockPlus/FileSystem.h> 29 #include <AdblockPlus/FileSystem.h>
29 #include <AdblockPlus/JsValue.h> 30 #include <AdblockPlus/JsValue.h>
30 #include <AdblockPlus/WebRequest.h> 31 #include <AdblockPlus/WebRequest.h>
31 32
32 #include "tr1_memory.h"
33 #include "V8ValueHolder.h" 33 #include "V8ValueHolder.h"
34 34
35 namespace v8 35 namespace v8
36 { 36 {
37 class Arguments; 37 class Arguments;
38 class Isolate; 38 class Isolate;
39 class Value; 39 class Value;
40 class Context; 40 class Context;
41 template<class T> class Handle; 41 template<class T> class Handle;
42 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); 42 typedef Handle<Value>(*InvocationCallback)(const Arguments &args);
43 } 43 }
44 44
45 namespace AdblockPlus 45 namespace AdblockPlus
46 { 46 {
47 class JsEngine; 47 class JsEngine;
48 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; 48 typedef std::shared_ptr<JsEngine> JsEnginePtr;
49 49
50 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> 50 class JsEngine : public std::enable_shared_from_this<JsEngine>
51 { 51 {
52 friend class JsValue; 52 friend class JsValue;
53 friend class JsContext; 53 friend class JsContext;
54 54
55 public: 55 public:
56 typedef std::tr1::function<void(JsValueList& params)> EventCallback; 56 typedef std::function<void(JsValueList& params)> EventCallback;
57 typedef std::map<std::string, EventCallback> EventMap; 57 typedef std::map<std::string, EventCallback> EventMap;
58 58
59 static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); 59 static JsEnginePtr New(const AppInfo& appInfo = AppInfo());
60 void SetEventCallback(const std::string& eventName, EventCallback callback); 60 void SetEventCallback(const std::string& eventName, EventCallback callback);
61 void RemoveEventCallback(const std::string& eventName); 61 void RemoveEventCallback(const std::string& eventName);
62 void TriggerEvent(const std::string& eventName, JsValueList& params); 62 void TriggerEvent(const std::string& eventName, JsValueList& params);
63 JsValuePtr Evaluate(const std::string& source, 63 JsValuePtr Evaluate(const std::string& source,
64 const std::string& filename = ""); 64 const std::string& filename = "");
65 void Gc(); 65 void Gc();
66 JsValuePtr NewValue(const std::string& val); 66 JsValuePtr NewValue(const std::string& val);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 FileSystemPtr fileSystem; 98 FileSystemPtr fileSystem;
99 WebRequestPtr webRequest; 99 WebRequestPtr webRequest;
100 LogSystemPtr logSystem; 100 LogSystemPtr logSystem;
101 v8::Isolate* isolate; 101 v8::Isolate* isolate;
102 V8ValueHolder<v8::Context> context; 102 V8ValueHolder<v8::Context> context;
103 EventMap eventCallbacks; 103 EventMap eventCallbacks;
104 }; 104 };
105 } 105 }
106 106
107 #endif 107 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld