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

Side by Side Diff: src/JsEngine.cpp

Issue 29422625: Issue 5189 - use r-value references when objects should be transferred (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created April 26, 2017, 2:14 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
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 std::lock_guard<std::mutex> lock(eventCallbacksMutex); 180 std::lock_guard<std::mutex> lock(eventCallbacksMutex);
181 eventCallbacks[eventName] = callback; 181 eventCallbacks[eventName] = callback;
182 } 182 }
183 183
184 void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName) 184 void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName)
185 { 185 {
186 std::lock_guard<std::mutex> lock(eventCallbacksMutex); 186 std::lock_guard<std::mutex> lock(eventCallbacksMutex);
187 eventCallbacks.erase(eventName); 187 eventCallbacks.erase(eventName);
188 } 188 }
189 189
190 void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, const Adb lockPlus::JsValueList& params) 190 void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, AdblockPl us::JsValueList&& params)
191 { 191 {
192 EventCallback callback; 192 EventCallback callback;
193 { 193 {
194 std::lock_guard<std::mutex> lock(eventCallbacksMutex); 194 std::lock_guard<std::mutex> lock(eventCallbacksMutex);
195 auto it = eventCallbacks.find(eventName); 195 auto it = eventCallbacks.find(eventName);
196 if (it == eventCallbacks.end()) 196 if (it == eventCallbacks.end())
197 return; 197 return;
198 callback = it->second; 198 callback = it->second;
199 } 199 }
200 callback(params); 200 callback(move(params));
201 } 201 }
202 202
203 void AdblockPlus::JsEngine::Gc() 203 void AdblockPlus::JsEngine::Gc()
204 { 204 {
205 while (!v8::V8::IdleNotification()); 205 while (!v8::V8::IdleNotification());
206 } 206 }
207 207
208 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val) 208 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val)
209 { 209 {
210 const JsContext context(*this); 210 const JsContext context(*this);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 logSystem = val; 323 logSystem = val;
324 } 324 }
325 325
326 326
327 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, 327 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
328 const AdblockPlus::JsValue& value) 328 const AdblockPlus::JsValue& value)
329 { 329 {
330 auto global = GetGlobalObject(); 330 auto global = GetGlobalObject();
331 global.SetProperty(name, value); 331 global.SetProperty(name, value);
332 } 332 }
OLDNEW
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld