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

Side by Side Diff: src/FileSystemJsObject.cpp

Issue 29812649: Issue 6526 - *ToV8String() return MaybeLocal<> and check Call() return value (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added tests. Renamed CHECKED_TO_LOCAL. Created July 11, 2018, 2:10 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
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/Utils.h » ('J')
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-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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 throw std::runtime_error("`this` pointer has to be an object"); 180 throw std::runtime_error("`this` pointer has to be an object");
181 181
182 auto isolate = jsEngine->GetIsolate(); 182 auto isolate = jsEngine->GetIsolate();
183 const v8::TryCatch tryCatch(isolate); 183 const v8::TryCatch tryCatch(isolate);
184 const auto contentEnd = content.cend(); 184 const auto contentEnd = content.cend();
185 auto stringBegin = SkipEndOfLine(content.begin(), contentEnd); 185 auto stringBegin = SkipEndOfLine(content.begin(), contentEnd);
186 auto v8Context = isolate->GetCurrentContext(); 186 auto v8Context = isolate->GetCurrentContext();
187 do 187 do
188 { 188 {
189 auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd); 189 auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd);
190 auto jsLine = Utils::StringBufferToV8String(isolate, StringBuffe r(stringBegin, stringEnd)).As<v8::Value>(); 190 auto jsLine = CHECKED_TO_LOCAL_WITH_TRY_CATCH(
191 processFunc->Call(v8Context, globalContext, 1, &jsLine); 191 isolate,
192 if (tryCatch.HasCaught()) 192 Utils::StringBufferToV8String(
193 throw JsError(isolate, tryCatch.Exception(), tryCatch.Message( )); 193 isolate, StringBuffer(stringBegin, stringEnd)),
194 tryCatch).As<v8::Value>();
195
196 CHECKED_TO_LOCAL_WITH_TRY_CATCH(
197 isolate, processFunc->Call(v8Context, globalContext, 1, &jsLin e),
198 tryCatch);
199
194 stringBegin = SkipEndOfLine(stringEnd, contentEnd); 200 stringBegin = SkipEndOfLine(stringEnd, contentEnd);
195 } while (stringBegin != contentEnd); 201 } while (stringBegin != contentEnd);
196 jsEngine->GetJsValues(weakData->weakResolveCallback)[0].Call(); 202 jsEngine->GetJsValues(weakData->weakResolveCallback)[0].Call();
197 }, [weakData](const std::string& error) 203 }, [weakData](const std::string& error)
198 { 204 {
199 if (error.empty()) 205 if (error.empty())
200 return; 206 return;
201 auto jsEngine = weakData->weakJsEngine.lock(); 207 auto jsEngine = weakData->weakJsEngine.lock();
202 if (!jsEngine) 208 if (!jsEngine)
203 return; 209 return;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) 367 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj)
362 { 368 {
363 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback::V8Callback)); 369 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback::V8Callback));
364 obj.SetProperty("readFromFile", jsEngine.NewCallback(::ReadFromFileCallback::V 8Callback)); 370 obj.SetProperty("readFromFile", jsEngine.NewCallback(::ReadFromFileCallback::V 8Callback));
365 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); 371 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback));
366 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); 372 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback));
367 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); 373 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback));
368 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); 374 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback));
369 return obj; 375 return obj;
370 } 376 }
OLDNEW
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/Utils.h » ('J')

Powered by Google App Engine
This is Rietveld