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

Side by Side Diff: chrome/browser/chromeos/vpn_provider/pepper_vpn_provider_service_helper.h

Issue 1307173009: rebased ppapi vpnProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: fix compile Created 5 years, 3 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 2015 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 CHROME_BROWSER_CHROMEOS_VPN_PROVIDER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_ H_
6 #define CHROME_BROWSER_CHROMEOS_VPN_PROVIDER_PEPPER_VPN_PROVIDER_SERVICE_HELPER_ H_
7
8 #include <map>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ppapi/c/ppb_vpn_provider.h"
14 #include "ppapi/proxy/serialized_structs.h"
15
16 namespace base {
17 template <typename T>
18 struct DefaultSingletonTraits;
19 } // namespace base
20
21 namespace base {
22 class DictionaryValue;
23 } // namespace base
24
25 namespace content {
26 class PepperVpnProviderMessageFilterChromeOS;
27 } // namespace content
28
29 namespace chromeos {
30 class VpnService;
31
32 namespace vpn_provider {
33 class VpnProviderServiceHelper {
34 public:
35 using SuccessCallback = base::Closure;
36 using StringCallback = base::Callback<void(const std::string& result)>;
37 using FailureCallback =
38 base::Callback<void(const std::string& error_name,
39 const std::string& error_message)>;
40
41 static VpnProviderServiceHelper* GetInstance();
42
43 // These functions must get called on the IO thread
44 void AddServiceID_IO(
45 const std::string& service_id,
46 base::WeakPtr<content::PepperVpnProviderMessageFilterChromeOS>
47 vpn_provider,
48 int render_process_id);
49 void RemoveServiceID_IO(const std::string& service_id, int render_process_id);
50
51 // These functions must get called on the UI thread
52 void CreateConfig_UI(const std::string& service_id,
53 const std::string& name,
54 int render_process_id,
55 SuccessCallback success,
56 FailureCallback failure);
57 void DestroyConfig_UI(const std::string& service_id,
58 const std::string& id,
59 int render_process_id,
60 SuccessCallback success,
61 FailureCallback failure);
62 void SetParameters_UI(
63 const std::string& service_id,
64 const ppapi::proxy::SerializedVpnProviderParameters& serialized_params,
65 int render_process_id,
66 StringCallback success,
67 FailureCallback failure);
68 void SendPacket_UI(const std::string& service_id,
69 const std::vector<char>& data,
70 int render_process_id,
71 SuccessCallback success,
72 FailureCallback failure);
73 void NotifyConnectionStateChanged_UI(const std::string& service_id,
74 PP_VpnProvider_VpnConnectionState status,
75 int render_process_id,
76 SuccessCallback success,
77 FailureCallback failure);
78
79 void OnPlatformMessage_UI(const std::string& service_id,
80 std::string id,
81 PP_VpnProvider_PlatformMessage status,
82 std::string message);
83 void OnPacketReceived_UI(const std::string& service_id,
84 const std::vector<char>& data);
85 void OnConfigurationRemoved_UI(const std::string& service_id,
86 const std::string& id);
87 void OnConfigurationCreated_UI(const std::string& service_id,
88 const std::string& id,
89 const std::string& name,
90 const std::string& data);
91 void OnUIEvent_UI(const std::string& service_id,
92 PP_VpnProvider_UIEvent event,
93 const std::string& id);
94
95 private:
96 VpnProviderServiceHelper();
97 ~VpnProviderServiceHelper();
98 friend struct base::DefaultSingletonTraits<VpnProviderServiceHelper>;
99
100 // These functions must get called on the UI thread
101 chromeos::VpnService* GetVpnService_UI(int render_process_id);
102 void AddServiceID_UI(const std::string& service_id, int render_process_id);
103 void RemoveServiceID_UI(const std::string& service_id, int render_process_id);
104
105 // These functions must get called on the IO thread
106 void OnPlatformMessage_IO(const std::string& service_id,
107 std::string id,
108 PP_VpnProvider_PlatformMessage status,
109 std::string message);
110 void OnPacketReceived_IO(const std::string& service_id,
111 const std::vector<char>& data);
112 void OnConfigurationEvent_IO(const std::string& service_id,
113 const std::string& id,
114 PP_VpnProvider_ConfigMessage message,
115 const std::string& name,
116 const std::string& data);
117 void OnUIEvent_IO(const std::string& service_id,
118 PP_VpnProvider_UIEvent event,
119 const std::string& id);
120
121 // Utility Functions
122 void ConvertParams(
123 const ppapi::proxy::SerializedVpnProviderParameters& serialized_params,
124 base::DictionaryValue* dictionary_params);
125
126 std::map<std::string,
127 base::WeakPtr<content::PepperVpnProviderMessageFilterChromeOS>>
128 service_to_host_map_;
129
130 base::WeakPtrFactory<VpnProviderServiceHelper> weak_factory_;
131
132 DISALLOW_COPY_AND_ASSIGN(VpnProviderServiceHelper);
133 };
134
135 } // namespace vpn_provider
136 } // namespace chromeos
137
138 #endif // CHROME_BROWSER_CHROMEOS_VPN_PROVIDER_PEPPER_VPN_PROVIDER_SERVICE_HELP ER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/vpn_provider/DEPS ('k') | chrome/browser/chromeos/vpn_provider/pepper_vpn_provider_service_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698