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

Side by Side Diff: src/GlobalJsObject.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 12, 2017, 3:24 p.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 51 return v8::Undefined();
52 } 52 }
53 53
54 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments) 54 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments)
55 { 55 {
56 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments); 56 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments);
57 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); 57 AdblockPlus::JsConstValueList converted = jsEngine->ConvertArguments(argumen ts);
58 if (converted.size() < 1) 58 if (converted.size() < 1)
59 { 59 {
60 v8::Isolate* isolate = arguments.GetIsolate(); 60 v8::Isolate* isolate = arguments.GetIsolate();
61 return v8::ThrowException(Utils::ToV8String(isolate, 61 return v8::ThrowException(Utils::ToV8String(isolate,
62 "_triggerEvent expects at least one parameter")); 62 "_triggerEvent expects at least one parameter"));
63 } 63 }
64 std::string eventName = converted.front()->AsString(); 64 std::string eventName = converted.front()->AsString();
65 converted.erase(converted.begin()); 65 converted.erase(converted.begin());
66 jsEngine->TriggerEvent(eventName, converted); 66 jsEngine->TriggerEvent(eventName, converted);
67 return v8::Undefined(); 67 return v8::Undefined();
68 } 68 }
69 } 69 }
70 70
71 JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, 71 JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo,
72 const JsValuePtr& obj) 72 const JsValuePtr& obj)
73 { 73 {
74 obj->SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); 74 obj->SetProperty("setTimeout", *jsEngine.NewCallback(::SetTimeoutCallback));
75 obj->SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback) ); 75 obj->SetProperty("_triggerEvent", *jsEngine.NewCallback(::TriggerEventCallback ));
76 obj->SetProperty("_fileSystem", 76 obj->SetProperty("_fileSystem",
77 FileSystemJsObject::Setup(jsEngine, jsEngine.NewObject())); 77 FileSystemJsObject::Setup(jsEngine, *jsEngine.NewObject()));
78 obj->SetProperty("_webRequest", 78 obj->SetProperty("_webRequest",
79 WebRequestJsObject::Setup(jsEngine, jsEngine.NewObject())); 79 WebRequestJsObject::Setup(jsEngine, *jsEngine.NewObject()));
80 obj->SetProperty("console", 80 obj->SetProperty("console",
81 ConsoleJsObject::Setup(jsEngine, jsEngine.NewObject())); 81 ConsoleJsObject::Setup(jsEngine, *jsEngine.NewObject()));
82 obj->SetProperty("_appInfo", 82 obj->SetProperty("_appInfo",
83 AppInfoJsObject::Setup(appInfo, jsEngine.NewObject())); 83 AppInfoJsObject::Setup(appInfo, *jsEngine.NewObject()));
84 return obj; 84 return obj;
85 } 85 }
OLDNEW
« src/FilterEngine.cpp ('K') | « src/FilterEngine.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld