| 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> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 int port, | 80 int port, |
| 81 net::AddressList* address_list); | 81 net::AddressList* address_list); |
| 82 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str, | 82 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str, |
| 83 int port, | 83 int port, |
| 84 net::IPEndPoint* ip_end_point); | 84 net::IPEndPoint* ip_end_point); |
| 85 static void IPEndPointToStringAndPort(const net::IPEndPoint& address, | 85 static void IPEndPointToStringAndPort(const net::IPEndPoint& address, |
| 86 std::string* ip_address_str, | 86 std::string* ip_address_str, |
| 87 int* port); | 87 int* port); |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 explicit Socket(ApiResourceEventNotifier* event_notifier); | 90 Socket(const std::string& owner_extension_id_, |
| 91 ApiResourceEventNotifier* event_notifier); |
| 91 | 92 |
| 92 void WriteData(); | 93 void WriteData(); |
| 93 virtual int WriteImpl(net::IOBuffer* io_buffer, | 94 virtual int WriteImpl(net::IOBuffer* io_buffer, |
| 94 int io_buffer_size, | 95 int io_buffer_size, |
| 95 const net::CompletionCallback& callback) = 0; | 96 const net::CompletionCallback& callback) = 0; |
| 96 virtual void OnWriteComplete(int result); | 97 virtual void OnWriteComplete(int result); |
| 97 | 98 |
| 98 const std::string address_; | 99 const std::string address_; |
| 99 int port_; | 100 int port_; |
| 100 bool is_connected_; | 101 bool is_connected_; |
| 101 | 102 |
| 102 private: | 103 private: |
| 103 struct WriteRequest { | 104 struct WriteRequest { |
| 104 WriteRequest(scoped_refptr<net::IOBuffer> io_buffer, | 105 WriteRequest(scoped_refptr<net::IOBuffer> io_buffer, |
| 105 int byte_count, | 106 int byte_count, |
| 106 const CompletionCallback& callback); | 107 const CompletionCallback& callback); |
| 107 ~WriteRequest(); | 108 ~WriteRequest(); |
| 108 scoped_refptr<net::IOBuffer> io_buffer; | 109 scoped_refptr<net::IOBuffer> io_buffer; |
| 109 int byte_count; | 110 int byte_count; |
| 110 CompletionCallback callback; | 111 CompletionCallback callback; |
| 111 int bytes_written; | 112 int bytes_written; |
| 112 }; | 113 }; |
| 113 std::queue<WriteRequest> write_queue_; | 114 std::queue<WriteRequest> write_queue_; |
| 114 scoped_refptr<net::IOBuffer> io_buffer_write_; | 115 scoped_refptr<net::IOBuffer> io_buffer_write_; |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 } // namespace extensions | 118 } // namespace extensions |
| 118 | 119 |
| 119 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ | 120 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ |
| OLD | NEW |