Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc / ext / channel.h
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18
19 #ifndef NET_GRPC_NODE_CHANNEL_H_
20 #define NET_GRPC_NODE_CHANNEL_H_
21
22 #include <nan.h>
23 #include <node.h>
24 #include "grpc/grpc.h"
25
26 namespace grpc {
27 namespace node {
28
29 bool ParseChannelArgs(v8::Local<v8::Value> args_val,
30                       grpc_channel_args **channel_args_ptr);
31
32 void DeallocateChannelArgs(grpc_channel_args *channel_args);
33
34 /* Wrapper class for grpc_channel structs */
35 class Channel : public Nan::ObjectWrap {
36  public:
37   static void Init(v8::Local<v8::Object> exports);
38   static bool HasInstance(v8::Local<v8::Value> val);
39   /* This is used to typecheck javascript objects before converting them to
40      this type */
41   static v8::Persistent<v8::Value> prototype;
42
43   /* Returns the grpc_channel struct that this object wraps */
44   grpc_channel *GetWrappedChannel();
45
46  private:
47   explicit Channel(grpc_channel *channel);
48   ~Channel();
49
50   // Prevent copying
51   Channel(const Channel &);
52   Channel &operator=(const Channel &);
53
54   static NAN_METHOD(New);
55   static NAN_METHOD(Close);
56   static NAN_METHOD(GetTarget);
57   static NAN_METHOD(GetConnectivityState);
58   static NAN_METHOD(WatchConnectivityState);
59   static NAN_METHOD(CreateCall);
60   static Nan::Callback *constructor;
61   static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
62
63   grpc_channel *wrapped_channel;
64 };
65
66 }  // namespace node
67 }  // namespace grpc
68
69 #endif  // NET_GRPC_NODE_CHANNEL_H_