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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 for (int i = 0; i < arguments.Length(); i++) | 98 for (int i = 0; i < arguments.Length(); i++) |
99 timerTaskInfoIterator->arguments.emplace_back(new v8::Persistent<v8::Value>(
GetIsolate(), arguments[i])); | 99 timerTaskInfoIterator->arguments.emplace_back(new v8::Persistent<v8::Value>(
GetIsolate(), arguments[i])); |
100 TimerTask retValue = { shared_from_this(), timerTaskInfoIterator }; | 100 TimerTask retValue = { shared_from_this(), timerTaskInfoIterator }; |
101 return retValue; | 101 return retValue; |
102 } | 102 } |
103 | 103 |
104 void JsEngine::CallTimerTask(TimerTaskInfos::const_iterator timerTaskInfoIterato
r) | 104 void JsEngine::CallTimerTask(TimerTaskInfos::const_iterator timerTaskInfoIterato
r) |
105 { | 105 { |
106 const JsContext context(shared_from_this()); | 106 const JsContext context(shared_from_this()); |
107 JsValue callback(shared_from_this(), v8::Local<v8::Value>::New(GetIsolate(), *
timerTaskInfoIterator->arguments[0])); | 107 JsValue callback(shared_from_this(), v8::Local<v8::Value>::New(GetIsolate(), *
timerTaskInfoIterator->arguments[0])); |
108 JsValueList callbackArgs; | 108 JsConstValueList callbackArgs; |
109 for (int i = 2; i < timerTaskInfoIterator->arguments.size(); i++) | 109 for (int i = 2; i < timerTaskInfoIterator->arguments.size(); i++) |
110 callbackArgs.emplace_back(new JsValue(shared_from_this(), | 110 callbackArgs.emplace_back(new JsValue(shared_from_this(), |
111 v8::Local<v8::Value>::New(GetIsolate(), *timerTaskInfoIterator->arguments[i]
))); | 111 v8::Local<v8::Value>::New(GetIsolate(), *timerTaskInfoIterator->arguments[i]
))); |
112 callback.Call(callbackArgs); | 112 callback.Call(callbackArgs); |
113 timerTaskInfos.erase(timerTaskInfoIterator); | 113 timerTaskInfos.erase(timerTaskInfoIterator); |
114 } | 114 } |
115 | 115 |
116 AdblockPlus::JsEngine::JsEngine(const ScopedV8IsolatePtr& isolate) | 116 AdblockPlus::JsEngine::JsEngine(const ScopedV8IsolatePtr& isolate) |
117 : isolate(isolate) | 117 : isolate(isolate) |
118 { | 118 { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 | 316 |
317 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 317 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
318 AdblockPlus::JsValuePtr value) | 318 AdblockPlus::JsValuePtr value) |
319 { | 319 { |
320 auto global = GetGlobalObject(); | 320 auto global = GetGlobalObject(); |
321 if (!global) | 321 if (!global) |
322 throw std::runtime_error("Global object cannot be null"); | 322 throw std::runtime_error("Global object cannot be null"); |
323 global->SetProperty(name, value); | 323 global->SetProperty(name, value); |
324 } | 324 } |
OLD | NEW |