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

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

Issue 9455083: Proxy the PPP_Printing interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/resource_tracker.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.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_tracker.h" 5 #include "ppapi/shared_impl/resource_tracker.h"
6 6
7 #include "base/bind.h"
8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h"
7 #include "ppapi/shared_impl/callback_tracker.h" 10 #include "ppapi/shared_impl/callback_tracker.h"
8 #include "ppapi/shared_impl/id_assignment.h" 11 #include "ppapi/shared_impl/id_assignment.h"
9 #include "ppapi/shared_impl/ppapi_globals.h" 12 #include "ppapi/shared_impl/ppapi_globals.h"
10 #include "ppapi/shared_impl/resource.h" 13 #include "ppapi/shared_impl/resource.h"
11 14
12 namespace ppapi { 15 namespace ppapi {
13 16
14 ResourceTracker::ResourceTracker() : last_resource_value_(0) { 17 ResourceTracker::ResourceTracker()
18 : last_resource_value_(0),
19 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
15 } 20 }
16 21
17 ResourceTracker::~ResourceTracker() { 22 ResourceTracker::~ResourceTracker() {
18 } 23 }
19 24
20 Resource* ResourceTracker::GetResource(PP_Resource res) const { 25 Resource* ResourceTracker::GetResource(PP_Resource res) const {
21 ResourceMap::const_iterator i = live_resources_.find(res); 26 ResourceMap::const_iterator i = live_resources_.find(res);
22 if (i == live_resources_.end()) 27 if (i == live_resources_.end())
23 return NULL; 28 return NULL;
24 return i->second.first; 29 return i->second.first;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (i->second.second == 0) { 65 if (i->second.second == 0) {
61 LastPluginRefWasDeleted(i->second.first); 66 LastPluginRefWasDeleted(i->second.first);
62 67
63 // When we go from 1 to 0 plugin ref count, free the additional "real" ref 68 // When we go from 1 to 0 plugin ref count, free the additional "real" ref
64 // on its behalf. THIS WILL MOST LIKELY RELEASE THE OBJECT AND REMOVE IT 69 // on its behalf. THIS WILL MOST LIKELY RELEASE THE OBJECT AND REMOVE IT
65 // FROM OUR LIST. 70 // FROM OUR LIST.
66 i->second.first->Release(); 71 i->second.first->Release();
67 } 72 }
68 } 73 }
69 74
75 void ResourceTracker::ReleaseResourceSoon(PP_Resource res) {
76 MessageLoop::current()->PostNonNestableTask(
77 FROM_HERE,
78 base::Bind(&ResourceTracker::ReleaseResource,
79 weak_ptr_factory_.GetWeakPtr(),
80 res));
81 }
82
70 void ResourceTracker::DidCreateInstance(PP_Instance instance) { 83 void ResourceTracker::DidCreateInstance(PP_Instance instance) {
71 // Due to the infrastructure of some tests, the instance is registered 84 // Due to the infrastructure of some tests, the instance is registered
72 // twice in a few cases. It would be nice not to do that and assert here 85 // twice in a few cases. It would be nice not to do that and assert here
73 // instead. 86 // instead.
74 if (instance_map_.find(instance) != instance_map_.end()) 87 if (instance_map_.find(instance) != instance_map_.end())
75 return; 88 return;
76 instance_map_[instance] = linked_ptr<InstanceData>(new InstanceData); 89 instance_map_[instance] = linked_ptr<InstanceData>(new InstanceData);
77 } 90 }
78 91
79 void ResourceTracker::DidDeleteInstance(PP_Instance instance) { 92 void ResourceTracker::DidDeleteInstance(PP_Instance instance) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 live_resources_.erase(pp_resource); 182 live_resources_.erase(pp_resource);
170 } 183 }
171 184
172 void ResourceTracker::LastPluginRefWasDeleted(Resource* object) { 185 void ResourceTracker::LastPluginRefWasDeleted(Resource* object) {
173 PpapiGlobals::Get()->GetCallbackTrackerForInstance(object->pp_instance())-> 186 PpapiGlobals::Get()->GetCallbackTrackerForInstance(object->pp_instance())->
174 PostAbortForResource(object->pp_resource()); 187 PostAbortForResource(object->pp_resource());
175 object->LastPluginRefWasDeleted(); 188 object->LastPluginRefWasDeleted();
176 } 189 }
177 190
178 } // namespace ppapi 191 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/resource_tracker.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698