From 11ffb9dfb6898f24a26a40e767c17b6bd83783f8 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 4 Aug 2015 16:50:33 +0800 Subject: [PATCH] Fix node::Buffer API changes. --- atom/common/api/atom_api_native_image.cc | 13 +++++++------ .../browser/printing/print_preview_message_handler.cc | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 40a73a7..79fc0c0 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -148,17 +148,18 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder( v8::Local NativeImage::ToPNG(v8::Isolate* isolate) { scoped_refptr png = image_.As1xPNGBytes(); - return node::Buffer::New(isolate, - reinterpret_cast(png->front()), - png->size()); + return node::Buffer::Copy(isolate, + reinterpret_cast(png->front()), + static_cast(png->size())).ToLocalChecked(); } v8::Local NativeImage::ToJPEG(v8::Isolate* isolate, int quality) { std::vector output; gfx::JPEG1xEncodedDataFromImage(image_, quality, &output); - return node::Buffer::New(isolate, - reinterpret_cast(&output.front()), - output.size()); + return node::Buffer::Copy( + isolate, + reinterpret_cast(&output.front()), + static_cast(output.size())).ToLocalChecked(); } std::string NativeImage::ToDataURL() { diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc index ca70ac2..613f3f2 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc @@ -125,8 +125,8 @@ void PrintPreviewMessageHandler::RunPrintToPDFCallback( v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (data) { - v8::Local buffer = node::Buffer::Use(isolate, - data, static_cast(data_size)); + v8::Local buffer = node::Buffer::New(isolate, + data, static_cast(data_size)).ToLocalChecked(); print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate), buffer); } else { v8::Local error_message = v8::String::NewFromUtf8(isolate, -- 2.7.4