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

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

Issue 174213003: PPAPI: Use clang-format on ppapi/shared_impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove DEPS Created 6 years, 10 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
« no previous file with comments | « ppapi/shared_impl/resource_var.cc ('k') | ppapi/shared_impl/scoped_pp_var.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/scoped_pp_resource.h" 5 #include "ppapi/shared_impl/scoped_pp_resource.h"
6 6
7 #include "ppapi/shared_impl/ppapi_globals.h" 7 #include "ppapi/shared_impl/ppapi_globals.h"
8 #include "ppapi/shared_impl/resource.h" 8 #include "ppapi/shared_impl/resource.h"
9 #include "ppapi/shared_impl/resource_tracker.h" 9 #include "ppapi/shared_impl/resource_tracker.h"
10 10
11 namespace ppapi { 11 namespace ppapi {
12 12
13 ScopedPPResource::ScopedPPResource() : id_(0) { 13 ScopedPPResource::ScopedPPResource() : id_(0) {}
14 }
15 14
16 ScopedPPResource::ScopedPPResource(PP_Resource resource) : id_(resource) { 15 ScopedPPResource::ScopedPPResource(PP_Resource resource) : id_(resource) {
17 CallAddRef(); 16 CallAddRef();
18 } 17 }
19 18
20 ScopedPPResource::ScopedPPResource(const PassRef&, PP_Resource resource) 19 ScopedPPResource::ScopedPPResource(const PassRef&, PP_Resource resource)
21 : id_(resource) { 20 : id_(resource) {}
22 }
23 21
24 ScopedPPResource::ScopedPPResource(Resource* resource) 22 ScopedPPResource::ScopedPPResource(Resource* resource)
25 : id_(resource ? resource->GetReference() : 0) { 23 : id_(resource ? resource->GetReference() : 0) {
26 // GetReference AddRef's for us. 24 // GetReference AddRef's for us.
27 } 25 }
28 26
29 ScopedPPResource::ScopedPPResource(const ScopedPPResource& other) 27 ScopedPPResource::ScopedPPResource(const ScopedPPResource& other)
30 : id_(other.id_) { 28 : id_(other.id_) {
31 CallAddRef(); 29 CallAddRef();
32 } 30 }
33 31
34 ScopedPPResource::~ScopedPPResource() { 32 ScopedPPResource::~ScopedPPResource() { CallRelease(); }
35 CallRelease();
36 }
37 33
38 ScopedPPResource& ScopedPPResource::operator=(PP_Resource resource) { 34 ScopedPPResource& ScopedPPResource::operator=(PP_Resource resource) {
39 if (id_ == resource) 35 if (id_ == resource)
40 return *this; // Be careful about self-assignment. 36 return *this; // Be careful about self-assignment.
41 CallRelease(); 37 CallRelease();
42 id_ = resource; 38 id_ = resource;
43 CallAddRef(); 39 CallAddRef();
44 return *this; 40 return *this;
45 } 41 }
46 42
(...skipping 20 matching lines...) Expand all
67 if (id_) 63 if (id_)
68 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(id_); 64 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(id_);
69 } 65 }
70 66
71 void ScopedPPResource::CallRelease() { 67 void ScopedPPResource::CallRelease() {
72 if (id_) 68 if (id_)
73 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(id_); 69 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(id_);
74 } 70 }
75 71
76 } // namespace ppapi 72 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/resource_var.cc ('k') | ppapi/shared_impl/scoped_pp_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698