blob: 511227ca0de79793d74a0c7d75c27345655d9769 [file] [log] [blame]
[email protected]d8f868a62012-02-04 16:44:371// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[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
avie029c4132015-12-23 06:45:228#include "base/macros.h"
[email protected]67600b92012-03-10 06:51:489#include "base/memory/weak_ptr.h"
[email protected]66085312010-11-05 22:14:2510#include "ppapi/proxy/var_serialization_rules.h"
11
[email protected]4d2efd22011-08-18 21:58:0212namespace ppapi {
[email protected]66085312010-11-05 22:14:2513namespace proxy {
14
[email protected]67600b92012-03-10 06:51:4815class PluginDispatcher;
[email protected]66085312010-11-05 22:14:2516class PluginVarTracker;
17
[email protected]67600b92012-03-10 06:51:4818// Implementation of the VarSerializationRules interface for the plugin.
[email protected]66085312010-11-05 22:14:2519class 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]67600b92012-03-10 06:51:4823 explicit PluginVarSerializationRules(
24 const base::WeakPtr<PluginDispatcher>& dispatcher);
Peter Boström3d5b3cb2021-09-23 21:35:4525
26 PluginVarSerializationRules(const PluginVarSerializationRules&) = delete;
27 PluginVarSerializationRules& operator=(const PluginVarSerializationRules&) =
28 delete;
29
[email protected]66085312010-11-05 22:14:2530 ~PluginVarSerializationRules();
31
32 // VarSerialization implementation.
[email protected]2d449b32012-02-07 05:38:0033 virtual PP_Var SendCallerOwned(const PP_Var& var);
[email protected]67600b92012-03-10 06:51:4834 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var);
[email protected]66085312010-11-05 22:14:2535 virtual void EndReceiveCallerOwned(const PP_Var& var);
[email protected]67600b92012-03-10 06:51:4836 virtual PP_Var ReceivePassRef(const PP_Var& var);
[email protected]2d449b32012-02-07 05:38:0037 virtual PP_Var BeginSendPassRef(const PP_Var& var);
[email protected]67600b92012-03-10 06:51:4838 virtual void EndSendPassRef(const PP_Var& var);
[email protected]66085312010-11-05 22:14:2539 virtual void ReleaseObjectRef(const PP_Var& var);
40
41 private:
42 PluginVarTracker* var_tracker_;
43
[email protected]67600b92012-03-10 06:51:4844 // 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]66085312010-11-05 22:14:2552};
53
54} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0255} // namespace ppapi
[email protected]66085312010-11-05 22:14:2556
57#endif // PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_