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

Unified Diff: ppapi/cpp/dev/udp_socket_dev.cc

Issue 16282005: Introduce PPB_UDPSocket_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 | « ppapi/cpp/dev/udp_socket_dev.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/udp_socket_dev.cc
diff --git a/ppapi/cpp/dev/udp_socket_dev.cc b/ppapi/cpp/dev/udp_socket_dev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..32a8e5ddfcde5d53e6dd18549900765a6272aeae
--- /dev/null
+++ b/ppapi/cpp/dev/udp_socket_dev.cc
@@ -0,0 +1,111 @@
+// Copyright (c) 2013 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.
+
+#include "ppapi/cpp/dev/udp_socket_dev.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_UDPSocket_Dev_0_1>() {
+ return PPB_UDPSOCKET_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+UDPSocket_Dev::UDPSocket_Dev() {
+}
+
+UDPSocket_Dev::UDPSocket_Dev(const InstanceHandle& instance) {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>()) {
+ PassRefFromConstructor(get_interface<PPB_UDPSocket_Dev_0_1>()->Create(
+ instance.pp_instance()));
+ }
+}
+
+UDPSocket_Dev::UDPSocket_Dev(PassRef, PP_Resource resource)
+ : Resource(PASS_REF, resource) {
+}
+
+UDPSocket_Dev::UDPSocket_Dev(const UDPSocket_Dev& other) : Resource(other) {
+}
+
+UDPSocket_Dev::~UDPSocket_Dev() {
+}
+
+UDPSocket_Dev& UDPSocket_Dev::operator=(const UDPSocket_Dev& other) {
+ Resource::operator=(other);
+ return *this;
+}
+
+// static
+bool UDPSocket_Dev::IsAvailable() {
+ return has_interface<PPB_UDPSocket_Dev_0_1>();
+}
+
+int32_t UDPSocket_Dev::Bind(const NetAddress_Dev& addr,
+ const CompletionCallback& callback) {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>()) {
+ return get_interface<PPB_UDPSocket_Dev_0_1>()->Bind(
+ pp_resource(), addr.pp_resource(), callback.pp_completion_callback());
+ }
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+NetAddress_Dev UDPSocket_Dev::GetBoundAddress() {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>()) {
+ return NetAddress_Dev(
+ PASS_REF,
+ get_interface<PPB_UDPSocket_Dev_0_1>()->GetBoundAddress(pp_resource()));
+ }
+ return NetAddress_Dev();
+}
+
+int32_t UDPSocket_Dev::RecvFrom(
+ char* buffer,
+ int32_t num_bytes,
+ const CompletionCallbackWithOutput<NetAddress_Dev>& callback) {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>()) {
+ return get_interface<PPB_UDPSocket_Dev_0_1>()->RecvFrom(
+ pp_resource(), buffer, num_bytes, callback.output(),
+ callback.pp_completion_callback());
+ }
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+int32_t UDPSocket_Dev::SendTo(const char* buffer,
+ int32_t num_bytes,
+ const NetAddress_Dev& addr,
+ const CompletionCallback& callback) {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>()) {
+ return get_interface<PPB_UDPSocket_Dev_0_1>()->SendTo(
+ pp_resource(), buffer, num_bytes, addr.pp_resource(),
+ callback.pp_completion_callback());
+ }
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+void UDPSocket_Dev::Close() {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>())
+ return get_interface<PPB_UDPSocket_Dev_0_1>()->Close(pp_resource());
+}
+
+int32_t UDPSocket_Dev::SetOption(PP_UDPSocket_Option_Dev name,
+ const Var& value,
+ const CompletionCallback& callback) {
+ if (has_interface<PPB_UDPSocket_Dev_0_1>()) {
+ return get_interface<PPB_UDPSocket_Dev_0_1>()->SetOption(
+ pp_resource(), name, value.pp_var(),
+ callback.pp_completion_callback());
+ }
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/udp_socket_dev.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698