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

Side by Side Diff: webkit/plugins/ppapi/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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/plugins/ppapi/resource.h" 5 #include "webkit/plugins/ppapi/resource.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "webkit/plugins/ppapi/callbacks.h" 8 #include "webkit/plugins/ppapi/callbacks.h"
9 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 9 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
10 #include "webkit/plugins/ppapi/plugin_module.h" 10 #include "webkit/plugins/ppapi/plugin_module.h"
11 #include "webkit/plugins/ppapi/resource_tracker.h" 11 #include "webkit/plugins/ppapi/resource_tracker.h"
12 12
13 namespace webkit { 13 namespace webkit {
14 namespace ppapi { 14 namespace ppapi {
15 15
16 Resource::Resource(PluginInstance* instance) 16 Resource::Resource(PluginInstance* instance)
17 : ResourceObjectBase(instance->pp_instance()), 17 : ::ppapi::Resource(instance->pp_instance()),
18 resource_id_(0),
19 instance_(instance) { 18 instance_(instance) {
20 ResourceTracker::Get()->ResourceCreated(this, instance_);
21 } 19 }
22 20
23 Resource::~Resource() { 21 Resource::~Resource() {
24 ResourceTracker::Get()->ResourceDestroyed(this);
25 } 22 }
26 23
27 PP_Resource Resource::GetReference() { 24 PP_Resource Resource::GetReference() {
28 ResourceTracker *tracker = ResourceTracker::Get(); 25 ResourceTracker* tracker = ResourceTracker::Get();
29 if (resource_id_) 26 tracker->AddRefResource(pp_resource());
30 tracker->AddRefResource(resource_id_); 27 return pp_resource();
31 else
32 resource_id_ = tracker->AddResource(this);
33 return resource_id_;
34 }
35
36 PP_Resource Resource::GetReferenceNoAddRef() const {
37 return resource_id_;
38 }
39
40 void Resource::ClearInstance() {
41 instance_ = NULL;
42 } 28 }
43 29
44 void Resource::LastPluginRefWasDeleted() { 30 void Resource::LastPluginRefWasDeleted() {
45 DCHECK(resource_id_ != 0);
46 instance()->module()->GetCallbackTracker()->PostAbortForResource( 31 instance()->module()->GetCallbackTracker()->PostAbortForResource(
47 resource_id_); 32 pp_resource());
48 resource_id_ = 0; 33 }
34
35 void Resource::InstanceWasDeleted() {
36 ::ppapi::Resource::InstanceWasDeleted();
37 instance_ = NULL;
49 } 38 }
50 39
51 } // namespace ppapi 40 } // namespace ppapi
52 } // namespace webkit 41 } // namespace webkit
53 42
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698