| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_SOCKET_SOCKET_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SOCKET_SOCKET_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SOCKET_SOCKET_H_ | 6 #define EXTENSIONS_BROWSER_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 "extensions/browser/api/api_resource.h" | 14 #include "extensions/browser/api/api_resource.h" |
| 15 #include "extensions/browser/api/api_resource_manager.h" | 15 #include "extensions/browser/api/api_resource_manager.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
| 18 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
| 19 #include "net/socket/tcp_client_socket.h" | 19 #include "net/socket/tcp_client_socket.h" |
| 20 | 20 |
| 21 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 22 #include "chromeos/network/firewall_hole.h" | 22 #include "extensions/browser/api/socket/app_firewall_hole_manager.h" |
| 23 #endif // OS_CHROMEOS | 23 #endif // OS_CHROMEOS |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 class AddressList; | 26 class AddressList; |
| 27 class IPEndPoint; | 27 class IPEndPoint; |
| 28 class Socket; | 28 class Socket; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace extensions { | 31 namespace extensions { |
| 32 | 32 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 53 // socket to TLS, and thusly has not invoked set_hostname(). | 53 // socket to TLS, and thusly has not invoked set_hostname(). |
| 54 const std::string& hostname() const { return hostname_; } | 54 const std::string& hostname() const { return hostname_; } |
| 55 | 55 |
| 56 // Set the hostname of the remote host that this socket is connected to. | 56 // Set the hostname of the remote host that this socket is connected to. |
| 57 // Note: This may be an IP literal. In the case of IDNs, this should be a | 57 // Note: This may be an IP literal. In the case of IDNs, this should be a |
| 58 // series of U-LABELs (UTF-8), not A-LABELs. IP literals for IPv6 will be | 58 // series of U-LABELs (UTF-8), not A-LABELs. IP literals for IPv6 will be |
| 59 // unbracketed. | 59 // unbracketed. |
| 60 void set_hostname(const std::string& hostname) { hostname_ = hostname; } | 60 void set_hostname(const std::string& hostname) { hostname_ = hostname; } |
| 61 | 61 |
| 62 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
| 63 void set_firewall_hole(scoped_ptr<chromeos::FirewallHole> firewall_hole) { | 63 void set_firewall_hole( |
| 64 firewall_hole_.reset(firewall_hole.release()); | 64 scoped_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread> |
| 65 firewall_hole) { |
| 66 firewall_hole_ = firewall_hole.Pass(); |
| 65 } | 67 } |
| 66 #endif // OS_CHROMEOS | 68 #endif // OS_CHROMEOS |
| 67 | 69 |
| 68 // Note: |address| contains the resolved IP address, not the hostname of | 70 // Note: |address| contains the resolved IP address, not the hostname of |
| 69 // the remote endpoint. In order to upgrade this socket to TLS, callers | 71 // the remote endpoint. In order to upgrade this socket to TLS, callers |
| 70 // must also supply the hostname of the endpoint via set_hostname(). | 72 // must also supply the hostname of the endpoint via set_hostname(). |
| 71 virtual void Connect(const std::string& address, | 73 virtual void Connect(const std::string& address, |
| 72 uint16 port, | 74 uint16 port, |
| 73 const CompletionCallback& callback) = 0; | 75 const CompletionCallback& callback) = 0; |
| 74 virtual void Disconnect() = 0; | 76 virtual void Disconnect() = 0; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 scoped_refptr<net::IOBuffer> io_buffer; | 143 scoped_refptr<net::IOBuffer> io_buffer; |
| 142 int byte_count; | 144 int byte_count; |
| 143 CompletionCallback callback; | 145 CompletionCallback callback; |
| 144 int bytes_written; | 146 int bytes_written; |
| 145 }; | 147 }; |
| 146 std::queue<WriteRequest> write_queue_; | 148 std::queue<WriteRequest> write_queue_; |
| 147 scoped_refptr<net::IOBuffer> io_buffer_write_; | 149 scoped_refptr<net::IOBuffer> io_buffer_write_; |
| 148 | 150 |
| 149 #if defined(OS_CHROMEOS) | 151 #if defined(OS_CHROMEOS) |
| 150 // Represents a hole punched in the system firewall for this socket. | 152 // Represents a hole punched in the system firewall for this socket. |
| 151 scoped_ptr<chromeos::FirewallHole, content::BrowserThread::DeleteOnUIThread> | 153 scoped_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread> |
| 152 firewall_hole_; | 154 firewall_hole_; |
| 153 #endif // OS_CHROMEOS | 155 #endif // OS_CHROMEOS |
| 154 }; | 156 }; |
| 155 | 157 |
| 156 } // namespace extensions | 158 } // namespace extensions |
| 157 | 159 |
| 158 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_H_ | 160 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_H_ |
| OLD | NEW |