Index: content/browser/renderer_host/media/ownership.h |
diff --git a/content/browser/renderer_host/media/ownership.h b/content/browser/renderer_host/media/ownership.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..969c8daab0f03a956d36758db0814911ee9846be |
--- /dev/null |
+++ b/content/browser/renderer_host/media/ownership.h |
@@ -0,0 +1,56 @@ |
+// Copyright 2016 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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_OWNERSHIP_H_ |
+#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_OWNERSHIP_H_ |
+ |
+#include <memory> |
+#include <vector> |
+ |
+#include "base/memory/ptr_util.h" |
+#include "base/memory/ref_counted.h" |
+ |
+namespace content { |
+ |
+// Destructor-only interface for encapsulating pure ownership. |
+// TODO(chfremer): Consider renaming this to Releasable, ScopedOpaqueReference, |
+// ScopedReference, or ScopedResource. |
+class Ownership { |
+ public: |
+ virtual ~Ownership() {} |
+}; |
+ |
+// Encapsulates (shared) ownership of a scoped_refptr<T> and exposes it |
+// through the Ownership interface. |
+template <typename T> |
+class ScopedRefptrOwnership : public Ownership { |
+ public: |
+ ScopedRefptrOwnership(scoped_refptr<T> refptr) : refptr_(std::move(refptr)) {} |
+ |
+ private: |
+ const scoped_refptr<T> refptr_; |
+}; |
+ |
+template <typename T> |
+std::unique_ptr<Ownership> MakeScopedRefptrOwnership(scoped_refptr<T> refptr) { |
+ return base::MakeUnique<ScopedRefptrOwnership<T>>(std::move(refptr)); |
+} |
+ |
+// A collection of Ownerships |
+class OwnershipCollection : public Ownership { |
+ public: |
+ OwnershipCollection(); |
+ ~OwnershipCollection() override; |
+ |
+ void AttachOwnership(std::unique_ptr<Ownership> ownership) { |
+ collection_.push_back(std::move(ownership)); |
+ } |
+ |
+ private: |
+ std::vector<std::unique_ptr<Ownership>> collection_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_OWNERSHIP_H_ |