[inspector] fixed CommandLineAPIData leak
We can use v8::ArrayBuffer to store struct. R=dgozman@chromium.org Bug: none Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel Change-Id: I6c4e994e3a8b0a19ad06f89dfadf808f8c6a68e6 Reviewed-on: https://chromium-review.googlesource.com/772036 Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Cr-Commit-Position: refs/heads/master@{#49390}
This commit is contained in:
parent
4ab559cb89
commit
f51192bc4d
@ -663,9 +663,10 @@ v8::Local<v8::Object> V8Console::createCommandLineAPI(
|
|||||||
DCHECK(success);
|
DCHECK(success);
|
||||||
USE(success);
|
USE(success);
|
||||||
|
|
||||||
// TODO(dgozman): this CommandLineAPIData instance leaks. Use PodArray maybe?
|
v8::Local<v8::ArrayBuffer> data =
|
||||||
v8::Local<v8::External> data =
|
v8::ArrayBuffer::New(isolate, sizeof(CommandLineAPIData));
|
||||||
v8::External::New(isolate, new CommandLineAPIData(this, sessionId));
|
*static_cast<CommandLineAPIData*>(data->GetContents().Data()) =
|
||||||
|
CommandLineAPIData(this, sessionId);
|
||||||
createBoundFunctionProperty(context, commandLineAPI, data, "dir",
|
createBoundFunctionProperty(context, commandLineAPI, data, "dir",
|
||||||
&V8Console::call<&V8Console::Dir>,
|
&V8Console::call<&V8Console::Dir>,
|
||||||
"function dir(value) { [Command Line API] }");
|
"function dir(value) { [Command Line API] }");
|
||||||
|
@ -108,14 +108,14 @@ class V8Console : public v8::debug::ConsoleDelegate {
|
|||||||
int)>
|
int)>
|
||||||
static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||||
CommandLineAPIData* data = static_cast<CommandLineAPIData*>(
|
CommandLineAPIData* data = static_cast<CommandLineAPIData*>(
|
||||||
info.Data().As<v8::External>()->Value());
|
info.Data().As<v8::ArrayBuffer>()->GetContents().Data());
|
||||||
(data->first->*func)(info, data->second);
|
(data->first->*func)(info, data->second);
|
||||||
}
|
}
|
||||||
template <void (V8Console::*func)(const v8::debug::ConsoleCallArguments&,
|
template <void (V8Console::*func)(const v8::debug::ConsoleCallArguments&,
|
||||||
const v8::debug::ConsoleContext&)>
|
const v8::debug::ConsoleContext&)>
|
||||||
static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||||
CommandLineAPIData* data = static_cast<CommandLineAPIData*>(
|
CommandLineAPIData* data = static_cast<CommandLineAPIData*>(
|
||||||
info.Data().As<v8::External>()->Value());
|
info.Data().As<v8::ArrayBuffer>()->GetContents().Data());
|
||||||
v8::debug::ConsoleCallArguments args(info);
|
v8::debug::ConsoleCallArguments args(info);
|
||||||
(data->first->*func)(args, v8::debug::ConsoleContext());
|
(data->first->*func)(args, v8::debug::ConsoleContext());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user