| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/socket/tcp_socket.h" | 5 #include "extensions/browser/api/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "extensions/browser/api/api_resource.h" | 12 #include "extensions/browser/api/api_resource.h" |
| 13 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/base/rand_callback.h" | 16 #include "net/base/rand_callback.h" |
| 17 #include "net/log/net_log_source.h" | 17 #include "net/log/net_log_source.h" |
| 18 #include "net/socket/tcp_client_socket.h" | 18 #include "net/socket/tcp_client_socket.h" |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 const char kTCPSocketTypeInvalidError[] = | 22 const char kTCPSocketTypeInvalidError[] = |
| 23 "Cannot call both connect and listen on the same socket."; | 23 "Cannot call both connect and listen on the same socket."; |
| 24 const char kSocketListenError[] = "Could not listen on the specified port."; | 24 const char kSocketListenError[] = "Could not listen on the specified port."; |
| 25 | 25 |
| 26 static base::LazyInstance< | 26 static base::LazyInstance<BrowserContextKeyedAPIFactory< |
| 27 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPSocket> > > | 27 ApiResourceManager<ResumableTCPSocket>>>::DestructorAtExit g_factory = |
| 28 g_factory = LAZY_INSTANCE_INITIALIZER; | 28 LAZY_INSTANCE_INITIALIZER; |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 template <> | 31 template <> |
| 32 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPSocket> >* | 32 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPSocket> >* |
| 33 ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance() { | 33 ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance() { |
| 34 return g_factory.Pointer(); | 34 return g_factory.Pointer(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 static base::LazyInstance<BrowserContextKeyedAPIFactory< | 37 static base::LazyInstance<BrowserContextKeyedAPIFactory< |
| 38 ApiResourceManager<ResumableTCPServerSocket> > > g_server_factory = | 38 ApiResourceManager<ResumableTCPServerSocket>>>::DestructorAtExit |
| 39 LAZY_INSTANCE_INITIALIZER; | 39 g_server_factory = LAZY_INSTANCE_INITIALIZER; |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 template <> | 42 template <> |
| 43 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPServerSocket> >* | 43 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableTCPServerSocket> >* |
| 44 ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance() { | 44 ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance() { |
| 45 return g_server_factory.Pointer(); | 45 return g_server_factory.Pointer(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 TCPSocket::TCPSocket(const std::string& owner_extension_id) | 48 TCPSocket::TCPSocket(const std::string& owner_extension_id) |
| 49 : Socket(owner_extension_id), socket_mode_(UNKNOWN) {} | 49 : Socket(owner_extension_id), socket_mode_(UNKNOWN) {} |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } | 374 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } |
| 375 | 375 |
| 376 ResumableTCPServerSocket::ResumableTCPServerSocket( | 376 ResumableTCPServerSocket::ResumableTCPServerSocket( |
| 377 const std::string& owner_extension_id) | 377 const std::string& owner_extension_id) |
| 378 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} | 378 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} |
| 379 | 379 |
| 380 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } | 380 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } |
| 381 | 381 |
| 382 } // namespace extensions | 382 } // namespace extensions |
| OLD | NEW |