Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/extensions/api/socket/udp_socket.h

Issue 10134008: Add bind(), recvFrom(), sendTo() for UDP socket. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: wip Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/extensions/api/socket/socket.h" 11 #include "chrome/browser/extensions/api/socket/socket.h"
12 #include "net/udp/datagram_client_socket.h" 12 #include "net/udp/udp_socket.h"
13 13
14 namespace net { 14 namespace net {
15 class Socket; 15 class Socket;
16 } 16 }
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 class APIResourceEventNotifier; 20 class APIResourceEventNotifier;
21 21
22 class UDPSocket : public Socket { 22 class UDPSocket : public Socket {
23 public: 23 public:
24 UDPSocket(const std::string& address, int port, 24 UDPSocket(APIResourceEventNotifier* event_notifier);
25 APIResourceEventNotifier* event_notifier);
26 virtual ~UDPSocket(); 25 virtual ~UDPSocket();
27 26
28 virtual bool IsValid() OVERRIDE; 27 virtual bool IsValid() OVERRIDE;
29 28
30 virtual int Connect() OVERRIDE; 29 virtual int Connect(const std::string& address, int port) OVERRIDE;
31 virtual void Disconnect() OVERRIDE; 30 virtual void Disconnect() OVERRIDE;
31 virtual int Bind(const std::string& address, int port) OVERRIDE;
32 virtual int Read(scoped_refptr<net::IOBuffer> io_buffer,
33 int io_buffer_size) OVERRIDE;
34 virtual int Write(scoped_refptr<net::IOBuffer> io_buffer,
35 int bytes) OVERRIDE;
36 virtual int RecvFrom(scoped_refptr<net::IOBuffer> io_buffer,
37 int io_buffer_size,
38 net::IPEndPoint* address) OVERRIDE;
39 virtual int SendTo(scoped_refptr<net::IOBuffer> io_buffer,
40 int byte_count,
41 const std::string& address,
42 int port) OVERRIDE;
32 43
33 static UDPSocket* CreateSocketForTesting( 44 static UDPSocket* CreateSocketForTesting(
34 net::DatagramClientSocket* datagram_client_socket, 45 net::UDPSocket* udp_socket,
35 const std::string& address, int port,
36 APIResourceEventNotifier* event_notifier); 46 APIResourceEventNotifier* event_notifier);
37 47
38 protected:
39 virtual net::Socket* socket() OVERRIDE;
40
41 private: 48 private:
42 // Special constructor for testing. 49 // Special constructor for testing.
43 UDPSocket(net::DatagramClientSocket* datagram_client_socket, 50 UDPSocket(net::UDPSocket* udp_socket,
44 const std::string& address, int port,
45 APIResourceEventNotifier* event_notifier); 51 APIResourceEventNotifier* event_notifier);
46 52
47 scoped_ptr<net::DatagramClientSocket> socket_; 53 scoped_ptr<net::UDPSocket> socket_;
48 }; 54 };
49 55
50 } // namespace extensions 56 } // namespace extensions
51 57
52 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 58 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698