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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include <AdblockPlus.h> | 18 #include <AdblockPlus.h> |
19 #include "FileSystemJsObject.h" | 19 #include "FileSystemJsObject.h" |
20 #include "GlobalJsObject.h" | 20 #include "GlobalJsObject.h" |
21 #include "JsContext.h" | 21 #include "JsContext.h" |
22 #include "JsEngineInternal.h" | 22 #include "JsEngineInternal.h" |
23 #include "JsEngineTransition.h" | 23 #include "JsEngineTransition.h" |
24 #include "JsError.h" | 24 #include "JsError.h" |
| 25 #include "Timeout.h" |
25 #include "Utils.h" | 26 #include "Utils.h" |
26 #include "WebRequestJsObject.h" | 27 #include "WebRequestJsObject.h" |
27 | 28 |
28 const ImmediateSingleUseThreadType ImmediateSingleUseThread = {}; | 29 const ImmediateSingleUseThreadType ImmediateSingleUseThread = {}; |
29 | 30 |
30 namespace | 31 namespace |
31 { | 32 { |
32 v8::Handle<v8::Script> CompileScript(v8::Isolate* isolate, | 33 v8::Handle<v8::Script> CompileScript(v8::Isolate* isolate, |
33 const std::string& source, const std::string& filename) | 34 const std::string& source, const std::string& filename) |
34 { | 35 { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 auto global = GetGlobalObject(); | 371 auto global = GetGlobalObject(); |
371 if (!global) | 372 if (!global) |
372 throw std::runtime_error("Global object cannot be null"); | 373 throw std::runtime_error("Global object cannot be null"); |
373 global->SetProperty(name, value); | 374 global->SetProperty(name, value); |
374 } | 375 } |
375 | 376 |
376 void JsEngineInternal::ScheduleTaskInternal(std::shared_ptr<TaskFunctionInterfac
e>&& body) | 377 void JsEngineInternal::ScheduleTaskInternal(std::shared_ptr<TaskFunctionInterfac
e>&& body) |
377 { | 378 { |
378 // The present version of the scheduler only does immediate and single-use | 379 // The present version of the scheduler only does immediate and single-use |
379 // It does not, however, detach threads like the legacy thread behavior did. | 380 // It does not, however, detach threads like the legacy thread behavior did. |
380 scheduler.Run(Task(this, std::move(body))); | 381 scheduler.Run(std::forward<std::shared_ptr<TaskFunctionInterface>>(body), |
| 382 shared_from_this()); |
381 } | 383 } |
382 | 384 |
383 void JsEngineInternal::WaitForQuietScheduler() | 385 void JsEngineInternal::WaitForQuietScheduler() |
384 { | 386 { |
| 387 scheduler.ShutDown(); |
385 scheduler.JoinAll(); | 388 scheduler.JoinAll(); |
386 } | 389 } |
387 | 390 |
388 JsEngineInternal* ToInternal(AdblockPlus::JsEnginePtr p) | 391 JsEngineInternal* ToInternal(AdblockPlus::JsEnginePtr p) |
389 { | 392 { |
390 return static_cast<JsEngineInternal*>(p.get()); | 393 return static_cast<JsEngineInternal*>(p.get()); |
391 } | 394 } |
392 | 395 |
393 JsEngineInternal* ToInternal(AdblockPlus::JsEngine* p) | 396 JsEngineInternal* ToInternal(AdblockPlus::JsEngine* p) |
394 { | 397 { |
395 return static_cast<JsEngineInternal*>(p); | 398 return static_cast<JsEngineInternal*>(p); |
396 } | 399 } |
OLD | NEW |