summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/tracker_base.h
blob: 28cd442f281460888403f238cb2939452eba26fa (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
// 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 "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/proxy/interface_id.h"

namespace ppapi {

class FunctionGroupBase;
class ResourceObjectBase;

// 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.
class 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 resource object corresponding to the given ID, or NULL if
  // there isn't one.
  virtual ResourceObjectBase* GetResourceAPI(PP_Resource res) = 0;

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

  // Returns the instance corresponding to the given resource, or 0 if the
  // resource is invalid.
  virtual PP_Instance GetInstanceForResource(PP_Resource resource) = 0;
};

}  // namespace ppapi

#endif  // PPAPI_SHARED_IMPL_TRACKER_BASE_H_