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 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 private: | 60 private: |
61 JsValuePtr function; | 61 JsValuePtr function; |
62 int delay; | 62 int delay; |
63 JsValueList functionArguments; | 63 JsValueList functionArguments; |
64 }; | 64 }; |
65 | 65 |
66 v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments) | 66 v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments) |
67 { | 67 { |
68 std::shared_ptr<TimeoutTask> timeoutTask; | 68 std::shared_ptr<TimeoutTask> timeoutTask; |
| 69 JsEnginePtr engine; |
69 try | 70 try |
70 { | 71 { |
| 72 engine = AdblockPlus::JsEngine::FromArguments(arguments); |
71 AdblockPlus::JsValueList converted = | 73 AdblockPlus::JsValueList converted = |
72 AdblockPlus::JsEngine::FromArguments(arguments) | 74 engine->ConvertArguments(arguments); |
73 ->ConvertArguments(arguments); | |
74 timeoutTask = std::make_shared<TimeoutTask>(converted); | 75 timeoutTask = std::make_shared<TimeoutTask>(converted); |
75 } | 76 } |
76 catch (const std::exception& e) | 77 catch (const std::exception& e) |
77 { | 78 { |
78 v8::Isolate* isolate = arguments.GetIsolate(); | 79 v8::Isolate* isolate = arguments.GetIsolate(); |
79 return v8::ThrowException(Utils::ToV8String(isolate, e.what())); | 80 return v8::ThrowException(Utils::ToV8String(isolate, e.what())); |
80 } | 81 } |
81 Scheduler::StartImmediatelyInSingleUseThread(MakeHeapFunction(timeoutTask)); | 82 StartImmediatelyInSingleUseDetachedThread(MakeHeapFunction(timeoutTask)); |
82 | 83 |
83 // We should actually return the timer ID here, which could be | 84 // We should actually return the timer ID here, which could be |
84 // used via clearTimeout(). But since we don't seem to need | 85 // used via clearTimeout(). But since we don't seem to need |
85 // clearTimeout(), we can save that for later. | 86 // clearTimeout(), we can save that for later. |
86 return v8::Undefined(); | 87 return v8::Undefined(); |
87 } | 88 } |
88 | 89 |
89 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments) | 90 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments) |
90 { | 91 { |
91 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); | 92 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); |
(...skipping 19 matching lines...) Expand all Loading... |
111 obj->SetProperty("_fileSystem", | 112 obj->SetProperty("_fileSystem", |
112 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject())); | 113 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject())); |
113 obj->SetProperty("_webRequest", | 114 obj->SetProperty("_webRequest", |
114 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject())); | 115 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject())); |
115 obj->SetProperty("console", | 116 obj->SetProperty("console", |
116 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject())); | 117 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject())); |
117 obj->SetProperty("_appInfo", | 118 obj->SetProperty("_appInfo", |
118 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject())); | 119 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject())); |
119 return obj; | 120 return obj; |
120 } | 121 } |
OLD | NEW |