Upstream version 11.39.264.0
[platform/framework/web/crosswalk.git] / src / xwalk / sysapps / raw_socket / raw_socket_extension.h
1 // Copyright (c) 2013 Intel Corporation. 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.
4
5 #ifndef XWALK_SYSAPPS_RAW_SOCKET_RAW_SOCKET_EXTENSION_H_
6 #define XWALK_SYSAPPS_RAW_SOCKET_RAW_SOCKET_EXTENSION_H_
7
8 #include <string>
9 #include "base/values.h"
10 #include "xwalk/sysapps/common/binding_object_store.h"
11
12 namespace xwalk {
13 namespace sysapps {
14
15 using extensions::XWalkExtension;
16 using extensions::XWalkExtensionFunctionHandler;
17 using extensions::XWalkExtensionFunctionInfo;
18 using extensions::XWalkExtensionInstance;
19
20 class RawSocketExtension : public XWalkExtension {
21  public:
22   RawSocketExtension();
23   virtual ~RawSocketExtension();
24
25   // XWalkExtension implementation.
26   virtual XWalkExtensionInstance* CreateInstance() OVERRIDE;
27 };
28
29 class RawSocketInstance : public XWalkExtensionInstance {
30  public:
31   RawSocketInstance();
32
33   // XWalkExtensionInstance implementation.
34   virtual void HandleMessage(scoped_ptr<base::Value> msg) OVERRIDE;
35
36   void AddBindingObject(const std::string& object_id,
37                         scoped_ptr<BindingObject> obj);
38
39  private:
40   void OnTCPServerSocketConstructor(
41       scoped_ptr<XWalkExtensionFunctionInfo> info);
42   void OnTCPSocketConstructor(scoped_ptr<XWalkExtensionFunctionInfo> info);
43   void OnUDPSocketConstructor(scoped_ptr<XWalkExtensionFunctionInfo> info);
44
45   XWalkExtensionFunctionHandler handler_;
46   BindingObjectStore store_;
47 };
48
49 }  // namespace sysapps
50 }  // namespace xwalk
51
52 #endif  // XWALK_SYSAPPS_RAW_SOCKET_RAW_SOCKET_EXTENSION_H_