Index: content/public/browser/pepper_vpn_provider_service_helper.h |
diff --git a/content/public/browser/pepper_vpn_provider_service_helper.h b/content/public/browser/pepper_vpn_provider_service_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..674e1d7ca5061c0d7974debf3073b66d3fdcf77d |
--- /dev/null |
+++ b/content/public/browser/pepper_vpn_provider_service_helper.h |
@@ -0,0 +1,105 @@ |
+// 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 CONTENT_PUBLIC_BROWSER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_H_ |
+#define CONTENT_PUBLIC_BROWSER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_H_ |
ncarter (slow)
2016/05/17 19:07:36
In general, content/public should have one class p
adrian.belgun
2016/06/10 14:41:07
Done.
|
+ |
+#include <map> |
+#include <memory> |
+#include <vector> |
+ |
+#include "base/callback.h" |
+#include "base/memory/weak_ptr.h" |
+#include "content/common/content_export.h" |
+ |
+namespace base { |
+template <typename T> |
+struct DefaultSingletonTraits; |
+} |
+ |
+namespace content { |
+class BrowserContext; |
+ |
+class CONTENT_EXPORT VpnMessageFilterDelegate { |
ncarter (slow)
2016/05/17 19:07:35
Document these:
Which threads will these methods
adrian.belgun
2016/06/10 14:41:07
Done.
|
+ public: |
+ virtual ~VpnMessageFilterDelegate(); |
ncarter (slow)
2016/05/17 19:07:36
This class is called MessageFilterDelegate, but th
adrian.belgun
2016/06/10 14:41:07
Done. Renamed to PepperVpnProviderResourceHostProx
|
+ |
+ virtual void SendOnPacketReceived(const std::vector<char>& data) = 0; |
ncarter (slow)
2016/05/17 19:07:36
It looks like this Delegate interface will be impl
adrian.belgun
2016/06/10 14:41:07
Done. Split functionalty to Impl.
Cannot avoid Re
|
+ virtual void SendOnUnbind() = 0; |
+}; |
+ |
+class CONTENT_EXPORT VpnServiceDelegate { |
ncarter (slow)
2016/05/17 19:07:36
I see that the VpnService in extensions will actua
adrian.belgun
2016/06/10 14:41:07
Done. Renamed to VpnServiceProxy. The object that
|
+ public: |
+ virtual ~VpnServiceDelegate(); |
+ |
+ using SuccessCallback = base::Closure; |
+ using StringCallback = base::Callback<void(const std::string& result)>; |
ncarter (slow)
2016/05/17 19:07:36
This looks unused?
adrian.belgun
2016/06/10 14:41:07
Done.
|
+ using FailureCallback = |
+ base::Callback<void(const std::string& error_name, |
+ const std::string& error_message)>; |
+ |
+ virtual void Bind(const std::string& extension_id, |
+ const std::string& configuration_id, |
+ const std::string& configuration_name, |
+ const SuccessCallback& success, |
+ const FailureCallback& failure) = 0; |
+ virtual void SendPacket(const std::string& extension_id, |
+ const std::vector<char>& data, |
+ const SuccessCallback& success, |
+ const FailureCallback& failure) = 0; |
+}; |
+ |
ncarter (slow)
2016/05/17 19:07:36
content/public, being the public api of this modul
adrian.belgun
2016/06/10 14:41:07
Done.
|
+class CONTENT_EXPORT VpnProviderServiceHelper { |
+ public: |
+ using SuccessCallback = base::Closure; |
+ using StringCallback = base::Callback<void(const std::string& result)>; |
+ using FailureCallback = |
+ base::Callback<void(const std::string& error_name, |
+ const std::string& error_message)>; |
+ |
+ static VpnProviderServiceHelper* GetInstance(); |
ncarter (slow)
2016/05/17 19:07:36
VpnProviderServiceHelper ought to be a pure virtua
adrian.belgun
2016/06/10 14:41:07
Done.
|
+ |
+ // These functions must get called on the UI thread |
+ void RegisterDelegate(const std::string& extension_id, |
ncarter (slow)
2016/05/17 19:07:36
extensions don't exist at the content/ layer, so t
adrian.belgun
2016/06/10 14:41:07
Done. Replaced with host_id. The extension id is u
|
+ std::unique_ptr<VpnMessageFilterDelegate> delegate); |
+ void RegisterDelegate(content::BrowserContext* context, |
+ std::unique_ptr<VpnServiceDelegate> delegate); |
ncarter (slow)
2016/05/17 19:07:36
Is there only one of these per BrowserContext? Or
adrian.belgun
2016/06/10 14:41:07
Yes. There is one VpnService per browser context.
|
+ void Bind(const std::string& extension_id, |
+ const std::string& configuration_id, |
+ const std::string& configuration_name, |
+ int render_process_id, |
+ const SuccessCallback& success, |
+ const FailureCallback& failure); |
+ void SendPacket(const std::string& extension_id, |
+ const std::vector<char>& data, |
+ int render_process_id, |
+ SuccessCallback success, |
+ FailureCallback failure); |
+ void OnUnbind(const std::string& extension_id); |
+ void OnPacketReceived(const std::string& extension_id, |
+ const std::vector<char>& data); |
ncarter (slow)
2016/05/17 19:07:36
Are all of these methods going to be called outsid
adrian.belgun
2016/06/10 14:41:07
Done.
|
+ |
+ private: |
+ VpnProviderServiceHelper(); |
+ ~VpnProviderServiceHelper(); |
+ friend struct base::DefaultSingletonTraits<VpnProviderServiceHelper>; |
+ |
+ // These functions must get called on the IO thread |
+ void OnUnbindIO(const std::string& extension_id); |
+ void OnPacketReceivedIO(const std::string& extension_id, |
+ const std::vector<char>& data); |
+ |
+ std::map<std::string, std::unique_ptr<VpnMessageFilterDelegate>> |
+ extension_to_host_map_; |
+ std::map<content::BrowserContext*, std::unique_ptr<VpnServiceDelegate>> |
+ context_to_service_map_; |
+ |
+ base::WeakPtrFactory<VpnProviderServiceHelper> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(VpnProviderServiceHelper); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_BROWSER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_H_ |