blob: 7f0fefc0f032264be7c7a226af4f3e807d395033 (
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
58
59
60
61
62
63
64
65
66
67
|
// Copyright (c) 2010 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_CPP_CORE_H_
#define PPAPI_CPP_CORE_H_
#include "ppapi/c/ppb_core.h"
namespace pp {
class CompletionCallback;
class Module;
// Simple wrapper around the PPB_Core interface. Some of these wrappers add
// nothing over the C interface, but some allow the use of C++ arguments.
class Core {
public:
// Note that we explicitly don't expose Resource& versions of this function
// since Resource will normally manage the refcount properly. These should
// be called only when doing manual management on raw PP_Resource handles,
// which should be fairly rare.
void AddRefResource(PP_Resource resource) {
interface_->AddRefResource(resource);
}
void ReleaseResource(PP_Resource resource) {
interface_->ReleaseResource(resource);
}
void* MemAlloc(uint32_t num_bytes) {
return interface_->MemAlloc(num_bytes);
}
void MemFree(void* ptr) {
interface_->MemFree(ptr);
}
PP_Time GetTime() {
return interface_->GetTime();
}
PP_TimeTicks GetTimeTicks() {
return interface_->GetTimeTicks();
}
void CallOnMainThread(int32_t delay_in_milliseconds,
const CompletionCallback& callback,
int32_t result = 0);
bool IsMainThread();
private:
// Allow Module to construct.
friend class Module;
// Only module should make this class so this constructor is private.
Core(const PPB_Core* inter) : interface_(inter) {}
// Copy and assignment are disallowed.
Core(const Core& other);
Core& operator=(const Core& other);
const PPB_Core* interface_;
};
} // namespace pp
#endif // PPAPI_CPP_CORE_H_
|