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 #include "chrome/browser/extensions/api/socket/socket.h" | 5 #include "chrome/browser/extensions/api/socket/socket.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" | 8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/ip_endpoint.h" | 11 #include "net/base/ip_endpoint.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/socket/socket.h" | 13 #include "net/socket/socket.h" |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 | 16 |
| 17 const char kSocketTypeNotSupported[] = "Socket type does not support this API"; |
| 18 |
17 Socket::Socket(const std::string& owner_extension_id, | 19 Socket::Socket(const std::string& owner_extension_id, |
18 ApiResourceEventNotifier* event_notifier) | 20 ApiResourceEventNotifier* event_notifier) |
19 : ApiResource(owner_extension_id, event_notifier), | 21 : ApiResource(owner_extension_id, event_notifier), |
20 port_(0), | 22 port_(0), |
21 is_connected_(false) { | 23 is_connected_(false) { |
22 } | 24 } |
23 | 25 |
24 Socket::~Socket() { | 26 Socket::~Socket() { |
25 // Derived destructors should make sure the socket has been closed. | 27 // Derived destructors should make sure the socket has been closed. |
26 DCHECK(!is_connected_); | 28 DCHECK(!is_connected_); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 82 } |
81 | 83 |
82 bool Socket::SetKeepAlive(bool enable, int delay) { | 84 bool Socket::SetKeepAlive(bool enable, int delay) { |
83 return false; | 85 return false; |
84 } | 86 } |
85 | 87 |
86 bool Socket::SetNoDelay(bool no_delay) { | 88 bool Socket::SetNoDelay(bool no_delay) { |
87 return false; | 89 return false; |
88 } | 90 } |
89 | 91 |
| 92 int Socket::Listen(const std::string& address, int port, int backlog, |
| 93 std::string* error_msg) { |
| 94 *error_msg = kSocketTypeNotSupported; |
| 95 return net::ERR_FAILED; |
| 96 } |
| 97 |
| 98 void Socket::Accept(const AcceptCompletionCallback& callback) { |
| 99 callback.Run(net::ERR_FAILED, NULL); |
| 100 } |
| 101 |
90 // static | 102 // static |
91 bool Socket::StringAndPortToIPEndPoint(const std::string& ip_address_str, | 103 bool Socket::StringAndPortToIPEndPoint(const std::string& ip_address_str, |
92 int port, | 104 int port, |
93 net::IPEndPoint* ip_end_point) { | 105 net::IPEndPoint* ip_end_point) { |
94 DCHECK(ip_end_point); | 106 DCHECK(ip_end_point); |
95 net::IPAddressNumber ip_number; | 107 net::IPAddressNumber ip_number; |
96 if (!net::ParseIPLiteralToNumber(ip_address_str, &ip_number)) | 108 if (!net::ParseIPLiteralToNumber(ip_address_str, &ip_number)) |
97 return false; | 109 return false; |
98 | 110 |
99 *ip_end_point = net::IPEndPoint(ip_number, port); | 111 *ip_end_point = net::IPEndPoint(ip_number, port); |
(...skipping 30 matching lines...) Expand all Loading... |
130 const CompletionCallback& callback) | 142 const CompletionCallback& callback) |
131 : io_buffer(io_buffer), | 143 : io_buffer(io_buffer), |
132 byte_count(byte_count), | 144 byte_count(byte_count), |
133 callback(callback), | 145 callback(callback), |
134 bytes_written(0) { | 146 bytes_written(0) { |
135 } | 147 } |
136 | 148 |
137 Socket::WriteRequest::~WriteRequest() { } | 149 Socket::WriteRequest::~WriteRequest() { } |
138 | 150 |
139 } // namespace extensions | 151 } // namespace extensions |
OLD | NEW |