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

Unified Diff: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_network_monitor_private_rpc_server.cc

Issue 10823187: NaCl proxy for PPB_NetworkMonitor_Private (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
Index: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_network_monitor_private_rpc_server.cc
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_network_monitor_private_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_network_monitor_private_rpc_server.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1078d2b2489ecab2add426aef2e0d7b2e77666d5
--- /dev/null
+++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_network_monitor_private_rpc_server.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2012 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.
+//
+// SRPC-abstraction wrappers around PPB_NetworkMonitor_Private functions.
+
+#include <string.h>
+#include <limits>
+
+#include "native_client/src/include/nacl_macros.h"
+#include "native_client/src/shared/ppapi_proxy/browser_callback.h"
+#include "native_client/src/shared/ppapi_proxy/browser_globals.h"
+#include "native_client/src/shared/ppapi_proxy/utility.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_udp_socket_private.h"
+#include "srpcgen/ppb_rpc.h"
+#include "srpcgen/ppp_rpc.h"
+
+using ppapi_proxy::DebugPrintf;
+using ppapi_proxy::DeleteRemoteCallbackInfo;
+using ppapi_proxy::MakeRemoteCompletionCallback;
+using ppapi_proxy::PPBNetworkMonitorPrivateInterface;
+
+namespace {
+
+struct NetworkListCallbackData {
+ PP_Instance instance_id;
+ PP_Resource network_monitor;
+};
+
+void NetworkListChangedCallback(void* user_data, PP_Resource network_list) {
+ NetworkListCallbackData* data =
+ reinterpret_cast<NetworkListCallbackData*>(user_data);
+
+ NaClSrpcChannel* nacl_srpc_channel = ppapi_proxy::GetMainSrpcChannel(
+ data->instance_id);
+ PppNetworkMonitorPrivateRpcClient::
+ PPP_NetworkMonitor_Private_NetworkListChanged(
+ nacl_srpc_channel, data->network_monitor, network_list);
+}
+
+} // namespace
+
+void PpbNetworkMonitorPrivateServer::PPB_NetworkMonitor_Private_Create(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Instance instance,
+ PP_Resource* resource) {
+ DebugPrintf("PPB_NetworkMonitor_Private::Create: "
+ "instance=%"NACL_PRId32"\n", instance);
+
+ NaClSrpcClosureRunner runner(done);
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+
+ // NetworkListCallbackData is always leaked - it's non-trivial to detect when
+ // NetworkMonitor resource is destroyed. This code is going to be removed
+ // soon, so it doesn't make sense to fix it.
+ //
+ // TODO(sergeyu): Fix this leak if for any reason we decide to keep this code
+ // long term.
+ NetworkListCallbackData* callback_data = new NetworkListCallbackData();
+ callback_data->instance_id = instance;
+
+ *resource = PPBNetworkMonitorPrivateInterface()->Create(
+ instance, &NetworkListChangedCallback, callback_data);
+
+ callback_data->network_monitor = *resource;
+
+ rpc->result = NACL_SRPC_RESULT_OK;
+}
+
+void
+PpbNetworkMonitorPrivateServer::PPB_NetworkMonitor_Private_IsNetworkMonitor(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Resource resource,
+ int32_t* out_bool) {
+ DebugPrintf("PPB_NetworkMonitor_Private::IsNetworkMonitor: "
+ "resource=%"NACL_PRId32"\n", resource);
+
+ NaClSrpcClosureRunner runner(done);
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+
+ PP_Bool pp_success =
+ PPBNetworkMonitorPrivateInterface()->IsNetworkMonitor(resource);
+ *out_bool = PP_ToBool(pp_success);
+
+ rpc->result = NACL_SRPC_RESULT_OK;
+}

Powered by Google App Engine
This is Rietveld 408576698