blob: a0b23d9b8237d64e03f2684ffba4f5d7a93e9240 [file] [log] [blame]
Avi Drissmandb497b32022-09-15 19:47:281// Copyright 2012 The Chromium Authors
[email protected]66085312010-11-05 22:14:252// 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
[email protected]67600b92012-03-10 06:51:488#include "base/memory/weak_ptr.h"
[email protected]66085312010-11-05 22:14:259#include "ppapi/proxy/var_serialization_rules.h"
10
[email protected]4d2efd22011-08-18 21:58:0211namespace ppapi {
[email protected]66085312010-11-05 22:14:2512namespace proxy {
13
[email protected]67600b92012-03-10 06:51:4814class PluginDispatcher;
[email protected]66085312010-11-05 22:14:2515class PluginVarTracker;
16
[email protected]67600b92012-03-10 06:51:4817// Implementation of the VarSerializationRules interface for the plugin.
[email protected]66085312010-11-05 22:14:2518class PluginVarSerializationRules : public VarSerializationRules {
19 public:
20 // This class will use the given non-owning pointer to the var tracker to
21 // handle object refcounting and string conversion.
[email protected]67600b92012-03-10 06:51:4822 explicit PluginVarSerializationRules(
23 const base::WeakPtr<PluginDispatcher>& dispatcher);
Peter Boström3d5b3cb2021-09-23 21:35:4524
25 PluginVarSerializationRules(const PluginVarSerializationRules&) = delete;
26 PluginVarSerializationRules& operator=(const PluginVarSerializationRules&) =
27 delete;
28
[email protected]66085312010-11-05 22:14:2529 ~PluginVarSerializationRules();
30
31 // VarSerialization implementation.
[email protected]2d449b32012-02-07 05:38:0032 virtual PP_Var SendCallerOwned(const PP_Var& var);
[email protected]67600b92012-03-10 06:51:4833 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var);
[email protected]66085312010-11-05 22:14:2534 virtual void EndReceiveCallerOwned(const PP_Var& var);
[email protected]67600b92012-03-10 06:51:4835 virtual PP_Var ReceivePassRef(const PP_Var& var);
[email protected]2d449b32012-02-07 05:38:0036 virtual PP_Var BeginSendPassRef(const PP_Var& var);
[email protected]67600b92012-03-10 06:51:4837 virtual void EndSendPassRef(const PP_Var& var);
[email protected]66085312010-11-05 22:14:2538 virtual void ReleaseObjectRef(const PP_Var& var);
39
40 private:
41 PluginVarTracker* var_tracker_;
42
[email protected]67600b92012-03-10 06:51:4843 // In most cases, |dispatcher_| won't be NULL, but you should always check
44 // before using it.
45 // One scenario that it becomes NULL: A SerializedVar holds a ref to this
46 // object, and a sync message is issued. While waiting for the reply to the
47 // sync message, some incoming message causes the dispatcher to be destroyed.
48 // If that happens, we may leak references to object vars. Considering that
49 // scripting has been deprecated, this may not be a big issue.
50 base::WeakPtr<PluginDispatcher> dispatcher_;
[email protected]66085312010-11-05 22:14:2551};
52
53} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0254} // namespace ppapi
[email protected]66085312010-11-05 22:14:2555
56#endif // PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_