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

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

Issue 10420020: Made sure FilterEngine instances are always initialized (Closed)
Patch Set: Created May 16, 2013, 2:27 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 | « include/AdblockPlus/FilterEngine.h ('k') | include/AdblockPlus/tr1_functional.h » ('j') | no next file with comments »
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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 <stdexcept> 21 #include <stdexcept>
22 #include <stdint.h> 22 #include <stdint.h>
23 #include <string> 23 #include <string>
24 #include <v8.h> 24 #include <v8.h>
25 #include <AdblockPlus/AppInfo.h> 25 #include <AdblockPlus/AppInfo.h>
26 #include <AdblockPlus/tr1_functional.h>
26 #include <AdblockPlus/LogSystem.h> 27 #include <AdblockPlus/LogSystem.h>
27 #include <AdblockPlus/FileSystem.h> 28 #include <AdblockPlus/FileSystem.h>
28 #include <AdblockPlus/JsValue.h> 29 #include <AdblockPlus/JsValue.h>
29 #include <AdblockPlus/WebRequest.h> 30 #include <AdblockPlus/WebRequest.h>
30 31
31 #include "tr1_memory.h" 32 #include "tr1_memory.h"
32 33
33 namespace AdblockPlus 34 namespace AdblockPlus
34 { 35 {
35 class JsError : public std::runtime_error 36 class JsError : public std::runtime_error
36 { 37 {
37 public: 38 public:
38 JsError(const v8::Handle<v8::Value> exception, 39 JsError(const v8::Handle<v8::Value> exception,
39 const v8::Handle<v8::Message> message); 40 const v8::Handle<v8::Message> message);
40 }; 41 };
41 42
42 class JsEngine; 43 class JsEngine;
43 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; 44 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr;
44 45
45 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> 46 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine>
46 { 47 {
47 friend class JsValue; 48 friend class JsValue;
48 49
49 public: 50 public:
51 typedef std::tr1::function<void()> InitCallback;
52
50 static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); 53 static JsEnginePtr New(const AppInfo& appInfo = AppInfo());
54 void SetInitCallback(InitCallback callback);
55 void InitDone(void);
51 JsValuePtr Evaluate(const std::string& source, 56 JsValuePtr Evaluate(const std::string& source,
52 const std::string& filename = ""); 57 const std::string& filename = "");
53 void Gc(); 58 void Gc();
54 JsValuePtr NewValue(const std::string& val); 59 JsValuePtr NewValue(const std::string& val);
55 JsValuePtr NewValue(int64_t val); 60 JsValuePtr NewValue(int64_t val);
56 JsValuePtr NewValue(bool val); 61 JsValuePtr NewValue(bool val);
57 inline JsValuePtr NewValue(const char* val) 62 inline JsValuePtr NewValue(const char* val)
58 { 63 {
59 return NewValue(std::string(val)); 64 return NewValue(std::string(val));
60 } 65 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 }; 98 };
94 99
95 private: 100 private:
96 JsEngine(); 101 JsEngine();
97 102
98 FileSystemPtr fileSystem; 103 FileSystemPtr fileSystem;
99 WebRequestPtr webRequest; 104 WebRequestPtr webRequest;
100 LogSystemPtr logSystem; 105 LogSystemPtr logSystem;
101 v8::Isolate* isolate; 106 v8::Isolate* isolate;
102 v8::Persistent<v8::Context> context; 107 v8::Persistent<v8::Context> context;
108 InitCallback initCallback;
103 }; 109 };
104 } 110 }
105 111
106 #endif 112 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | include/AdblockPlus/tr1_functional.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld