1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WRT_BUNDLE_RUNTIME_IPC_CLIENT_H_
6 #define WRT_BUNDLE_RUNTIME_IPC_CLIENT_H_
9 #include <ewk_ipc_message.h>
16 class RuntimeIPCClient {
20 explicit JSCallback(v8::Isolate* isolate,
21 v8::Handle<v8::Function> callback);
24 v8::Isolate* isolate() const { return isolate_; }
26 void Call(v8::Handle<v8::Value> args[]);
28 v8::Isolate* isolate_;
29 v8::Persistent<v8::Function> callback_;
32 typedef std::function<void(const std::string& type,
33 const std::string& value,
34 JSCallback* js_callback)> ReplyCallback;
36 static RuntimeIPCClient* GetInstance();
38 // Send message to BrowserProcess without reply
39 void SendMessage(const std::string& type, const std::string& value);
41 // Send message to BrowserProcess synchronous with reply
42 std::string SendSyncMessage(const std::string& type,
43 const std::string& value);
45 // Send message to BrowserProcess asynchronous,
46 // reply message will be passed to callback function.
47 void SendAsyncMessage(const std::string& type, const std::string& value,
48 ReplyCallback callback, JSCallback* js_callback);
50 void HandleMessageFromRuntime(const Ewk_IPC_Wrt_Message_Data* msg);
52 int routing_id() const { return routing_id_; }
53 void set_routing_id(int routing_id) { routing_id_ = routing_id; }
59 if (js_callback) delete js_callback;
62 ReplyCallback callback;
63 JSCallback* js_callback;
69 std::map<std::string, AsyncData> callbacks_;
74 #endif // WRT_BUNDLE_RUNTIME_IPC_CLIENT_H_