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

Unified Diff: ppapi/shared_impl/scoped_pp_resource.h

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nulls auditeed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/shared_impl/resource_tracker.cc ('k') | ppapi/shared_impl/scoped_pp_resource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/scoped_pp_resource.h
diff --git a/ppapi/shared_impl/scoped_pp_resource.h b/ppapi/shared_impl/scoped_pp_resource.h
new file mode 100644
index 0000000000000000000000000000000000000000..74cb9eb2d8cf853f1f17b4c0922e1a3cad872e2b
--- /dev/null
+++ b/ppapi/shared_impl/scoped_pp_resource.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_SHARED_IMPL_SCOPED_RESOURCE_H_
+#define PPAPI_SHARED_IMPL_SCOPED_RESOURCE_H_
+
+#include "ppapi/c/pp_resource.h"
+
+namespace ppapi {
+
+class Resource;
+
+// This is a version of scoped_refptr but for PP_Resources.
+class ScopedPPResource {
+ public:
+ ScopedPPResource();
+
+ // Takes one reference to the given resource.
+ explicit ScopedPPResource(PP_Resource resource);
+
+ // Helper to get the PP_Resource out of the given object and take a reference
+ // to it.
+ explicit ScopedPPResource(Resource* resource);
+
+ // Implicit copy constructor allowed.
+ ScopedPPResource(const ScopedPPResource& other);
+
+ ~ScopedPPResource();
+
+ ScopedPPResource& operator=(PP_Resource resource);
+ ScopedPPResource& operator=(const ScopedPPResource& resource);
+
+ // Returns the PP_Resource without affecting the refcounting.
+ PP_Resource get() const { return id_; }
+ operator PP_Resource() const { return id_; }
+
+ // Returns the PP_Resource, passing the reference to the caller. This class
+ // will no longer hold the resource.
+ PP_Resource Release();
+
+ private:
+ // Helpers to addref or release the id_ if it's non-NULL. The id_ value will
+ // be unchanged.
+ void CallAddRef();
+ void CallRelease();
+
+ PP_Resource id_;
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_SCOPED_RESOURCE_H_
« no previous file with comments | « ppapi/shared_impl/resource_tracker.cc ('k') | ppapi/shared_impl/scoped_pp_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698