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

Unified Diff: native_client_sdk/src/examples/api/vpn_provider/vpn_provider_helper.h

Issue 1731273002: ppapi: PPB_VpnProvider: Add a simple NaCl SDK example. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vpn-ppapi
Patch Set: New simplied API. Full connection workflow. Created 4 years, 5 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: native_client_sdk/src/examples/api/vpn_provider/vpn_provider_helper.h
diff --git a/native_client_sdk/src/examples/api/vpn_provider/vpn_provider_helper.h b/native_client_sdk/src/examples/api/vpn_provider/vpn_provider_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..c10c8f39046715f107b5caae429220ce24b703b7
--- /dev/null
+++ b/native_client_sdk/src/examples/api/vpn_provider/vpn_provider_helper.h
@@ -0,0 +1,49 @@
+// Copyright 2016 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.
+
+#ifndef VPN_PROVIDER_HELPER_H_
+#define VPN_PROVIDER_HELPER_H_
+
+#include <queue>
+
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/var.h"
+#include "ppapi/cpp/vpn_provider.h"
+#include "ppapi/utility/completion_callback_factory.h"
+#include "ppapi/utility/threading/simple_thread.h"
+
+// Helper class that keeps VpnPacket handling in it's own thread.
binji 2016/07/18 18:46:28 nit: its
adrian.belgun 2016/07/19 13:57:23 Done.
+class VpnProviderHelper {
+ public:
+ explicit VpnProviderHelper(pp::Instance* instance);
+
+ void Init();
+ void Bind(const std::string& config_name, const std::string& config_id);
+ void SendPacket(const pp::Var& data);
+
+ private:
+ void InitOnThread(int32_t result);
emaxx 2016/07/18 13:46:58 nit: include <stdint.h>
adrian.belgun 2016/07/19 13:57:22 Done.
+ void BindOnThread(int32_t result,
+ const std::string& config,
+ const std::string& name);
+ void SendPacketOnThread(int32_t result, const pp::Var& data);
+
+ // Completion Callbacks
+ void BindCompletionCallback(int32_t result);
+ void ReceivePacketCompletionCallback(int32_t result, const pp::Var& packet);
+ void SendPacketCompletionCallback(int32_t result);
+
+ pp::Instance* instance_;
+ pp::SimpleThread thread_;
+ pp::VpnProvider vpn_;
+ pp::CompletionCallbackFactory<VpnProviderHelper> factory_;
+
+ bool send_packet_pending_;
+ std::queue<pp::Var> send_packet_queue_;
+
+ std::string config_name_;
emaxx 2016/07/18 13:46:58 nit: #include <string>
adrian.belgun 2016/07/19 13:57:22 Done.
+ std::string config_id_;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698