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< |
21 g_factory = LAZY_INSTANCE_INITIALIZER; | 21 BrowserContextKeyedAPIFactory<ApiResourceManager<Socket> > > g_factory = |
| 22 LAZY_INSTANCE_INITIALIZER; |
22 | 23 |
23 // static | 24 // static |
24 template <> | 25 template <> |
25 ProfileKeyedAPIFactory<ApiResourceManager<Socket> >* | 26 BrowserContextKeyedAPIFactory<ApiResourceManager<Socket> >* |
26 ApiResourceManager<Socket>::GetFactoryInstance() { | 27 ApiResourceManager<Socket>::GetFactoryInstance() { |
27 return g_factory.Pointer(); | 28 return g_factory.Pointer(); |
28 } | 29 } |
29 | 30 |
30 Socket::Socket(const std::string& owner_extension_id) | 31 Socket::Socket(const std::string& owner_extension_id) |
31 : ApiResource(owner_extension_id), is_connected_(false) { | 32 : ApiResource(owner_extension_id), is_connected_(false) { |
32 } | 33 } |
33 | 34 |
34 Socket::~Socket() { | 35 Socket::~Socket() { |
35 // Derived destructors should make sure the socket has been closed. | 36 // Derived destructors should make sure the socket has been closed. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 const CompletionCallback& callback) | 147 const CompletionCallback& callback) |
147 : io_buffer(io_buffer), | 148 : io_buffer(io_buffer), |
148 byte_count(byte_count), | 149 byte_count(byte_count), |
149 callback(callback), | 150 callback(callback), |
150 bytes_written(0) { | 151 bytes_written(0) { |
151 } | 152 } |
152 | 153 |
153 Socket::WriteRequest::~WriteRequest() { } | 154 Socket::WriteRequest::~WriteRequest() { } |
154 | 155 |
155 } // namespace extensions | 156 } // namespace extensions |
OLD | NEW |