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

Delta Between Two Patch Sets: src/GlobalJsObject.cpp

Issue 29451722: Issue 4907 - Update v8 to 5.7.278 in libadblockplus (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Left Patch Set: Created May 30, 2017, 3:02 p.m.
Right Patch Set: independence from file mode of make_gyp_wrapper.py Created July 4, 2017, 11:11 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/FileSystemJsObject.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 24 matching lines...) Expand all
35 { 35 {
36 void SetTimeoutCallback(const v8::FunctionCallbackInfo<v8::Value>& 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 Utils::ThrowException(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 } 51 }
52 52
53 void TriggerEventCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments ) 53 void TriggerEventCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments )
54 { 54 {
55 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments); 55 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments);
56 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); 56 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
57 if (converted.size() < 1) 57 if (converted.size() < 1)
58 { 58 {
59 v8::Isolate* isolate = arguments.GetIsolate(); 59 v8::Isolate* isolate = arguments.GetIsolate();
60 return Utils::ThrowException(isolate, "_triggerEvent expects at least one parameter"); 60 return Utils::ThrowExceptionInJS(isolate, "_triggerEvent expects at least one parameter");
61 } 61 }
62 std::string eventName = converted.front().AsString(); 62 std::string eventName = converted.front().AsString();
63 converted.erase(converted.cbegin()); 63 converted.erase(converted.cbegin());
64 jsEngine->TriggerEvent(eventName, move(converted)); 64 jsEngine->TriggerEvent(eventName, move(converted));
65 } 65 }
66 } 66 }
67 67
68 JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, 68 JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo,
69 JsValue& obj) 69 JsValue& obj)
70 { 70 {
71 obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); 71 obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback));
72 obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback)) ; 72 obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback)) ;
73 auto value = jsEngine.NewObject(); 73 auto value = jsEngine.NewObject();
74 obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value)); 74 obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value));
75 value = jsEngine.NewObject(); 75 value = jsEngine.NewObject();
76 obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value)); 76 obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value));
77 value = jsEngine.NewObject(); 77 value = jsEngine.NewObject();
78 obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value)); 78 obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value));
79 value = jsEngine.NewObject(); 79 value = jsEngine.NewObject();
80 obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value)); 80 obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value));
81 return obj; 81 return obj;
82 } 82 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld