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

Side by Side Diff: src/GlobalJsObject.cpp

Issue 29451722: Issue 4907 - Update v8 to 5.7.278 in libadblockplus (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: fix support of ARCH=ia32 Created June 2, 2017, 7:19 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
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 15 matching lines...) Expand all
26 #include "GlobalJsObject.h" 26 #include "GlobalJsObject.h"
27 #include "ConsoleJsObject.h" 27 #include "ConsoleJsObject.h"
28 #include "WebRequestJsObject.h" 28 #include "WebRequestJsObject.h"
29 #include "Thread.h" 29 #include "Thread.h"
30 #include "Utils.h" 30 #include "Utils.h"
31 31
32 using namespace AdblockPlus; 32 using namespace AdblockPlus;
33 33
34 namespace 34 namespace
35 { 35 {
36 v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments) 36 void SetTimeoutCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
37 { 37 {
38 try 38 try
39 { 39 {
40 AdblockPlus::JsEngine::ScheduleTimer(arguments); 40 AdblockPlus::JsEngine::ScheduleTimer(arguments);
41 } 41 }
42 catch (const std::exception& e) 42 catch (const std::exception& e)
43 { 43 {
44 v8::Isolate* isolate = arguments.GetIsolate(); 44 v8::Isolate* isolate = arguments.GetIsolate();
45 return v8::ThrowException(Utils::ToV8String(isolate, e.what())); 45 return Utils::ThrowExceptionInJS(isolate, e.what());
46 } 46 }
47 47
48 // We should actually return the timer ID here, which could be 48 // We should actually return the timer ID here, which could be
49 // used via clearTimeout(). But since we don't seem to need 49 // used via clearTimeout(). But since we don't seem to need
50 // clearTimeout(), we can save that for later. 50 // clearTimeout(), we can save that for later.
51 return v8::Undefined();
52 } 51 }
53 52
54 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments) 53 void TriggerEventCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments )
55 { 54 {
56 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments); 55 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments);
57 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); 56 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
58 if (converted.size() < 1) 57 if (converted.size() < 1)
59 { 58 {
60 v8::Isolate* isolate = arguments.GetIsolate(); 59 v8::Isolate* isolate = arguments.GetIsolate();
61 return v8::ThrowException(Utils::ToV8String(isolate, 60 return Utils::ThrowExceptionInJS(isolate, "_triggerEvent expects at least one parameter");
62 "_triggerEvent expects at least one parameter"));
63 } 61 }
64 std::string eventName = converted.front().AsString(); 62 std::string eventName = converted.front().AsString();
65 converted.erase(converted.cbegin()); 63 converted.erase(converted.cbegin());
66 jsEngine->TriggerEvent(eventName, move(converted)); 64 jsEngine->TriggerEvent(eventName, move(converted));
67 return v8::Undefined();
68 } 65 }
69 } 66 }
70 67
71 JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, 68 JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo,
72 JsValue& obj) 69 JsValue& obj)
73 { 70 {
74 obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); 71 obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback));
75 obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback)) ; 72 obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback)) ;
76 auto value = jsEngine.NewObject(); 73 auto value = jsEngine.NewObject();
77 obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value)); 74 obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value));
78 value = jsEngine.NewObject(); 75 value = jsEngine.NewObject();
79 obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value)); 76 obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value));
80 value = jsEngine.NewObject(); 77 value = jsEngine.NewObject();
81 obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value)); 78 obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value));
82 value = jsEngine.NewObject(); 79 value = jsEngine.NewObject();
83 obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value)); 80 obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value));
84 return obj; 81 return obj;
85 } 82 }
OLDNEW
« README.md ('K') | « src/FileSystemJsObject.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld