summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-09 01:53:23 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-09 01:53:23 +0000
commit6903130df04c68841a9815be736a6b4eb5b393c1 (patch)
treedab0d15397a7b4e68800e9fbc0ea5dfe18cb2e67 /ppapi/cpp
parent6c8bbcb719653d761d688d3a47d85a8451e498e4 (diff)
downloadchromium_src-6903130df04c68841a9815be736a6b4eb5b393c1.zip
chromium_src-6903130df04c68841a9815be736a6b4eb5b393c1.tar.gz
chromium_src-6903130df04c68841a9815be736a6b4eb5b393c1.tar.bz2
Re-land r109086: Add private Pepper API for dealing with PP_Flash_NetAddress.
[The Win components build was already fixed, and the broken unrevert reverted. The original review was here: http://codereview.chromium.org/8357030 .] BUG=none TEST=none Review URL: http://codereview.chromium.org/8496045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/private/flash_net_address.cc81
-rw-r--r--ppapi/cpp/private/flash_net_address.h38
2 files changed, 119 insertions, 0 deletions
diff --git a/ppapi/cpp/private/flash_net_address.cc b/ppapi/cpp/private/flash_net_address.cc
new file mode 100644
index 0000000..93984d7
--- /dev/null
+++ b/ppapi/cpp/private/flash_net_address.cc
@@ -0,0 +1,81 @@
+// 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_net_address.h"
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
+#include "ppapi/c/private/ppb_flash_net_address.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Flash_NetAddress>() {
+ return PPB_FLASH_NETADDRESS_INTERFACE;
+}
+
+} // namespace
+
+namespace flash {
+
+// static
+bool NetAddress::AreEqual(const PP_Flash_NetAddress& addr1,
+ const PP_Flash_NetAddress& addr2) {
+ if (!has_interface<PPB_Flash_NetAddress>())
+ return false;
+ return !!get_interface<PPB_Flash_NetAddress>()->AreEqual(&addr1, &addr2);
+}
+
+// static
+bool NetAddress::AreHostsEqual(const PP_Flash_NetAddress& addr1,
+ const PP_Flash_NetAddress& addr2) {
+ if (!has_interface<PPB_Flash_NetAddress>())
+ return false;
+ return !!get_interface<PPB_Flash_NetAddress>()->AreHostsEqual(&addr1, &addr2);
+}
+
+// static
+std::string NetAddress::Describe(const PP_Flash_NetAddress& addr,
+ bool include_port) {
+ if (!has_interface<PPB_Flash_NetAddress>())
+ return std::string();
+
+ Module* module = Module::Get();
+ if (!module)
+ return std::string();
+
+ Var result(Var::PassRef(),
+ get_interface<PPB_Flash_NetAddress>()->Describe(
+ module->pp_module(),
+ &addr,
+ PP_FromBool(include_port)));
+ return result.is_string() ? result.AsString() : std::string();
+}
+
+// static
+bool NetAddress::ReplacePort(const PP_Flash_NetAddress& addr_in,
+ uint16_t port,
+ PP_Flash_NetAddress* addr_out) {
+ if (!has_interface<PPB_Flash_NetAddress>())
+ return false;
+ return !!get_interface<PPB_Flash_NetAddress>()->ReplacePort(&addr_in,
+ port,
+ addr_out);
+}
+
+// static
+void NetAddress::GetAnyAddress(bool is_ipv6, PP_Flash_NetAddress* addr) {
+ if (!has_interface<PPB_Flash_NetAddress>())
+ return;
+ get_interface<PPB_Flash_NetAddress>()->GetAnyAddress(PP_FromBool(is_ipv6),
+ addr);
+}
+
+} // namespace flash
+} // namespace pp
diff --git a/ppapi/cpp/private/flash_net_address.h b/ppapi/cpp/private/flash_net_address.h
new file mode 100644
index 0000000..f08cb52
--- /dev/null
+++ b/ppapi/cpp/private/flash_net_address.h
@@ -0,0 +1,38 @@
+// 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 things
+// in ppapi/c/private/ppb_flash_net_address.h. This is currently not used in
+// (or even compiled with) Chromium.
+
+#ifndef PPAPI_CPP_PRIVATE_FLASH_NET_ADDRESS_H_
+#define PPAPI_CPP_PRIVATE_FLASH_NET_ADDRESS_H_
+
+#include <string>
+
+#include "ppapi/c/pp_stdint.h"
+
+struct PP_Flash_NetAddress;
+
+namespace pp {
+namespace flash {
+
+class NetAddress {
+ public:
+ static bool AreEqual(const PP_Flash_NetAddress& addr1,
+ const PP_Flash_NetAddress& addr2);
+ static bool AreHostsEqual(const PP_Flash_NetAddress& addr1,
+ const PP_Flash_NetAddress& addr2);
+ static std::string Describe(const PP_Flash_NetAddress& addr,
+ bool include_port);
+ static bool ReplacePort(const PP_Flash_NetAddress& addr_in,
+ uint16_t port,
+ PP_Flash_NetAddress* addr_out);
+ static void GetAnyAddress(bool is_ipv6, PP_Flash_NetAddress* addr);
+};
+
+} // namespace flash
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_FLASH_NET_ADDRESS_H_