blob: 9619861bdfdee59ffb4f0991c5fe2f614c7dd376 (
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
|
// 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.
#include "webkit/plugins/ppapi/resource.h"
#include "base/logging.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace webkit {
namespace ppapi {
Resource::Resource(PluginInstance* instance)
: resource_id_(0), instance_(instance) {
}
Resource::~Resource() {
}
PP_Resource Resource::GetReference() {
ResourceTracker *tracker = ResourceTracker::Get();
if (resource_id_)
tracker->AddRefResource(resource_id_);
else
resource_id_ = tracker->AddResource(this);
return resource_id_;
}
PP_Resource Resource::GetReferenceNoAddRef() const {
return resource_id_;
}
void Resource::LastPluginRefWasDeleted(bool instance_destroyed) {
DCHECK(resource_id_ != 0);
instance()->module()->GetCallbackTracker()->PostAbortForResource(
resource_id_);
resource_id_ = 0;
if (instance_destroyed)
instance_ = NULL;
}
#define DEFINE_TYPE_GETTER(RESOURCE) \
RESOURCE* Resource::As##RESOURCE() { return NULL; }
FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER)
#undef DEFINE_TYPE_GETTER
} // namespace ppapi
} // namespace webkit
|