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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void JsEngine::CallTimerTask(const JsWeakValuesID& timerParamsID) | 118 void JsEngine::CallTimerTask(const JsWeakValuesID& timerParamsID) |
119 { | 119 { |
120 auto timerParams = TakeJsValues(timerParamsID); | 120 auto timerParams = TakeJsValues(timerParamsID); |
121 JsValue callback = std::move(timerParams[0]); | 121 JsValue callback = std::move(timerParams[0]); |
122 | 122 |
123 timerParams.erase(timerParams.begin()); // remove callback placeholder | 123 timerParams.erase(timerParams.begin()); // remove callback placeholder |
124 timerParams.erase(timerParams.begin()); // remove timeout param | 124 timerParams.erase(timerParams.begin()); // remove timeout param |
125 callback.Call(timerParams); | 125 callback.Call(timerParams); |
126 } | 126 } |
127 | 127 |
128 AdblockPlus::JsEngine::JsEngine(const ScopedV8IsolatePtr& isolate, | 128 AdblockPlus::JsEngine::JsEngine(TimerPtr timer, WebRequestPtr webRequest) |
129 TimerPtr timer, WebRequestPtr webRequest) | 129 : fileSystem(new DefaultFileSystem()) |
130 : isolate(isolate) | |
131 , fileSystem(new DefaultFileSystem()) | |
132 , logSystem(new DefaultLogSystem()) | 130 , logSystem(new DefaultLogSystem()) |
133 , timer(std::move(timer)) | 131 , timer(std::move(timer)) |
134 , webRequest(std::move(webRequest)) | 132 , webRequest(std::move(webRequest)) |
135 { | 133 { |
136 } | 134 } |
137 | 135 |
138 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo, | 136 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo, |
139 TimerPtr timer, WebRequestPtr webRequest, | 137 TimerPtr timer, WebRequestPtr webRequest) |
140 const ScopedV8IsolatePtr& isolate) | |
141 { | 138 { |
142 JsEnginePtr result(new JsEngine(isolate, std::move(timer), std::move(webReques
t))); | 139 JsEnginePtr result(new JsEngine(std::move(timer), std::move(webRequest))); |
143 | 140 |
144 const v8::Locker locker(result->GetIsolate()); | 141 const v8::Locker locker(result->GetIsolate()); |
145 const v8::Isolate::Scope isolateScope(result->GetIsolate()); | 142 const v8::Isolate::Scope isolateScope(result->GetIsolate()); |
146 const v8::HandleScope handleScope(result->GetIsolate()); | 143 const v8::HandleScope handleScope(result->GetIsolate()); |
147 | 144 |
148 result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(), | 145 result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(), |
149 v8::Context::New(result->GetIsolate()))); | 146 v8::Context::New(result->GetIsolate()))); |
150 auto global = result->GetGlobalObject(); | 147 auto global = result->GetGlobalObject(); |
151 AdblockPlus::GlobalJsObject::Setup(*result, appInfo, global); | 148 AdblockPlus::GlobalJsObject::Setup(*result, appInfo, global); |
152 return result; | 149 return result; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 logSystem = val; | 333 logSystem = val; |
337 } | 334 } |
338 | 335 |
339 | 336 |
340 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 337 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
341 const AdblockPlus::JsValue& value) | 338 const AdblockPlus::JsValue& value) |
342 { | 339 { |
343 auto global = GetGlobalObject(); | 340 auto global = GetGlobalObject(); |
344 global.SetProperty(name, value); | 341 global.SetProperty(name, value); |
345 } | 342 } |
OLD | NEW |