OLD | NEW |
---|---|
(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_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_ | |
6 #define CONTENT_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 // Tracks all connected links (video sinks / tracks), and reports if they are | |
11 // all secure for video capturing. | |
12 template <typename T> | |
13 class SecureDisplayLinkTracker { | |
14 public: | |
15 SecureDisplayLinkTracker() {} | |
16 ~SecureDisplayLinkTracker() {} | |
17 | |
18 void Add(T* link, bool is_link_secure); | |
19 void Remove(T* link); | |
20 void Update(T* link, bool is_link_secure); | |
21 bool is_capturing_secure() { return insecure_links_.empty(); } | |
oshima
2016/05/07 14:41:50
const
xjz
2016/05/10 00:28:25
Done.
| |
22 | |
23 private: | |
24 // Record every insecure links. | |
25 std::vector<T*> insecure_links_; | |
oshima
2016/05/07 14:41:50
DISALLOW_COPY_AND_ASSIGN
xjz
2016/05/10 00:28:25
Done.
| |
26 }; | |
27 | |
28 template <typename T> | |
29 void SecureDisplayLinkTracker<T>::Add(T* link, bool is_link_secure) { | |
30 if (!is_link_secure) | |
31 insecure_links_.push_back(link); | |
32 } | |
33 | |
34 template <typename T> | |
35 void SecureDisplayLinkTracker<T>::Remove(T* link) { | |
36 for (auto it = insecure_links_.begin(); it != insecure_links_.end(); ++it) { | |
oshima
2016/05/07 14:41:50
std::find ?
xjz
2016/05/10 00:28:25
Done.
| |
37 if (*it == link) { | |
38 insecure_links_.erase(it); | |
39 break; | |
40 } | |
41 } | |
42 } | |
43 | |
44 template <typename T> | |
45 void SecureDisplayLinkTracker<T>::Update(T* link, bool is_link_secure) { | |
46 for (auto it = insecure_links_.begin(); it != insecure_links_.end(); ++it) { | |
47 if (*it == link) { | |
48 if (is_link_secure) | |
49 insecure_links_.erase(it); | |
50 return; | |
51 } | |
52 } | |
53 if (!is_link_secure) | |
54 insecure_links_.push_back(link); | |
55 } | |
56 | |
57 #endif // CONTENT_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_ | |
OLD | NEW |