Index: extensions/browser/api/socket/socket_api.h |
diff --git a/extensions/browser/api/socket/socket_api.h b/extensions/browser/api/socket/socket_api.h |
index 60bd765b372edc4523f5e565ecc917c0a87c4a6c..017fcf8af8659b618181f13e7ecbcdc24790626f 100644 |
--- a/extensions/browser/api/socket/socket_api.h |
+++ b/extensions/browser/api/socket/socket_api.h |
@@ -24,10 +24,12 @@ class ResourceContext; |
namespace net { |
class IOBuffer; |
+class URLRequestContextGetter; |
+class SSLClientSocket; |
} |
namespace extensions { |
- |
+class TLSSocket; |
class Socket; |
// A simple interface to ApiResourceManager<Socket> or derived class. The goal |
@@ -39,9 +41,14 @@ class SocketResourceManagerInterface { |
virtual ~SocketResourceManagerInterface() {} |
virtual bool SetBrowserContext(content::BrowserContext* context) = 0; |
- virtual int Add(Socket* socket) = 0; |
- virtual Socket* Get(const std::string& extension_id, int api_resource_id) = 0; |
- virtual void Remove(const std::string& extension_id, int api_resource_id) = 0; |
+ virtual int Add(Socket *socket) = 0; |
+ virtual Socket* Get(const std::string& extension_id, |
+ int api_resource_id) = 0; |
+ virtual void Remove(const std::string& extension_id, |
+ int api_resource_id) = 0; |
+ virtual void Replace(const std::string& extension_id, |
+ int api_resource_id, |
+ Socket* socket) = 0; |
virtual base::hash_set<int>* GetResourceIds( |
const std::string& extension_id) = 0; |
}; |
@@ -73,6 +80,12 @@ class SocketResourceManager : public SocketResourceManagerInterface { |
return manager_->Get(extension_id, api_resource_id); |
} |
+ virtual void Replace(const std::string& extension_id, |
+ int api_resource_id, |
+ Socket* socket) OVERRIDE { |
+ manager_->Replace(extension_id, api_resource_id, static_cast<T*>(socket)); |
+ } |
+ |
virtual void Remove(const std::string& extension_id, |
int api_resource_id) OVERRIDE { |
manager_->Remove(extension_id, api_resource_id); |
@@ -103,6 +116,7 @@ class SocketAsyncApiFunction : public AsyncApiFunction { |
int AddSocket(Socket* socket); |
Socket* GetSocket(int api_resource_id); |
+ void ReplaceSocket(int api_resource_id, Socket* socket); |
void RemoveSocket(int api_resource_id); |
base::hash_set<int>* GetSocketIds(); |
@@ -502,6 +516,29 @@ class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction { |
private: |
scoped_ptr<core_api::socket::GetJoinedGroups::Params> params_; |
}; |
+ |
+class SocketSecureFunction : public SocketAsyncApiFunction { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("socket.secure", SOCKET_SECURE); |
+ SocketSecureFunction(); |
+ |
+ protected: |
+ virtual ~SocketSecureFunction(); |
+ |
+ // AsyncApiFunction |
+ virtual bool Prepare() OVERRIDE; |
+ virtual void AsyncWorkStart() OVERRIDE; |
+ |
+ private: |
+ // Callback from TLSSocket::UpgradeSocketToTLS(). |
+ void TlsConnectDone(scoped_ptr<TLSSocket> socket, int result); |
+ |
+ scoped_ptr<core_api::socket::Secure::Params> params_; |
+ scoped_refptr<net::URLRequestContextGetter> url_request_getter_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); |
+}; |
+ |
} // namespace extensions |
#endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |