Fix invalid licenses
[platform/framework/web/crosswalk-tizen.git] / src / extension / extension_instance.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 #ifndef WRT_EXTENSION_EXTENSION_INSTANCE_H_
18 #define WRT_EXTENSION_EXTENSION_INSTANCE_H_
19
20 #include <string>
21 #include <functional>
22
23 #include "extension/xwalk/XW_Extension.h"
24
25 namespace wrt {
26
27 class Extension;
28
29 class ExtensionInstance {
30  public:
31   typedef std::function<void(const std::string&)> MessageCallback;
32
33   ExtensionInstance(Extension* extension, XW_Instance xw_instance);
34   virtual ~ExtensionInstance();
35
36   void HandleMessage(const std::string& msg);
37   void HandleSyncMessage(const std::string& msg);
38
39   void SetPostMessageCallback(MessageCallback callback);
40   void SetSendSyncReplyCallback(MessageCallback callback);
41
42  private:
43   friend class ExtensionAdapter;
44
45   void PostMessageToJS(const std::string& msg);
46   void SyncReplyToJS(const std::string& reply);
47
48   Extension* extension_;
49   XW_Instance xw_instance_;
50   void* instance_data_;
51
52   MessageCallback post_message_callback_;
53   MessageCallback send_sync_reply_callback_;
54 };
55
56 }  // namespace wrt
57
58 #endif  // WRT_EXTENSION_EXTENSION_INSTANCE_H_