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

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

Issue 8344025: Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « ppapi/shared_impl/ppapi_globals.cc ('k') | ppapi/shared_impl/resource_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/shared_impl/resource.h" 5 #include "ppapi/shared_impl/resource.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/shared_impl/resource_tracker.h" 8 #include "ppapi/shared_impl/resource_tracker.h"
9 #include "ppapi/shared_impl/tracker_base.h" 9 #include "ppapi/shared_impl/ppapi_globals.h"
10 10
11 namespace ppapi { 11 namespace ppapi {
12 12
13 Resource::Resource(PP_Instance instance) { 13 Resource::Resource(PP_Instance instance) {
14 // The instance should always be valid (nonzero). 14 // The instance should always be valid (nonzero).
15 DCHECK(instance); 15 DCHECK(instance);
16 16
17 // For the in-process case, the host resource and resource are the same. 17 // For the in-process case, the host resource and resource are the same.
18 // 18 //
19 // AddResource needs our instance() getter to work, and that goes through 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 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. 21 // have a resource ID yet, then fill the resource in later.
22 host_resource_ = HostResource::MakeInstanceOnly(instance); 22 host_resource_ = HostResource::MakeInstanceOnly(instance);
23 pp_resource_ = TrackerBase::Get()->GetResourceTracker()->AddResource(this); 23 pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
24 host_resource_.SetHostResource(instance, pp_resource_); 24 host_resource_.SetHostResource(instance, pp_resource_);
25 } 25 }
26 26
27 Resource::Resource(const HostResource& host_resource) 27 Resource::Resource(const HostResource& host_resource)
28 : host_resource_(host_resource) { 28 : host_resource_(host_resource) {
29 pp_resource_ = TrackerBase::Get()->GetResourceTracker()->AddResource(this); 29 pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
30 } 30 }
31 31
32 Resource::~Resource() { 32 Resource::~Resource() {
33 TrackerBase::Get()->GetResourceTracker()->RemoveResource(this); 33 PpapiGlobals::Get()->GetResourceTracker()->RemoveResource(this);
34 } 34 }
35 35
36 PP_Resource Resource::GetReference() { 36 PP_Resource Resource::GetReference() {
37 TrackerBase::Get()->GetResourceTracker()->AddRefResource(pp_resource()); 37 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource());
38 return pp_resource(); 38 return pp_resource();
39 } 39 }
40 40
41 void Resource::LastPluginRefWasDeleted() { 41 void Resource::LastPluginRefWasDeleted() {
42 } 42 }
43 43
44 void Resource::InstanceWasDeleted() { 44 void Resource::InstanceWasDeleted() {
45 host_resource_ = HostResource(); 45 host_resource_ = HostResource();
46 } 46 }
47 47
48 #define DEFINE_TYPE_GETTER(RESOURCE) \ 48 #define DEFINE_TYPE_GETTER(RESOURCE) \
49 thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; } 49 thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; }
50 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) 50 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER)
51 #undef DEFINE_TYPE_GETTER 51 #undef DEFINE_TYPE_GETTER
52 52
53 } // namespace ppapi 53 } // namespace ppapi
54 54
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppapi_globals.cc ('k') | ppapi/shared_impl/resource_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698