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 "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "chrome/browser/extensions/api/api_resource_manager.h" | 9 #include "chrome/browser/extensions/api/api_resource_manager.h" |
10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/socket/socket.h" | 14 #include "net/socket/socket.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 const char kSocketTypeNotSupported[] = "Socket type does not support this API"; | 18 const char kSocketTypeNotSupported[] = "Socket type does not support this API"; |
19 | 19 |
20 static base::LazyInstance<ProfileKeyedAPIFactory<ApiResourceManager<Socket> > > | 20 static base::LazyInstance<ProfileKeyedAPIFactory<ApiResourceManager<Socket> > > |
21 g_factory = LAZY_INSTANCE_INITIALIZER; | 21 g_factory = LAZY_INSTANCE_INITIALIZER; |
22 | 22 |
23 // static | 23 // static |
24 template <> | 24 template <> |
25 ProfileKeyedAPIFactory<ApiResourceManager<Socket> >* | 25 ProfileKeyedAPIFactory<ApiResourceManager<Socket> >* |
26 ApiResourceManager<Socket>::GetFactoryInstance() { | 26 ApiResourceManager<Socket>::GetFactoryInstance() { |
27 return &g_factory.Get(); | 27 return g_factory.Pointer(); |
28 } | 28 } |
29 | 29 |
30 Socket::Socket(const std::string& owner_extension_id) | 30 Socket::Socket(const std::string& owner_extension_id) |
31 : ApiResource(owner_extension_id), is_connected_(false) { | 31 : ApiResource(owner_extension_id), is_connected_(false) { |
32 } | 32 } |
33 | 33 |
34 Socket::~Socket() { | 34 Socket::~Socket() { |
35 // Derived destructors should make sure the socket has been closed. | 35 // Derived destructors should make sure the socket has been closed. |
36 DCHECK(!is_connected_); | 36 DCHECK(!is_connected_); |
37 } | 37 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 const CompletionCallback& callback) | 146 const CompletionCallback& callback) |
147 : io_buffer(io_buffer), | 147 : io_buffer(io_buffer), |
148 byte_count(byte_count), | 148 byte_count(byte_count), |
149 callback(callback), | 149 callback(callback), |
150 bytes_written(0) { | 150 bytes_written(0) { |
151 } | 151 } |
152 | 152 |
153 Socket::WriteRequest::~WriteRequest() { } | 153 Socket::WriteRequest::~WriteRequest() { } |
154 | 154 |
155 } // namespace extensions | 155 } // namespace extensions |
OLD | NEW |