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

Side by Side Diff: content/public/browser/pepper_vpn_provider_service_helper.h

Issue 1988613005: ppapi: PPB_VpnProvider: Implement Service Helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vpn-permission
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_H_
6 #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.
7
8 #include <map>
9 #include <memory>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h"
14 #include "content/common/content_export.h"
15
16 namespace base {
17 template <typename T>
18 struct DefaultSingletonTraits;
19 }
20
21 namespace content {
22 class BrowserContext;
23
24 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.
25 public:
26 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
27
28 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
29 virtual void SendOnUnbind() = 0;
30 };
31
32 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
33 public:
34 virtual ~VpnServiceDelegate();
35
36 using SuccessCallback = base::Closure;
37 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.
38 using FailureCallback =
39 base::Callback<void(const std::string& error_name,
40 const std::string& error_message)>;
41
42 virtual void Bind(const std::string& extension_id,
43 const std::string& configuration_id,
44 const std::string& configuration_name,
45 const SuccessCallback& success,
46 const FailureCallback& failure) = 0;
47 virtual void SendPacket(const std::string& extension_id,
48 const std::vector<char>& data,
49 const SuccessCallback& success,
50 const FailureCallback& failure) = 0;
51 };
52
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.
53 class CONTENT_EXPORT VpnProviderServiceHelper {
54 public:
55 using SuccessCallback = base::Closure;
56 using StringCallback = base::Callback<void(const std::string& result)>;
57 using FailureCallback =
58 base::Callback<void(const std::string& error_name,
59 const std::string& error_message)>;
60
61 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.
62
63 // These functions must get called on the UI thread
64 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
65 std::unique_ptr<VpnMessageFilterDelegate> delegate);
66 void RegisterDelegate(content::BrowserContext* context,
67 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.
68 void Bind(const std::string& extension_id,
69 const std::string& configuration_id,
70 const std::string& configuration_name,
71 int render_process_id,
72 const SuccessCallback& success,
73 const FailureCallback& failure);
74 void SendPacket(const std::string& extension_id,
75 const std::vector<char>& data,
76 int render_process_id,
77 SuccessCallback success,
78 FailureCallback failure);
79 void OnUnbind(const std::string& extension_id);
80 void OnPacketReceived(const std::string& extension_id,
81 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.
82
83 private:
84 VpnProviderServiceHelper();
85 ~VpnProviderServiceHelper();
86 friend struct base::DefaultSingletonTraits<VpnProviderServiceHelper>;
87
88 // These functions must get called on the IO thread
89 void OnUnbindIO(const std::string& extension_id);
90 void OnPacketReceivedIO(const std::string& extension_id,
91 const std::vector<char>& data);
92
93 std::map<std::string, std::unique_ptr<VpnMessageFilterDelegate>>
94 extension_to_host_map_;
95 std::map<content::BrowserContext*, std::unique_ptr<VpnServiceDelegate>>
96 context_to_service_map_;
97
98 base::WeakPtrFactory<VpnProviderServiceHelper> weak_factory_;
99
100 DISALLOW_COPY_AND_ASSIGN(VpnProviderServiceHelper);
101 };
102
103 } // namespace content
104
105 #endif // CONTENT_PUBLIC_BROWSER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/pepper_vpn_provider_service_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698