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_SOCKET_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "chrome/browser/extensions/api/api_resource.h" | 14 #include "chrome/browser/extensions/api/api_resource.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 17 #include "net/base/ip_endpoint.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 class AddressList; | 20 class AddressList; |
20 class IPEndPoint; | 21 class IPEndPoint; |
21 class Socket; | 22 class Socket; |
22 } | 23 } |
23 | 24 |
24 namespace extensions { | 25 namespace extensions { |
25 | 26 |
26 typedef base::Callback<void(int)> CompletionCallback; | 27 typedef base::Callback<void(int)> CompletionCallback; |
(...skipping 29 matching lines...) Expand all Loading... |
56 const RecvFromCompletionCallback& callback) = 0; | 57 const RecvFromCompletionCallback& callback) = 0; |
57 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, | 58 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, |
58 int byte_count, | 59 int byte_count, |
59 const std::string& address, | 60 const std::string& address, |
60 int port, | 61 int port, |
61 const CompletionCallback& callback) = 0; | 62 const CompletionCallback& callback) = 0; |
62 | 63 |
63 virtual bool SetKeepAlive(bool enable, int delay); | 64 virtual bool SetKeepAlive(bool enable, int delay); |
64 virtual bool SetNoDelay(bool no_delay); | 65 virtual bool SetNoDelay(bool no_delay); |
65 | 66 |
| 67 bool IsConnected(); |
| 68 virtual bool IsTCPSocket() = 0; |
| 69 |
| 70 virtual bool GetPeerAddress(net::IPEndPoint* address) = 0; |
| 71 virtual bool GetLocalAddress(net::IPEndPoint* address) = 0; |
| 72 |
66 static bool StringAndPortToAddressList(const std::string& ip_address_str, | 73 static bool StringAndPortToAddressList(const std::string& ip_address_str, |
67 int port, | 74 int port, |
68 net::AddressList* address_list); | 75 net::AddressList* address_list); |
69 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str, | 76 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str, |
70 int port, | 77 int port, |
71 net::IPEndPoint* ip_end_point); | 78 net::IPEndPoint* ip_end_point); |
72 static void IPEndPointToStringAndPort(const net::IPEndPoint& address, | 79 static void IPEndPointToStringAndPort(const net::IPEndPoint& address, |
73 std::string* ip_address_str, | 80 std::string* ip_address_str, |
74 int* port); | 81 int* port); |
75 | 82 |
(...skipping 25 matching lines...) Expand all Loading... |
101 CompletionCallback callback; | 108 CompletionCallback callback; |
102 int bytes_written; | 109 int bytes_written; |
103 }; | 110 }; |
104 std::queue<WriteRequest> write_queue_; | 111 std::queue<WriteRequest> write_queue_; |
105 scoped_refptr<net::IOBuffer> io_buffer_write_; | 112 scoped_refptr<net::IOBuffer> io_buffer_write_; |
106 }; | 113 }; |
107 | 114 |
108 } // namespace extensions | 115 } // namespace extensions |
109 | 116 |
110 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ | 117 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ |
OLD | NEW |