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.
5 #ifndef XWALK_SYSAPPS_RAW_SOCKET_UDP_SOCKET_OBJECT_H_
6 #define XWALK_SYSAPPS_RAW_SOCKET_UDP_SOCKET_OBJECT_H_
10 #include "net/base/address_list.h"
11 #include "net/base/io_buffer.h"
12 #include "net/dns/single_request_host_resolver.h"
13 #include "net/udp/udp_socket.h"
14 #include "xwalk/sysapps/raw_socket/raw_socket_object.h"
19 class UDPSocketObject : public RawSocketObject {
22 virtual ~UDPSocketObject();
27 // JavaScript function handlers.
28 void OnInit(scoped_ptr<XWalkExtensionFunctionInfo> info);
29 void OnClose(scoped_ptr<XWalkExtensionFunctionInfo> info);
30 void OnSuspend(scoped_ptr<XWalkExtensionFunctionInfo> info);
31 void OnResume(scoped_ptr<XWalkExtensionFunctionInfo> info);
32 void OnJoinMulticast(scoped_ptr<XWalkExtensionFunctionInfo> info);
33 void OnLeaveMulticast(scoped_ptr<XWalkExtensionFunctionInfo> info);
34 void OnSendString(scoped_ptr<XWalkExtensionFunctionInfo> info);
36 // net::UDPSocket callbacks.
37 void OnRead(int status);
38 void OnWrite(int status);
40 // net::SingleRequestHostResolver callbacks.
41 void OnConnectionOpen(int status);
42 void OnSend(int status);
44 bool has_write_pending_;
48 scoped_refptr<net::IOBuffer> read_buffer_;
49 scoped_refptr<net::IOBuffer> write_buffer_;
50 scoped_ptr<net::UDPSocket> socket_;
52 unsigned write_buffer_size_;
54 scoped_ptr<net::HostResolver> resolver_;
55 scoped_ptr<net::SingleRequestHostResolver> single_resolver_;
56 net::AddressList addresses_;
57 net::IPEndPoint from_;
60 } // namespace sysapps
63 #endif // XWALK_SYSAPPS_RAW_SOCKET_UDP_SOCKET_OBJECT_H_