Chromium Code Reviews| 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() const { return insecure_links_.empty(); } | |
| 22 | |
| 23 private: | |
| 24 // Record every insecure links. | |
| 25 std::vector<T*> insecure_links_; | |
| 26 | |
| 27 DISALLOW_COPY_AND_ASSIGN(SecureDisplayLinkTracker); | |
| 28 }; | |
| 29 | |
| 30 template <typename T> | |
| 31 void SecureDisplayLinkTracker<T>::Add(T* link, bool is_link_secure) { | |
|
oshima
2016/05/10 02:13:44
optional nit: maybe
DCHECK(std::find(, link) == i
xjz
2016/05/11 18:07:23
Done.
| |
| 32 if (!is_link_secure) | |
| 33 insecure_links_.push_back(link); | |
| 34 } | |
| 35 | |
| 36 template <typename T> | |
| 37 void SecureDisplayLinkTracker<T>::Remove(T* link) { | |
| 38 auto it = std::find(insecure_links_.begin(), insecure_links_.end(), link); | |
| 39 if (it != insecure_links_.end()) | |
| 40 insecure_links_.erase(it); | |
| 41 } | |
| 42 | |
| 43 template <typename T> | |
| 44 void SecureDisplayLinkTracker<T>::Update(T* link, bool is_link_secure) { | |
| 45 auto it = std::find(insecure_links_.begin(), insecure_links_.end(), link); | |
| 46 if (it != insecure_links_.end()) { | |
| 47 if (is_link_secure) | |
| 48 insecure_links_.erase(it); | |
| 49 return; | |
| 50 } | |
| 51 if (!is_link_secure) | |
| 52 insecure_links_.push_back(link); | |
|
oshima
2016/05/10 02:13:44
optional nit: Add(link, is_link_secure)
?
xjz
2016/05/11 18:07:23
Done.
| |
| 53 } | |
| 54 | |
| 55 #endif // CONTENT_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_ | |
| OLD | NEW |