| LEFT | RIGHT | 
|    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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   58     static void Init() |   58     static void Init() | 
|   59     { |   59     { | 
|   60       // it's threadsafe since C++11 and it will be instantiated only once and |   60       // it's threadsafe since C++11 and it will be instantiated only once and | 
|   61       // destroyed at the application exit |   61       // destroyed at the application exit | 
|   62       static V8Initializer initializer; |   62       static V8Initializer initializer; | 
|   63     } |   63     } | 
|   64   }; |   64   }; | 
|   65 } |   65 } | 
|   66  |   66  | 
|   67 AdblockPlus::ScopedV8Isolate::ScopedV8Isolate() |   67 AdblockPlus::ScopedV8Isolate::ScopedV8Isolate() | 
|   68   : isolate(v8::Isolate::New()) |   68 { | 
|   69 { |   69   V8Initializer::Init(); | 
 |   70   isolate = v8::Isolate::New(); | 
|   70 } |   71 } | 
|   71  |   72  | 
|   72 AdblockPlus::ScopedV8Isolate::~ScopedV8Isolate() |   73 AdblockPlus::ScopedV8Isolate::~ScopedV8Isolate() | 
|   73 { |   74 { | 
|   74   isolate->Dispose(); |   75   isolate->Dispose(); | 
|   75   isolate = nullptr; |   76   isolate = nullptr; | 
|   76 } |   77 } | 
|   77  |   78  | 
|   78 AdblockPlus::JsEngine::JsEngine(const ScopedV8IsolatePtr& isolate) |   79 AdblockPlus::JsEngine::JsEngine(const ScopedV8IsolatePtr& isolate) | 
|   79   : isolate(isolate) |   80   : isolate(isolate) | 
|   80 { |   81 { | 
|   81 } |   82 } | 
|   82  |   83  | 
|   83 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo, cons
     t ScopedV8IsolatePtr& isolate) |   84 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo, cons
     t ScopedV8IsolatePtr& isolate) | 
|   84 { |   85 { | 
|   85   V8Initializer::Init(); |  | 
|   86   JsEnginePtr result(new JsEngine(isolate)); |   86   JsEnginePtr result(new JsEngine(isolate)); | 
|   87  |   87  | 
|   88   const v8::Locker locker(result->GetIsolate()); |   88   const v8::Locker locker(result->GetIsolate()); | 
|   89   const v8::Isolate::Scope isolateScope(result->GetIsolate()); |   89   const v8::Isolate::Scope isolateScope(result->GetIsolate()); | 
|   90   const v8::HandleScope handleScope(result->GetIsolate()); |   90   const v8::HandleScope handleScope(result->GetIsolate()); | 
|   91  |   91  | 
|   92   result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(), |   92   result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(), | 
|   93     v8::Context::New(result->GetIsolate()))); |   93     v8::Context::New(result->GetIsolate()))); | 
|   94   v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( |   94   v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( | 
|   95     result->GetIsolate(), *result->context)->Global(); |   95     result->GetIsolate(), *result->context)->Global(); | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  242  |  242  | 
|  243  |  243  | 
|  244 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,  |  244 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,  | 
|  245                                               AdblockPlus::JsValuePtr value) |  245                                               AdblockPlus::JsValuePtr value) | 
|  246 { |  246 { | 
|  247   if (!globalJsObject) |  247   if (!globalJsObject) | 
|  248     throw std::runtime_error("Global object cannot be null"); |  248     throw std::runtime_error("Global object cannot be null"); | 
|  249  |  249  | 
|  250   globalJsObject->SetProperty(name, value); |  250   globalJsObject->SetProperty(name, value); | 
|  251 } |  251 } | 
| LEFT | RIGHT |