diff options
author | Mike Morris <mikemorris@users.noreply.github.com> | 2016-07-12 18:37:28 -0400 |
---|---|---|
committer | Mike Morris <mikemorris@users.noreply.github.com> | 2016-07-14 13:47:02 -0400 |
commit | 7df0e459b6da75f6ebddedb003f391df7c1959c9 (patch) | |
tree | 9c2cee179effa8d31abf58a338129854509c29d2 /platform/node/src/node_request.hpp | |
parent | 480be63396abe016ce8f1c8c5acd8621412a0fa3 (diff) | |
download | qtlocation-mapboxgl-7df0e459b6da75f6ebddedb003f391df7c1959c9.tar.gz |
[node] NodeRequest inherits from Nan::AsyncWorker
drop NodeRequest::Create, move MakeCallback to NodeRequest::Execute
rework Respond -> HandleCallback
modern NAN style updates
Diffstat (limited to 'platform/node/src/node_request.hpp')
-rw-r--r-- | platform/node/src/node_request.hpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/platform/node/src/node_request.hpp b/platform/node/src/node_request.hpp index 2d307a3f19..f7fce91726 100644 --- a/platform/node/src/node_request.hpp +++ b/platform/node/src/node_request.hpp @@ -11,29 +11,31 @@ namespace node_mbgl { -class NodeFileSource; -class NodeRequest; +class NodeMap; -class NodeRequest : public Nan::ObjectWrap { +class NodeRequest : public Nan::ObjectWrap, + public Nan::AsyncWorker { public: - static NAN_MODULE_INIT(Init); - - static NAN_METHOD(New); - static NAN_METHOD(Respond); - - static v8::Handle<v8::Object> Create(const mbgl::Resource&, mbgl::FileSource::Callback); - static Nan::Persistent<v8::Function> constructor; - - NodeRequest(mbgl::FileSource::Callback); - ~NodeRequest(); - struct NodeAsyncRequest : public mbgl::AsyncRequest { NodeAsyncRequest(NodeRequest*); ~NodeAsyncRequest() override; NodeRequest* request; }; + NodeRequest(NodeMap*, mbgl::FileSource::Callback); + ~NodeRequest(); + + static Nan::Persistent<v8::Function> constructor; + + static NAN_MODULE_INIT(Init); + + static void New(const Nan::FunctionCallbackInfo<v8::Value>&); + static void HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>&); + + void Execute(); + private: + NodeMap* target; mbgl::FileSource::Callback callback; NodeAsyncRequest* asyncRequest = nullptr; }; |