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

Delta Between Two Patch Sets: src/JsEngine.cpp

Issue 29812649: Issue 6526 - *ToV8String() return MaybeLocal<> and check Call() return value (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created June 21, 2018, 11:17 p.m.
Right Patch Set: Wrap macro arguments in brackets. Created Aug. 6, 2018, 1:25 p.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/JsValue.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 JsContext context(*this); 184 JsContext context(*this);
185 return JsValue(shared_from_this(), context.GetV8Context()->Global()); 185 return JsValue(shared_from_this(), context.GetV8Context()->Global());
186 } 186 }
187 187
188 AdblockPlus::JsValue AdblockPlus::JsEngine::Evaluate(const std::string& source, 188 AdblockPlus::JsValue AdblockPlus::JsEngine::Evaluate(const std::string& source,
189 const std::string& filename) 189 const std::string& filename)
190 { 190 {
191 const JsContext context(*this); 191 const JsContext context(*this);
192 auto isolate = GetIsolate(); 192 auto isolate = GetIsolate();
193 const v8::TryCatch tryCatch(isolate); 193 const v8::TryCatch tryCatch(isolate);
194 auto script = CHECKED_TO_LOCAL( 194 auto script = CHECKED_TO_LOCAL_WITH_TRY_CATCH(
195 isolate, CompileScript(isolate, source, filename), tryCatch); 195 isolate, CompileScript(isolate, source, filename), tryCatch);
196 auto result = CHECKED_TO_LOCAL( 196 auto result = CHECKED_TO_LOCAL_WITH_TRY_CATCH(
197 isolate, script->Run(isolate->GetCurrentContext()), tryCatch); 197 isolate, script->Run(isolate->GetCurrentContext()), tryCatch);
198 return JsValue(shared_from_this(), result); 198 return JsValue(shared_from_this(), result);
199 } 199 }
200 200
201 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName, 201 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName,
202 const AdblockPlus::JsEngine::EventCallback& callback) 202 const AdblockPlus::JsEngine::EventCallback& callback)
203 { 203 {
204 if (!callback) 204 if (!callback)
205 { 205 {
206 RemoveEventCallback(eventName); 206 RemoveEventCallback(eventName);
(...skipping 23 matching lines...) Expand all
230 } 230 }
231 231
232 void AdblockPlus::JsEngine::Gc() 232 void AdblockPlus::JsEngine::Gc()
233 { 233 {
234 while (!GetIsolate()->IdleNotificationDeadline(1000)); 234 while (!GetIsolate()->IdleNotificationDeadline(1000));
235 } 235 }
236 236
237 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val) 237 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(const std::string& val)
238 { 238 {
239 const JsContext context(*this); 239 const JsContext context(*this);
240 auto maybeValue = Utils::ToV8String(GetIsolate(), val); 240 auto isolate = GetIsolate();
241 if (maybeValue.IsEmpty()) 241 return JsValue(shared_from_this(),
242 return JsValue(shared_from_this(), v8::Undefined(GetIsolate())); 242 CHECKED_TO_LOCAL(isolate, Utils::ToV8String(isolate, val)));
hub 2018/06/22 00:34:31 This is where I think we should break APIs to some
sergei 2018/06/22 06:57:46 Let's just use CHECKED_TO_LOCAL.
hub 2018/06/22 15:50:56 Done.
243 return JsValue(shared_from_this(), maybeValue.ToLocalChecked());
244 } 243 }
245 244
246 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(int64_t val) 245 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(int64_t val)
247 { 246 {
248 const JsContext context(*this); 247 const JsContext context(*this);
249 return JsValue(shared_from_this(), v8::Number::New(GetIsolate(), val)); 248 return JsValue(shared_from_this(), v8::Number::New(GetIsolate(), val));
250 } 249 }
251 250
252 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(bool val) 251 AdblockPlus::JsValue AdblockPlus::JsEngine::NewValue(bool val)
253 { 252 {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 list.push_back(JsValue(shared_from_this(), arguments[i])); 341 list.push_back(JsValue(shared_from_this(), arguments[i]));
343 return list; 342 return list;
344 } 343 }
345 344
346 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, 345 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
347 const AdblockPlus::JsValue& value) 346 const AdblockPlus::JsValue& value)
348 { 347 {
349 auto global = GetGlobalObject(); 348 auto global = GetGlobalObject();
350 global.SetProperty(name, value); 349 global.SetProperty(name, value);
351 } 350 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld