Make callback aligns node.js style.
This commit is contained in:
parent
93243ef223
commit
ccbe554ec0
2 changed files with 8 additions and 3 deletions
|
@ -52,7 +52,9 @@ class WebContents : public mate::EventEmitter,
|
|||
public content::WebContentsObserver,
|
||||
public content::GpuDataManagerObserver {
|
||||
public:
|
||||
typedef base::Callback<void(v8::Local<v8::Value>)> PrintToPDFCallback;
|
||||
// For node.js callback function type: function(error, buffer)
|
||||
typedef base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>
|
||||
PrintToPDFCallback;
|
||||
|
||||
// Create from an existing WebContents.
|
||||
static mate::Handle<WebContents> CreateFrom(
|
||||
|
|
|
@ -130,9 +130,12 @@ void PrintPreviewMessageHandler::RunPrintToPDFCallback(
|
|||
v8::Local<v8::Value> buffer = node::Buffer::Use(
|
||||
const_cast<char*>(reinterpret_cast<const char*>(data->front())),
|
||||
data->size());
|
||||
print_to_pdf_callback_map_[request_id].Run(buffer);
|
||||
print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate), buffer);
|
||||
} else {
|
||||
print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate));
|
||||
v8::Local<v8::String> error_message = v8::String::NewFromUtf8(isolate,
|
||||
"Fail to generate PDF");
|
||||
print_to_pdf_callback_map_[request_id].Run(
|
||||
v8::Exception::Error(error_message), v8::Null(isolate));
|
||||
}
|
||||
print_to_pdf_callback_map_.erase(request_id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue