OLD | NEW |
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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 { | 48 { |
49 } | 49 } |
50 | 50 |
51 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) | 51 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) |
52 { | 52 { |
53 JsEnginePtr result(new JsEngine()); | 53 JsEnginePtr result(new JsEngine()); |
54 | 54 |
55 const v8::Locker locker(result->isolate); | 55 const v8::Locker locker(result->isolate); |
56 const v8::HandleScope handleScope; | 56 const v8::HandleScope handleScope; |
57 | 57 |
58 result->context.reset(result->isolate, v8::Context::New(result->isolate)); | 58 result->context.reset(new v8::Persistent<v8::Context>(result->isolate, |
| 59 v8::Context::New(result->isolate))); |
59 v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( | 60 v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( |
60 result->isolate, result->context)->Global(); | 61 result->isolate, *result->context)->Global(); |
61 AdblockPlus::GlobalJsObject::Setup(result, appInfo, | 62 AdblockPlus::GlobalJsObject::Setup(result, appInfo, |
62 JsValuePtr(new JsValue(result, globalContext))); | 63 JsValuePtr(new JsValue(result, globalContext))); |
63 return result; | 64 return result; |
64 } | 65 } |
65 | 66 |
66 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc
e, | 67 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc
e, |
67 const std::string& filename) | 68 const std::string& filename) |
68 { | 69 { |
69 const JsContext context(shared_from_this()); | 70 const JsContext context(shared_from_this()); |
70 const v8::TryCatch tryCatch; | 71 const v8::TryCatch tryCatch; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return logSystem; | 196 return logSystem; |
196 } | 197 } |
197 | 198 |
198 void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val) | 199 void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val) |
199 { | 200 { |
200 if (!val) | 201 if (!val) |
201 throw std::runtime_error("LogSystem cannot be null"); | 202 throw std::runtime_error("LogSystem cannot be null"); |
202 | 203 |
203 logSystem = val; | 204 logSystem = val; |
204 } | 205 } |
OLD | NEW |