OLD | NEW |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 29 matching lines...) Expand all Loading... |
40 return v8::Script::Compile(isolate->GetCurrentContext(), v8Source); | 40 return v8::Script::Compile(isolate->GetCurrentContext(), v8Source); |
41 } | 41 } |
42 | 42 |
43 class V8Initializer | 43 class V8Initializer |
44 { | 44 { |
45 V8Initializer() | 45 V8Initializer() |
46 : platform{nullptr} | 46 : platform{nullptr} |
47 { | 47 { |
48 std::string cmd = "--use_strict"; | 48 std::string cmd = "--use_strict"; |
49 v8::V8::SetFlagsFromString(cmd.c_str(), cmd.length()); | 49 v8::V8::SetFlagsFromString(cmd.c_str(), cmd.length()); |
50 platform = v8::platform::CreateDefaultPlatform(); | 50 platform = v8::platform::NewDefaultPlatform(); |
51 v8::V8::InitializePlatform(platform); | 51 v8::V8::InitializePlatform(platform.get()); |
52 v8::V8::Initialize(); | 52 v8::V8::Initialize(); |
53 } | 53 } |
54 | 54 |
55 ~V8Initializer() | 55 ~V8Initializer() |
56 { | 56 { |
57 v8::V8::Dispose(); | 57 v8::V8::Dispose(); |
58 v8::V8::ShutdownPlatform(); | 58 v8::V8::ShutdownPlatform(); |
59 delete platform; | |
60 } | 59 } |
61 v8::Platform* platform; | 60 std::unique_ptr<v8::Platform> platform; |
62 public: | 61 public: |
63 static void Init() | 62 static void Init() |
64 { | 63 { |
65 // it's threadsafe since C++11 and it will be instantiated only once and | 64 // it's threadsafe since C++11 and it will be instantiated only once and |
66 // destroyed at the application exit | 65 // destroyed at the application exit |
67 static V8Initializer initializer; | 66 static V8Initializer initializer; |
68 } | 67 } |
69 }; | 68 }; |
70 | 69 |
71 /** | 70 /** |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 list.push_back(JsValue(shared_from_this(), arguments[i])); | 334 list.push_back(JsValue(shared_from_this(), arguments[i])); |
336 return list; | 335 return list; |
337 } | 336 } |
338 | 337 |
339 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 338 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
340 const AdblockPlus::JsValue& value) | 339 const AdblockPlus::JsValue& value) |
341 { | 340 { |
342 auto global = GetGlobalObject(); | 341 auto global = GetGlobalObject(); |
343 global.SetProperty(name, value); | 342 global.SetProperty(name, value); |
344 } | 343 } |
OLD | NEW |