summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
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/cpp
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/cpp')
-rw-r--r--ppapi/cpp/private/flash.cc64
-rw-r--r--ppapi/cpp/private/flash.h42
2 files changed, 106 insertions, 0 deletions
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_