summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 00:25:40 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 00:25:40 +0000
commit1b4209f4c56fbdb6fe72aca508e8aa1c534964d4 (patch)
tree4ada6319dde7c5a46d974cad0007e7332dff858f /ppapi
parent047b4b5470ad1b7888c96c9314af78f41a87f387 (diff)
downloadchromium_src-1b4209f4c56fbdb6fe72aca508e8aa1c534964d4.zip
chromium_src-1b4209f4c56fbdb6fe72aca508e8aa1c534964d4.tar.gz
chromium_src-1b4209f4c56fbdb6fe72aca508e8aa1c534964d4.tar.bz2
Private Pepper extension for Flapper to allow TCP connections to be made
(from inside the renderer sandbox). (Only enabled on ChromeOS, since it opens a hole in the renderer. This should be revisited, with controls tightened, once Flapper runs out of process.) BUG=none TEST=none Review URL: http://codereview.chromium.org/5098002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/private/ppb_flash.h40
-rw-r--r--ppapi/cpp/private/flash.cc64
-rw-r--r--ppapi/cpp/private/flash.h42
3 files changed, 145 insertions, 1 deletions
diff --git a/ppapi/c/private/ppb_flash.h b/ppapi/c/private/ppb_flash.h
index ccc2f0a..49535e4 100644
--- a/ppapi/c/private/ppb_flash.h
+++ b/ppapi/c/private/ppb_flash.h
@@ -17,7 +17,9 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
-#define PPB_FLASH_INTERFACE "PPB_Flash;1"
+// PPB_Flash -------------------------------------------------------------------
+
+#define PPB_FLASH_INTERFACE "PPB_Flash;2"
#ifdef _WIN32
typedef HANDLE PP_FileHandle;
@@ -27,6 +29,7 @@ typedef int PP_FileHandle;
static const PP_FileHandle PP_kInvalidFileHandle = -1;
#endif
+struct PP_CompletionCallback;
struct PP_FontDescription_Dev;
struct PP_FileInfo_Dev;
@@ -114,4 +117,39 @@ struct PPB_Flash {
const char* target);
};
+// PPB_Flash_NetConnector ------------------------------------------------------
+
+#define PPB_FLASH_NETCONNECTOR_INTERFACE "PPB_Flash_NetConnector;1"
+
+// This is an opaque type holding a network address.
+struct PP_Flash_NetAddress {
+ size_t size;
+ char data[128];
+};
+
+struct PPB_Flash_NetConnector {
+ PP_Resource (*Create)(PP_Instance instance_id);
+ PP_Bool (*IsFlashNetConnector)(PP_Resource resource_id);
+
+ // Connect to a TCP port given as a host-port pair. The local and remote
+ // addresses of the connection (if successful) are returned in
+ // |local_addr_out| and |remote_addr_out|, respectively, if non-null.
+ int32_t (*ConnectTcp)(PP_Resource connector_id,
+ const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ struct PP_Flash_NetAddress* local_addr_out,
+ struct PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback);
+
+ // Same as |ConnectTcp()|, but connecting to the address given by |addr|. A
+ // typical use-case would be for reconnections.
+ int32_t (*ConnectTcpAddress)(PP_Resource connector_id,
+ const struct PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ struct PP_Flash_NetAddress* local_addr_out,
+ struct PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback);
+};
+
#endif // PPAPI_C_PRIVATE_PPB_FLASH_H_
diff --git a/ppapi/cpp/private/flash.cc b/ppapi/cpp/private/flash.cc
new file mode 100644
index 0000000..5af96bc
--- /dev/null
+++ b/ppapi/cpp/private/flash.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2011 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.
+
+// TODO(viettrungluu): See the comment in corresponding .h file.
+
+#include "ppapi/cpp/private/flash.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Flash_NetConnector>() {
+ return PPB_FLASH_NETCONNECTOR_INTERFACE;
+}
+
+} // namespace
+
+namespace flash {
+
+NetConnector::NetConnector(const Instance& instance) {
+ if (has_interface<PPB_Flash_NetConnector>()) {
+ PassRefFromConstructor(get_interface<PPB_Flash_NetConnector>()->Create(
+ instance.pp_instance()));
+ }
+}
+
+int32_t NetConnector::ConnectTcp(const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ const CompletionCallback& cc) {
+ if (!has_interface<PPB_Flash_NetConnector>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_NetConnector>()->ConnectTcp(
+ pp_resource(),
+ host, port,
+ socket_out, local_addr_out, remote_addr_out,
+ cc.pp_completion_callback());
+}
+
+int32_t NetConnector::ConnectTcpAddress(const PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ const CompletionCallback& cc) {
+ if (!has_interface<PPB_Flash_NetConnector>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_NetConnector>()->ConnectTcpAddress(
+ pp_resource(),
+ addr,
+ socket_out, local_addr_out, remote_addr_out,
+ cc.pp_completion_callback());
+}
+
+} // namespace flash
+} // namespace pp
diff --git a/ppapi/cpp/private/flash.h b/ppapi/cpp/private/flash.h
new file mode 100644
index 0000000..ffd1353
--- /dev/null
+++ b/ppapi/cpp/private/flash.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 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.
+
+// TODO(viettrungluu): This (and the .cc file) contain C++ wrappers for some
+// things in ppapi/c/private/ppb_flash.h. This is currently not used in (or even
+// compiled with) Chromium.
+
+#ifndef PPAPI_CPP_PRIVATE_FLASH_H_
+#define PPAPI_CPP_PRIVATE_FLASH_H_
+
+#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class CompletionCallback;
+class Instance;
+
+namespace flash {
+
+class NetConnector : public Resource {
+ public:
+ explicit NetConnector(const Instance& instance);
+
+ int32_t ConnectTcp(const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ const CompletionCallback& cc);
+ int32_t ConnectTcpAddress(const PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ const CompletionCallback& cc);
+};
+
+} // namespace flash
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_FLASH_H_