Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: ppapi/shared_impl/resource.cc

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 #include "ppapi/shared_impl/resource.h"
6
7 #include "base/logging.h"
8 #include "ppapi/shared_impl/resource_tracker.h"
9 #include "ppapi/shared_impl/tracker_base.h"
10
11 namespace ppapi {
12
13 Resource::Resource(PP_Instance instance) {
14 // The instance should always be valid (nonzero).
15 DCHECK(instance);
16
17 // For the in-process case, the host resource and resource are the same.
18 //
19 // AddResource needs our instance() getter to work, and that goes through
20 // the host resource, so we need to fill that first even though we don't
21 // have a resource ID yet, then fill the resource in later.
22 host_resource_ = HostResource::MakeInstanceOnly(instance);
23 pp_resource_ = TrackerBase::Get()->GetResourceTracker()->AddResource(this);
24 host_resource_.SetHostResource(instance, pp_resource_);
25 }
26
27 Resource::Resource(const HostResource& host_resource)
28 : host_resource_(host_resource) {
29 pp_resource_ = TrackerBase::Get()->GetResourceTracker()->AddResource(this);
30 }
31
32 Resource::~Resource() {
33 TrackerBase::Get()->GetResourceTracker()->RemoveResource(this);
34 }
35
36 PP_Resource Resource::GetReference() {
37 TrackerBase::Get()->GetResourceTracker()->AddRefResource(pp_resource());
38 return pp_resource();
39 }
40
41 void Resource::LastPluginRefWasDeleted() {
42 }
43
44 void Resource::InstanceWasDeleted() {
45 host_resource_ = HostResource();
46 }
47
48 #define DEFINE_TYPE_GETTER(RESOURCE) \
49 thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; }
50 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER)
51 #undef DEFINE_TYPE_GETTER
52
53 } // namespace ppapi
54
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698