summaryrefslogtreecommitdiff
path: root/src/node_request.hpp
blob: a690904ef25c2c5a65c8e539fd51e3b5d88b4d94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wshadow"
#include <node.h>
#include <nan.h>
#pragma GCC diagnostic pop

#include <mbgl/storage/resource.hpp>

#include <memory>

namespace node_mbgl {

class NodeFileSource;

class NodeRequest : public node::ObjectWrap {
    ////////////////////////////////////////////////////////////////////////////////////////////////
    // Static Node Methods
public:
    static void Init(v8::Handle<v8::Object> target);
    static NAN_METHOD(New);
    static NAN_METHOD(Respond);

    static v8::Handle<v8::Object> Create(NodeFileSource*, const mbgl::Resource&);

    static v8::Persistent<v8::FunctionTemplate> constructorTemplate;

    ////////////////////////////////////////////////////////////////////////////////////////////////
    // Instance
public:
    NodeRequest(NodeFileSource* source, const mbgl::Resource& resource);
    ~NodeRequest();

    void cancel();

private:
    NodeFileSource* source;
    std::unique_ptr<mbgl::Resource> resource;
};

}