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

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

Issue 12684008: Multicast socket API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 7 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 | Annotate | Revision Log
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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/hash_tables.h"
10 #include "chrome/browser/extensions/api/socket/socket.h" 11 #include "chrome/browser/extensions/api/socket/socket.h"
11 #include "net/udp/udp_socket.h" 12 #include "net/udp/udp_socket.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
15 class UDPSocket : public Socket { 16 class UDPSocket : public Socket {
16 public: 17 public:
17 explicit UDPSocket(const std::string& owner_extension_id); 18 explicit UDPSocket(const std::string& owner_extension_id);
18 virtual ~UDPSocket(); 19 virtual ~UDPSocket();
19 20
20 virtual void Connect(const std::string& address, 21 virtual void Connect(const std::string& address,
21 int port, 22 int port,
22 const CompletionCallback& callback) OVERRIDE; 23 const CompletionCallback& callback) OVERRIDE;
23 virtual void Disconnect() OVERRIDE; 24 virtual void Disconnect() OVERRIDE;
24 virtual int Bind(const std::string& address, int port) OVERRIDE; 25 virtual int Bind(const std::string& address, int port) OVERRIDE;
25 virtual void Read(int count, 26 virtual void Read(int count,
26 const ReadCompletionCallback& callback) OVERRIDE; 27 const ReadCompletionCallback& callback) OVERRIDE;
27 virtual void RecvFrom(int count, 28 virtual void RecvFrom(int count,
28 const RecvFromCompletionCallback& callback) OVERRIDE; 29 const RecvFromCompletionCallback& callback) OVERRIDE;
29 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, 30 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer,
30 int byte_count, 31 int byte_count,
31 const std::string& address, 32 const std::string& address,
32 int port, 33 int port,
33 const CompletionCallback& callback) OVERRIDE; 34 const CompletionCallback& callback) OVERRIDE;
34 virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE; 35 virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE;
35 virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE; 36 virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE;
36 virtual Socket::SocketType GetSocketType() const OVERRIDE; 37 virtual Socket::SocketType GetSocketType() const OVERRIDE;
37 38
39 int JoinGroup(const std::string& address);
40 int LeaveGroup(const std::string& address);
41
42 int SetMulticastTimeToLive(int ttl);
43 int SetMulticastLoopbackMode(bool loopback);
44
45 int GetJoinedGroups(base::hash_set<std::string>& groups) const;
38 protected: 46 protected:
39 virtual int WriteImpl(net::IOBuffer* io_buffer, 47 virtual int WriteImpl(net::IOBuffer* io_buffer,
40 int io_buffer_size, 48 int io_buffer_size,
41 const net::CompletionCallback& callback) OVERRIDE; 49 const net::CompletionCallback& callback) OVERRIDE;
42 50
43 private: 51 private:
44 // Make net::IPEndPoint can be refcounted 52 // Make net::IPEndPoint can be refcounted
45 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint; 53 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint;
46 54
47 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, 55 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
48 int result); 56 int result);
49 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer, 57 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer,
50 scoped_refptr<IPEndPoint> address, 58 scoped_refptr<IPEndPoint> address,
51 int result); 59 int result);
52 void OnSendToComplete(int result); 60 void OnSendToComplete(int result);
53 61
54 net::UDPSocket socket_; 62 net::UDPSocket socket_;
55 63
56 ReadCompletionCallback read_callback_; 64 ReadCompletionCallback read_callback_;
57 65
58 RecvFromCompletionCallback recv_from_callback_; 66 RecvFromCompletionCallback recv_from_callback_;
59 67
60 CompletionCallback send_to_callback_; 68 CompletionCallback send_to_callback_;
69
70 base::hash_set<std::string> multicast_groups_;
61 }; 71 };
62 72
63 } // namespace extensions 73 } // namespace extensions
64 74
65 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 75 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698