OLD | NEW |
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/scoped_pp_resource.h" | 5 #include "ppapi/shared_impl/scoped_pp_resource.h" |
6 | 6 |
7 #include "ppapi/shared_impl/resource.h" | 7 #include "ppapi/shared_impl/resource.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/tracker_base.h" |
10 | 10 |
11 namespace ppapi { | 11 namespace ppapi { |
12 | 12 |
13 ScopedPPResource::ScopedPPResource() : id_(0) { | 13 ScopedPPResource::ScopedPPResource() : id_(0) { |
14 } | 14 } |
15 | 15 |
16 ScopedPPResource::ScopedPPResource(PP_Resource resource) : id_(resource) { | 16 ScopedPPResource::ScopedPPResource(PP_Resource resource) : id_(resource) { |
17 CallAddRef(); | 17 CallAddRef(); |
18 } | 18 } |
19 | 19 |
| 20 ScopedPPResource::ScopedPPResource(const PassRef&, PP_Resource resource) |
| 21 : id_(resource) { |
| 22 } |
| 23 |
20 ScopedPPResource::ScopedPPResource(Resource* resource) | 24 ScopedPPResource::ScopedPPResource(Resource* resource) |
21 : id_(resource ? resource->GetReference() : 0) { | 25 : id_(resource ? resource->GetReference() : 0) { |
22 // GetReference AddRef's for us. | 26 // GetReference AddRef's for us. |
23 } | 27 } |
24 | 28 |
25 ScopedPPResource::ScopedPPResource(const ScopedPPResource& other) | 29 ScopedPPResource::ScopedPPResource(const ScopedPPResource& other) |
26 : id_(other.id_) { | 30 : id_(other.id_) { |
27 CallAddRef(); | 31 CallAddRef(); |
28 } | 32 } |
29 | 33 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (id_) | 66 if (id_) |
63 TrackerBase::Get()->GetResourceTracker()->AddRefResource(id_); | 67 TrackerBase::Get()->GetResourceTracker()->AddRefResource(id_); |
64 } | 68 } |
65 | 69 |
66 void ScopedPPResource::CallRelease() { | 70 void ScopedPPResource::CallRelease() { |
67 if (id_) | 71 if (id_) |
68 TrackerBase::Get()->GetResourceTracker()->ReleaseResource(id_); | 72 TrackerBase::Get()->GetResourceTracker()->ReleaseResource(id_); |
69 } | 73 } |
70 | 74 |
71 } // namespace ppapi | 75 } // namespace ppapi |
OLD | NEW |