Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/JsEngine.cpp

Issue 29442722: Issue 3593 - stop sharing v8::Isolate among tests (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: address comments Created May 22, 2017, 8:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | test/BaseJsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | test/BaseJsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld