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 "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/socket/socket.h" | 12 #include "net/socket/socket.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 const char kSocketTypeNotSupported[] = "Socket type does not support this API"; | 16 const char kSocketTypeNotSupported[] = "Socket type does not support this API"; |
17 | 17 |
18 Socket::Socket(const std::string& owner_extension_id) | 18 Socket::Socket(const std::string& owner_extension_id) |
19 : ApiResource(owner_extension_id, NULL), | 19 : ApiResource(owner_extension_id), is_connected_(false) { |
20 is_connected_(false) { | |
21 } | 20 } |
22 | 21 |
23 Socket::~Socket() { | 22 Socket::~Socket() { |
24 // Derived destructors should make sure the socket has been closed. | 23 // Derived destructors should make sure the socket has been closed. |
25 DCHECK(!is_connected_); | 24 DCHECK(!is_connected_); |
26 } | 25 } |
27 | 26 |
28 void Socket::Write(scoped_refptr<net::IOBuffer> io_buffer, | 27 void Socket::Write(scoped_refptr<net::IOBuffer> io_buffer, |
29 int byte_count, | 28 int byte_count, |
30 const CompletionCallback& callback) { | 29 const CompletionCallback& callback) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const CompletionCallback& callback) | 138 const CompletionCallback& callback) |
140 : io_buffer(io_buffer), | 139 : io_buffer(io_buffer), |
141 byte_count(byte_count), | 140 byte_count(byte_count), |
142 callback(callback), | 141 callback(callback), |
143 bytes_written(0) { | 142 bytes_written(0) { |
144 } | 143 } |
145 | 144 |
146 Socket::WriteRequest::~WriteRequest() { } | 145 Socket::WriteRequest::~WriteRequest() { } |
147 | 146 |
148 } // namespace extensions | 147 } // namespace extensions |
OLD | NEW |