Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: chrome/browser/extensions/api/socket/socket_api.h

Issue 76403004: An implementation of chrome.socket.secure(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another round of responses to Renaud. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/socket/socket_api.h
diff --git a/chrome/browser/extensions/api/socket/socket_api.h b/chrome/browser/extensions/api/socket/socket_api.h
index c52bf6dd5ce64ca386efad81e0396d4e05ac32cc..d48d7fbfa9c072524cb31b65b6d22473d59bb90c 100644
--- a/chrome/browser/extensions/api/socket/socket_api.h
+++ b/chrome/browser/extensions/api/socket/socket_api.h
@@ -21,10 +21,12 @@ class IOThread;
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
@@ -41,6 +43,8 @@ class SocketResourceManagerInterface {
int api_resource_id) = 0;
virtual void Remove(const std::string& extension_id,
int api_resource_id) = 0;
+ virtual void Set(const std::string& extension_id, int api_resource_id,
Ryan Sleevi 2013/12/17 00:37:40 style nit: api_resource_id should be on its own li
lally 2014/01/09 18:47:16 Done.
+ Socket *socket) = 0;
virtual base::hash_set<int>* GetResourceIds(
const std::string& extension_id) = 0;
};
@@ -73,6 +77,11 @@ class SocketResourceManager : public SocketResourceManagerInterface {
return manager_->Get(extension_id, api_resource_id);
}
+ virtual void Set(const std::string& extension_id, int api_resource_id,
+ Socket *socket) OVERRIDE {
+ manager_->Set(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 +112,7 @@ class SocketAsyncApiFunction : public AsyncApiFunction {
int AddSocket(Socket* socket);
Socket* GetSocket(int api_resource_id);
+ void SetSocket(int api_resource_id, Socket* socket);
void RemoveSocket(int api_resource_id);
base::hash_set<int>* GetSocketIds();
@@ -504,6 +514,27 @@ class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction {
private:
scoped_ptr<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:
Ryan Sleevi 2013/12/17 00:37:40 DISALLOW_COPY_AND_ASSIGN ? Although this seems to
lally 2014/01/09 18:47:16 Done.
+ // Callback from TLSSocket::SecureTCPSocket().
+ void TlsConnectDone(TLSSocket* socket, int result);
+
+ scoped_ptr<api::socket::Secure::Params> params_;
+ net::URLRequestContextGetter* url_request_getter_;
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_

Powered by Google App Engine
This is Rietveld 408576698