[email protected] | d8f868a6 | 2012-02-04 16:44:37 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 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 PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ | ||||
6 | #define PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ | ||||
7 | |||||
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 8 | #include "base/macros.h" |
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 9 | #include "base/memory/weak_ptr.h" |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 10 | #include "ppapi/proxy/var_serialization_rules.h" |
11 | |||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 12 | namespace ppapi { |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 13 | namespace proxy { |
14 | |||||
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 15 | class PluginDispatcher; |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 16 | class PluginVarTracker; |
17 | |||||
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 18 | // Implementation of the VarSerializationRules interface for the plugin. |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 19 | class PluginVarSerializationRules : public VarSerializationRules { |
20 | public: | ||||
21 | // This class will use the given non-owning pointer to the var tracker to | ||||
22 | // handle object refcounting and string conversion. | ||||
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 23 | explicit PluginVarSerializationRules( |
24 | const base::WeakPtr<PluginDispatcher>& dispatcher); | ||||
Peter Boström | 3d5b3cb | 2021-09-23 21:35:45 | [diff] [blame^] | 25 | |
26 | PluginVarSerializationRules(const PluginVarSerializationRules&) = delete; | ||||
27 | PluginVarSerializationRules& operator=(const PluginVarSerializationRules&) = | ||||
28 | delete; | ||||
29 | |||||
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 30 | ~PluginVarSerializationRules(); |
31 | |||||
32 | // VarSerialization implementation. | ||||
[email protected] | 2d449b3 | 2012-02-07 05:38:00 | [diff] [blame] | 33 | virtual PP_Var SendCallerOwned(const PP_Var& var); |
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 34 | virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var); |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 35 | virtual void EndReceiveCallerOwned(const PP_Var& var); |
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 36 | virtual PP_Var ReceivePassRef(const PP_Var& var); |
[email protected] | 2d449b3 | 2012-02-07 05:38:00 | [diff] [blame] | 37 | virtual PP_Var BeginSendPassRef(const PP_Var& var); |
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 38 | virtual void EndSendPassRef(const PP_Var& var); |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 39 | virtual void ReleaseObjectRef(const PP_Var& var); |
40 | |||||
41 | private: | ||||
42 | PluginVarTracker* var_tracker_; | ||||
43 | |||||
[email protected] | 67600b9 | 2012-03-10 06:51:48 | [diff] [blame] | 44 | // In most cases, |dispatcher_| won't be NULL, but you should always check |
45 | // before using it. | ||||
46 | // One scenario that it becomes NULL: A SerializedVar holds a ref to this | ||||
47 | // object, and a sync message is issued. While waiting for the reply to the | ||||
48 | // sync message, some incoming message causes the dispatcher to be destroyed. | ||||
49 | // If that happens, we may leak references to object vars. Considering that | ||||
50 | // scripting has been deprecated, this may not be a big issue. | ||||
51 | base::WeakPtr<PluginDispatcher> dispatcher_; | ||||
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 52 | }; |
53 | |||||
54 | } // namespace proxy | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 55 | } // namespace ppapi |
[email protected] | 6608531 | 2010-11-05 22:14:25 | [diff] [blame] | 56 | |
57 | #endif // PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ |