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

Side by Side Diff: content/browser/renderer_host/media/ownership.h

Issue 2738763002: [Mojo Video Capture] Introduce abstraction BuildableVideoCaptureDevice (Closed)
Patch Set: Incorporated miu@'s suggestions from PatchSet 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_OWNERSHIP_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_OWNERSHIP_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h"
13
14 namespace content {
15
16 // Destructor-only interface for encapsulating pure ownership.
17 // TODO(chfremer): Consider renaming this to Releasable, ScopedOpaqueReference,
18 // ScopedReference, or ScopedResource.
19 class Ownership {
20 public:
21 virtual ~Ownership() {}
22 };
23
24 // Encapsulates (shared) ownership of a scoped_refptr<T> and exposes it
25 // through the Ownership interface.
26 template <typename T>
27 class ScopedRefptrOwnership : public Ownership {
28 public:
29 ScopedRefptrOwnership(scoped_refptr<T> refptr) : refptr_(std::move(refptr)) {}
emircan 2017/03/16 20:54:03 Make this constructor to private and move MakeScop
chfremer 2017/03/16 22:02:30 I moved the MakeScopedRefptrOwnership out of this
30
31 private:
32 const scoped_refptr<T> refptr_;
33 };
34
35 template <typename T>
36 std::unique_ptr<Ownership> MakeScopedRefptrOwnership(scoped_refptr<T> refptr) {
37 return base::MakeUnique<ScopedRefptrOwnership<T>>(std::move(refptr));
38 }
39
40 // A collection of Ownerships
41 class OwnershipCollection : public Ownership {
42 public:
43 OwnershipCollection();
44 ~OwnershipCollection() override;
45
46 void AttachOwnership(std::unique_ptr<Ownership> ownership) {
47 collection_.push_back(std::move(ownership));
48 }
49
50 private:
51 std::vector<std::unique_ptr<Ownership>> collection_;
52 };
53
54 } // namespace content
55
56 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_OWNERSHIP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698