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

Unified Diff: webkit/plugins/ppapi/ppb_tcp_socket_private_impl.cc

Issue 9283022: Exposed Listen and Accept methods to plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Sync. Created 8 years, 10 months 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h ('k') | webkit/plugins/ppapi/resource_creation_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_tcp_socket_private_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_tcp_socket_private_impl.cc b/webkit/plugins/ppapi/ppb_tcp_socket_private_impl.cc
index 61fc83c4c14656cbe7f34a0bfa46d37f0506ad9f..06489aa593792da0f037bc47f97abc9923546344 100644
--- a/webkit/plugins/ppapi/ppb_tcp_socket_private_impl.cc
+++ b/webkit/plugins/ppapi/ppb_tcp_socket_private_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,11 +22,10 @@ PPB_TCPSocket_Private_Impl::~PPB_TCPSocket_Private_Impl() {
}
PP_Resource PPB_TCPSocket_Private_Impl::CreateResource(PP_Instance instance) {
- PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance);
- if (!plugin_instance)
+ PluginDelegate* plugin_delegate = GetPluginDelegate(instance);
+ if (!plugin_delegate)
return 0;
- PluginDelegate* plugin_delegate = plugin_instance->delegate();
uint32 socket_id = plugin_delegate->TCPSocketCreate();
if (!socket_id)
return 0;
@@ -34,6 +33,27 @@ PP_Resource PPB_TCPSocket_Private_Impl::CreateResource(PP_Instance instance) {
return (new PPB_TCPSocket_Private_Impl(instance, socket_id))->GetReference();
}
+PP_Resource PPB_TCPSocket_Private_Impl::CreateConnectedSocket(
+ PP_Instance instance,
+ uint32 socket_id,
+ const PP_NetAddress_Private& local_addr,
+ const PP_NetAddress_Private& remote_addr) {
+ PluginDelegate* plugin_delegate = GetPluginDelegate(instance);
+ if (!plugin_delegate)
+ return 0;
+
+ PPB_TCPSocket_Private_Impl* socket =
+ new PPB_TCPSocket_Private_Impl(instance, socket_id);
+
+ socket->connection_state_ = PPB_TCPSocket_Private_Impl::CONNECTED;
+ socket->local_addr_ = local_addr;
+ socket->remote_addr_ = remote_addr;
+
+ plugin_delegate->RegisterTCPSocket(socket, socket_id);
+
+ return socket->GetReference();
+}
+
void PPB_TCPSocket_Private_Impl::SendConnect(const std::string& host,
uint16_t port) {
PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
@@ -87,5 +107,13 @@ void PPB_TCPSocket_Private_Impl::SendDisconnect() {
plugin_delegate->TCPSocketDisconnect(socket_id_);
}
+PluginDelegate* PPB_TCPSocket_Private_Impl::GetPluginDelegate(
+ PP_Instance instance) {
+ PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance);
+ if (!plugin_instance)
+ return NULL;
+ return plugin_instance->delegate();
+}
+
} // namespace ppapi
} // namespace webkit
« no previous file with comments | « webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h ('k') | webkit/plugins/ppapi/resource_creation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698