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

Side by Side Diff: src/ConsoleJsObject.cpp

Issue 29809555: Issue #6526 - pass v8::Isolate to more functions because old approach is deprecated (Closed) Base URL: https://github.com/adblockplus/libadblockplus@4d9bcc12e77369cbc4bc04bace9a3e7fa03de17b
Patch Set: Created June 18, 2018, 10:22 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/FileSystemJsObject.cpp » ('j') | src/FileSystemJsObject.cpp » ('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 25 matching lines...) Expand all
36 std::stringstream message; 36 std::stringstream message;
37 for (size_t i = 0; i < converted.size(); i++) 37 for (size_t i = 0; i < converted.size(); i++)
38 { 38 {
39 if (i > 0) 39 if (i > 0)
40 message << " "; 40 message << " ";
41 message << converted[i].AsString(); 41 message << converted[i].AsString();
42 } 42 }
43 43
44 std::stringstream source; 44 std::stringstream source;
45 v8::Local<v8::StackFrame> frame = v8::StackTrace::CurrentStackTrace(argument s.GetIsolate(), 1)->GetFrame(0); 45 v8::Local<v8::StackFrame> frame = v8::StackTrace::CurrentStackTrace(argument s.GetIsolate(), 1)->GetFrame(0);
46 source << AdblockPlus::Utils::FromV8String(frame->GetScriptName()); 46 source << AdblockPlus::Utils::FromV8String(arguments.GetIsolate(), frame->Ge tScriptName());
47 source << ":" << frame->GetLineNumber(); 47 source << ":" << frame->GetLineNumber();
48 48
49 jsEngine->GetPlatform().WithLogSystem( 49 jsEngine->GetPlatform().WithLogSystem(
50 [logLevel, &message, &source](AdblockPlus::LogSystem& callback) 50 [logLevel, &message, &source](AdblockPlus::LogSystem& callback)
51 { 51 {
52 callback(logLevel, message.str(), source.str()); 52 callback(logLevel, message.str(), source.str());
53 }); 53 });
54 } 54 }
55 55
56 void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) 56 void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
(...skipping 26 matching lines...) Expand all
83 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments); 83 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments);
84 const AdblockPlus::JsContext context(*jsEngine); 84 const AdblockPlus::JsContext context(*jsEngine);
85 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); 85 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
86 86
87 std::stringstream traceback; 87 std::stringstream traceback;
88 v8::Local<v8::StackTrace> frames = v8::StackTrace::CurrentStackTrace(argumen ts.GetIsolate(), 100); 88 v8::Local<v8::StackTrace> frames = v8::StackTrace::CurrentStackTrace(argumen ts.GetIsolate(), 100);
89 for (int i = 0, l = frames->GetFrameCount(); i < l; i++) 89 for (int i = 0, l = frames->GetFrameCount(); i < l; i++)
90 { 90 {
91 v8::Local<v8::StackFrame> frame = frames->GetFrame(i); 91 v8::Local<v8::StackFrame> frame = frames->GetFrame(i);
92 traceback << (i + 1) << ": "; 92 traceback << (i + 1) << ": ";
93 std::string name = AdblockPlus::Utils::FromV8String(frame->GetFunctionName ()); 93 std::string name = AdblockPlus::Utils::FromV8String(arguments.GetIsolate() , frame->GetFunctionName());
94 if (name.size()) 94 if (name.size())
95 traceback << name; 95 traceback << name;
96 else 96 else
97 traceback << "/* anonymous */"; 97 traceback << "/* anonymous */";
98 traceback << "() at "; 98 traceback << "() at ";
99 traceback << AdblockPlus::Utils::FromV8String(frame->GetScriptName()); 99 traceback << AdblockPlus::Utils::FromV8String(arguments.GetIsolate(), fram e->GetScriptName());
100 traceback << ":" << frame->GetLineNumber(); 100 traceback << ":" << frame->GetLineNumber();
101 traceback << std::endl; 101 traceback << std::endl;
102 } 102 }
103 103
104 jsEngine->GetPlatform().WithLogSystem( 104 jsEngine->GetPlatform().WithLogSystem(
105 [&traceback](AdblockPlus::LogSystem& callback) 105 [&traceback](AdblockPlus::LogSystem& callback)
106 { 106 {
107 callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), ""); 107 callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), "");
108 }); 108 });
109 } 109 }
110 } 110 }
111 111
112 AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup( 112 AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup(
113 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) 113 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj)
114 { 114 {
115 obj.SetProperty("log", jsEngine.NewCallback(::LogCallback)); 115 obj.SetProperty("log", jsEngine.NewCallback(::LogCallback));
116 obj.SetProperty("debug", jsEngine.NewCallback(::DebugCallback)); 116 obj.SetProperty("debug", jsEngine.NewCallback(::DebugCallback));
117 obj.SetProperty("info", jsEngine.NewCallback(::InfoCallback)); 117 obj.SetProperty("info", jsEngine.NewCallback(::InfoCallback));
118 obj.SetProperty("warn", jsEngine.NewCallback(::WarnCallback)); 118 obj.SetProperty("warn", jsEngine.NewCallback(::WarnCallback));
119 obj.SetProperty("error", jsEngine.NewCallback(::ErrorCallback)); 119 obj.SetProperty("error", jsEngine.NewCallback(::ErrorCallback));
120 obj.SetProperty("trace", jsEngine.NewCallback(::TraceCallback)); 120 obj.SetProperty("trace", jsEngine.NewCallback(::TraceCallback));
121 return obj; 121 return obj;
122 } 122 }
OLDNEW
« no previous file with comments | « no previous file | src/FileSystemJsObject.cpp » ('j') | src/FileSystemJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld