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

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: Add License info to multicast.js Created 7 years, 7 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 #include <vector>
9 10
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 const std::vector<std::string>& GetJoinedGroups() const;
46
38 protected: 47 protected:
39 virtual int WriteImpl(net::IOBuffer* io_buffer, 48 virtual int WriteImpl(net::IOBuffer* io_buffer,
40 int io_buffer_size, 49 int io_buffer_size,
41 const net::CompletionCallback& callback) OVERRIDE; 50 const net::CompletionCallback& callback) OVERRIDE;
42 51
43 private: 52 private:
44 // Make net::IPEndPoint can be refcounted 53 // Make net::IPEndPoint can be refcounted
45 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint; 54 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint;
46 55
47 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, 56 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
48 int result); 57 int result);
49 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer, 58 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer,
50 scoped_refptr<IPEndPoint> address, 59 scoped_refptr<IPEndPoint> address,
51 int result); 60 int result);
52 void OnSendToComplete(int result); 61 void OnSendToComplete(int result);
53 62
54 net::UDPSocket socket_; 63 net::UDPSocket socket_;
55 64
56 ReadCompletionCallback read_callback_; 65 ReadCompletionCallback read_callback_;
57 66
58 RecvFromCompletionCallback recv_from_callback_; 67 RecvFromCompletionCallback recv_from_callback_;
59 68
60 CompletionCallback send_to_callback_; 69 CompletionCallback send_to_callback_;
70
71 std::vector<std::string> multicast_groups_;
61 }; 72 };
62 73
63 } // namespace extensions 74 } // namespace extensions
64 75
65 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 76 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/socket/socket_apitest.cc ('k') | chrome/browser/extensions/api/socket/udp_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698