summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-01 16:58:14 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-01 16:58:14 +0000
commit373a95aa69caa254f250c40f4483d6ac2b8c780c (patch)
tree85ff9884a544a7197e037d045bdb8982b9a8b9f9 /ppapi/cpp
parent1960edd57c9a2389229a774ef8f66597c28ca1fb (diff)
downloadchromium_src-373a95aa69caa254f250c40f4483d6ac2b8c780c.zip
chromium_src-373a95aa69caa254f250c40f4483d6ac2b8c780c.tar.gz
chromium_src-373a95aa69caa254f250c40f4483d6ac2b8c780c.tar.bz2
Re-land the reverted CL:
http://src.chromium.org/viewvc/chrome?view=rev&revision=91150 Comparing with the previous CL, this CL makes changes to ppapi/proxy/ppapi_proxy_test.{h,cc} TEST=None BUG=None Review URL: http://codereview.chromium.org/7210030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/private/flash_tcp_socket.cc102
-rw-r--r--ppapi/cpp/private/flash_tcp_socket.h48
2 files changed, 150 insertions, 0 deletions
diff --git a/ppapi/cpp/private/flash_tcp_socket.cc b/ppapi/cpp/private/flash_tcp_socket.cc
new file mode 100644
index 0000000..f5b4633
--- /dev/null
+++ b/ppapi/cpp/private/flash_tcp_socket.cc
@@ -0,0 +1,102 @@
+// 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(yzshen): See the comment in corresponding .h file.
+
+#include "ppapi/cpp/private/flash_tcp_socket.h"
+
+#include "ppapi/c/pp_bool.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_TCPSocket>() {
+ return PPB_FLASH_TCPSOCKET_INTERFACE;
+}
+
+} // namespace
+
+namespace flash {
+
+TCPSocket::TCPSocket(Instance* instance) {
+ if (has_interface<PPB_Flash_TCPSocket>() && instance) {
+ PassRefFromConstructor(get_interface<PPB_Flash_TCPSocket>()->Create(
+ instance->pp_instance()));
+ }
+}
+
+int32_t TCPSocket::Connect(const char* host,
+ uint16_t port,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_TCPSocket>()->Connect(
+ pp_resource(), host, port, callback.pp_completion_callback());
+}
+
+int32_t TCPSocket::ConnectWithNetAddress(const PP_Flash_NetAddress* addr,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_TCPSocket>()->ConnectWithNetAddress(
+ pp_resource(), addr, callback.pp_completion_callback());
+}
+
+bool TCPSocket::GetLocalAddress(PP_Flash_NetAddress* local_addr) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return false;
+
+ PP_Bool result = get_interface<PPB_Flash_TCPSocket>()->GetLocalAddress(
+ pp_resource(), local_addr);
+ return PP_ToBool(result);
+}
+
+bool TCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return false;
+ PP_Bool result = get_interface<PPB_Flash_TCPSocket>()->GetRemoteAddress(
+ pp_resource(), remote_addr);
+ return PP_ToBool(result);
+}
+
+int32_t TCPSocket::InitiateSSL(const char* server_name,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_TCPSocket>()->InitiateSSL(
+ pp_resource(), server_name, callback.pp_completion_callback());
+}
+
+int32_t TCPSocket::Read(char* buffer,
+ int32_t bytes_to_read,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_TCPSocket>()->Read(
+ pp_resource(), buffer, bytes_to_read, callback.pp_completion_callback());
+}
+
+int32_t TCPSocket::Write(const char* buffer,
+ int32_t bytes_to_write,
+ const CompletionCallback& callback) {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_Flash_TCPSocket>()->Write(
+ pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback());
+}
+
+void TCPSocket::Disconnect() {
+ if (!has_interface<PPB_Flash_TCPSocket>())
+ return;
+ return get_interface<PPB_Flash_TCPSocket>()->Disconnect(pp_resource());
+}
+
+} // namespace flash
+} // namespace pp
diff --git a/ppapi/cpp/private/flash_tcp_socket.h b/ppapi/cpp/private/flash_tcp_socket.h
new file mode 100644
index 0000000..8998728
--- /dev/null
+++ b/ppapi/cpp/private/flash_tcp_socket.h
@@ -0,0 +1,48 @@
+// 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(yzshen): This (and the .cc file) contain C++ wrappers for things
+// in ppapi/c/private/ppb_flash_tcp_socket.h. This is currently not used in
+// (or even compiled with) Chromium.
+
+#ifndef PPAPI_CPP_PRIVATE_FLASH_TCP_SOCKET_H_
+#define PPAPI_CPP_PRIVATE_FLASH_TCP_SOCKET_H_
+
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/private/ppb_flash_tcp_socket.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class CompletionCallback;
+class Instance;
+
+namespace flash {
+
+class TCPSocket : public Resource {
+ public:
+ explicit TCPSocket(Instance* instance);
+
+ int32_t Connect(const char* host,
+ uint16_t port,
+ const CompletionCallback& callback);
+ int32_t ConnectWithNetAddress(const PP_Flash_NetAddress* addr,
+ const CompletionCallback& callback);
+ bool GetLocalAddress(PP_Flash_NetAddress* local_addr);
+ bool GetRemoteAddress(PP_Flash_NetAddress* remote_addr);
+ int32_t InitiateSSL(const char* server_name,
+ const CompletionCallback& callback);
+ int32_t Read(char* buffer,
+ int32_t bytes_to_read,
+ const CompletionCallback& callback);
+ int32_t Write(const char* buffer,
+ int32_t bytes_to_write,
+ const CompletionCallback& callback);
+ void Disconnect();
+};
+
+} // namespace flash
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_FLASH_TCP_SOCKET_H_