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