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

Unified Diff: content/browser/renderer_host/media/ownership.h

Issue 2738763002: [Mojo Video Capture] Introduce abstraction BuildableVideoCaptureDevice (Closed)
Patch Set: Rebase to Feb 10th and change similarity to 10 Created 3 years, 9 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
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_

Powered by Google App Engine
This is Rietveld 408576698