proxy_object_var.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2011 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 PPAPI_PROXY_PROXY_OBJECT_VAR_H_
6#define PPAPI_PROXY_PROXY_OBJECT_VAR_H_
7
8#include "base/compiler_specific.h"
9#include "ppapi/proxy/ppapi_proxy_export.h"
10#include "ppapi/shared_impl/var.h"
11
12namespace ppapi {
13
14namespace proxy {
15class PluginDispatcher;
16}  // namespace proxy
17
18// Tracks a reference to an object var in the plugin side of the proxy. This
19// just stores the dispatcher and host var ID, and provides the interface for
20// integrating this with PP_Var creation.
21class PPAPI_PROXY_EXPORT ProxyObjectVar : public Var {
22 public:
23  ProxyObjectVar(proxy::PluginDispatcher* dispatcher,
24                 int32 host_var_id);
25
26  virtual ~ProxyObjectVar();
27
28  // Var overrides.
29  virtual ProxyObjectVar* AsProxyObjectVar() OVERRIDE;
30  virtual PP_VarType GetType() const OVERRIDE;
31
32  proxy::PluginDispatcher* dispatcher() const { return dispatcher_; }
33  int32 host_var_id() const { return host_var_id_; }
34
35  void* user_data() const { return user_data_; }
36  void set_user_data(void* ud) { user_data_ = ud; }
37
38  // Expose AssignVarID on Var so the PluginResourceTracker can call us when
39  // it's creating IDs.
40  void AssignVarID(int32 id);
41
42 private:
43  proxy::PluginDispatcher* dispatcher_;
44  int32 host_var_id_;
45
46  // When this object is created as representing a var implemented by the
47  // plugin, this stores the user data so that we can look it up later. See
48  // PluginVarTracker.
49  void* user_data_;
50
51  DISALLOW_COPY_AND_ASSIGN(ProxyObjectVar);
52};
53
54}  // namespace ppapi
55
56#endif  // PPAPI_PROXY_PROXY_OBJECT_VAR_H_
57