| OLD | NEW |
| 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/udp_socket.h" | 12 #include "net/udp/udp_socket.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 class APIResourceEventNotifier; | 16 class APIResourceEventNotifier; |
| 17 | 17 |
| 18 class UDPSocket : public Socket { | 18 class UDPSocket : public Socket { |
| 19 public: | 19 public: |
| 20 explicit UDPSocket(APIResourceEventNotifier* event_notifier); | 20 explicit UDPSocket(APIResourceEventNotifier* event_notifier); |
| 21 virtual ~UDPSocket(); | 21 virtual ~UDPSocket(); |
| 22 | 22 |
| 23 virtual int Connect(const std::string& address, int port) OVERRIDE; | 23 virtual void Connect(const std::string& address, |
| 24 int port, |
| 25 const CompletionCallback& callback) OVERRIDE; |
| 24 virtual void Disconnect() OVERRIDE; | 26 virtual void Disconnect() OVERRIDE; |
| 25 virtual int Bind(const std::string& address, int port) OVERRIDE; | 27 virtual int Bind(const std::string& address, int port) OVERRIDE; |
| 26 virtual int Read(scoped_refptr<net::IOBuffer> io_buffer, | 28 virtual void Read(int count, |
| 27 int io_buffer_size) OVERRIDE; | 29 const ReadCompletionCallback& callback) OVERRIDE; |
| 28 virtual int Write(scoped_refptr<net::IOBuffer> io_buffer, | 30 virtual void Write(scoped_refptr<net::IOBuffer> io_buffer, |
| 29 int bytes) OVERRIDE; | 31 int bytes, |
| 30 virtual int RecvFrom(scoped_refptr<net::IOBuffer> io_buffer, | 32 const CompletionCallback& callback) OVERRIDE; |
| 31 int io_buffer_size, | 33 virtual void RecvFrom(int count, |
| 32 net::IPEndPoint* address) OVERRIDE; | 34 const RecvFromCompletionCallback& callback) OVERRIDE; |
| 33 virtual int SendTo(scoped_refptr<net::IOBuffer> io_buffer, | 35 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, |
| 34 int byte_count, | 36 int byte_count, |
| 35 const std::string& address, | 37 const std::string& address, |
| 36 int port) OVERRIDE; | 38 int port, |
| 39 const CompletionCallback& callback) OVERRIDE; |
| 37 | 40 |
| 38 private: | 41 private: |
| 42 // Make net::IPEndPoint can be refcounted |
| 43 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint; |
| 44 |
| 45 virtual void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, |
| 46 int result); |
| 47 virtual void OnWriteComplete(int result); |
| 48 virtual void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer, |
| 49 scoped_refptr<IPEndPoint> address, |
| 50 int result); |
| 51 virtual void OnSendToComplete(int result); |
| 52 |
| 39 net::UDPSocket socket_; | 53 net::UDPSocket socket_; |
| 54 |
| 55 ReadCompletionCallback read_callback_; |
| 56 |
| 57 CompletionCallback write_callback_; |
| 58 |
| 59 RecvFromCompletionCallback recv_from_callback_; |
| 60 |
| 61 CompletionCallback send_to_callback_; |
| 40 }; | 62 }; |
| 41 | 63 |
| 42 } // namespace extensions | 64 } // namespace extensions |
| 43 | 65 |
| 44 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ |
| OLD | NEW |