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/tcp_socket.h" | 5 #include "chrome/browser/extensions/api/socket/tcp_socket.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/api_resource.h" | 7 #include "chrome/browser/extensions/api/api_resource.h" |
8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/base/rand_callback.h" | 11 #include "net/base/rand_callback.h" |
12 #include "net/socket/tcp_client_socket.h" | 12 #include "net/socket/tcp_client_socket.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 const char kTCPSocketTypeInvalidError[] = | 16 const char kTCPSocketTypeInvalidError[] = |
17 "Cannot call both connect and listen on the same socket."; | 17 "Cannot call both connect and listen on the same socket."; |
18 const char kSocketListenError[] = "Could not listen on the specified port."; | 18 const char kSocketListenError[] = "Could not listen on the specified port."; |
19 | 19 |
20 static base::LazyInstance<ProfileKeyedAPIFactory< | 20 static base::LazyInstance< |
21 ApiResourceManager<ResumableTCPSocket> > > | 21 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPSocket> > > |
22 g_factory = LAZY_INSTANCE_INITIALIZER; | 22 g_factory = LAZY_INSTANCE_INITIALIZER; |
23 | 23 |
24 // static | 24 // static |
25 template <> | 25 template <> |
26 ProfileKeyedAPIFactory<ApiResourceManager<ResumableTCPSocket> >* | 26 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPSocket> >* |
27 ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance() { | 27 ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance() { |
28 return g_factory.Pointer(); | 28 return g_factory.Pointer(); |
29 } | 29 } |
30 | 30 |
31 static base::LazyInstance<ProfileKeyedAPIFactory< | 31 static base::LazyInstance<BrowserContextKeyedAPIFactory< |
32 ApiResourceManager<ResumableTCPServerSocket> > > | 32 ApiResourceManager<ResumableTCPServerSocket> > > g_server_factory = |
33 g_server_factory = LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
34 | 34 |
35 // static | 35 // static |
36 template <> | 36 template <> |
37 ProfileKeyedAPIFactory<ApiResourceManager<ResumableTCPServerSocket> >* | 37 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPServerSocket> >* |
38 ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance() { | 38 ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance() { |
39 return g_server_factory.Pointer(); | 39 return g_server_factory.Pointer(); |
40 } | 40 } |
41 | 41 |
42 TCPSocket::TCPSocket(const std::string& owner_extension_id) | 42 TCPSocket::TCPSocket(const std::string& owner_extension_id) |
43 : Socket(owner_extension_id), | 43 : Socket(owner_extension_id), |
44 socket_mode_(UNKNOWN) { | 44 socket_mode_(UNKNOWN) { |
45 } | 45 } |
46 | 46 |
47 TCPSocket::TCPSocket(net::TCPClientSocket* tcp_client_socket, | 47 TCPSocket::TCPSocket(net::TCPClientSocket* tcp_client_socket, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 : TCPSocket(owner_extension_id), | 331 : TCPSocket(owner_extension_id), |
332 persistent_(false), | 332 persistent_(false), |
333 paused_(false) { | 333 paused_(false) { |
334 } | 334 } |
335 | 335 |
336 bool ResumableTCPServerSocket::IsPersistent() const { | 336 bool ResumableTCPServerSocket::IsPersistent() const { |
337 return persistent(); | 337 return persistent(); |
338 } | 338 } |
339 | 339 |
340 } // namespace extensions | 340 } // namespace extensions |
OLD | NEW |