summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/tracker_base.h
blob: 9ff19d4d7e4e34a8734f20f1e9c20c1e6f9eca7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_SHARED_IMPL_TRACKER_BASE_H_
#define PPAPI_SHARED_IMPL_TRACKER_BASE_H_

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/proxy/interface_id.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"

namespace ppapi {

class FunctionGroupBase;
class ResourceTracker;
class VarTracker;

// Tracks resource and function APIs, providing a mapping between ID and
// object.
// TODO(brettw) Eventually this should be one object with global tracking and
// called "Tracker", and this would be used in both the plugin side of the
// proxy as well as the implementation in the renderer. Currently, all this
// does is forward to the process-type-specific tracker to get the information.
// TODO(fischman/vrk): When brettw fixes the TODO above, fix the ugliness in
// VideoDecoderImpl accordingly.
class PPAPI_SHARED_EXPORT TrackerBase {
 public:
  // Must be called before any other function that uses the TrackerBase.
  // This sets the getter that returns the global implmenetation of
  // TrackerBase. It will be different for in the renderer and in the plugin
  // process.
  static void Init(TrackerBase*(*getter)());

  // Retrieves the global tracker. This will be NULL if you haven't called
  // Init() first (it should be unnecessary to NULL-check this).
  static TrackerBase* Get();

  // Returns the function object corresponding to the given ID, or NULL if
  // there isn't one.
  virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
                                            proxy::InterfaceID id) = 0;

  virtual VarTracker* GetVarTracker() = 0;
  virtual ResourceTracker* GetResourceTracker() = 0;

  // Returns the PP_Module associated with the given PP_Instance, or 0 on
  // failure.
  virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0;
};

}  // namespace ppapi

#endif  // PPAPI_SHARED_IMPL_TRACKER_BASE_H_