| 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 Socket::Socket(APIResourceEventNotifier* event_notifier) | 17 Socket::Socket(ApiResourceEventNotifier* event_notifier) |
| 18 : APIResource(APIResource::SocketResource, event_notifier), | 18 : ApiResource(event_notifier), |
| 19 port_(0), | 19 port_(0), |
| 20 is_connected_(false) { | 20 is_connected_(false) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 Socket::~Socket() { | 23 Socket::~Socket() { |
| 24 // Derived destructors should make sure the socket has been closed. | 24 // Derived destructors should make sure the socket has been closed. |
| 25 DCHECK(!is_connected_); | 25 DCHECK(!is_connected_); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void Socket::Write(scoped_refptr<net::IOBuffer> io_buffer, | 28 void Socket::Write(scoped_refptr<net::IOBuffer> io_buffer, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 DCHECK(port); | 114 DCHECK(port); |
| 115 *ip_address_str = address.ToStringWithoutPort(); | 115 *ip_address_str = address.ToStringWithoutPort(); |
| 116 if (ip_address_str->empty()) { | 116 if (ip_address_str->empty()) { |
| 117 *port = 0; | 117 *port = 0; |
| 118 } else { | 118 } else { |
| 119 *port = address.port(); | 119 *port = address.port(); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace extensions | 123 } // namespace extensions |
| OLD | NEW |