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

Side by Side Diff: content/renderer/media/capturing_link_secure_tracker.h

Issue 1873293002: Report if video capturing meets output protection requirement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Rebased. Created 4 years, 8 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_RENDERER_MEDIA_CAPTURING_LINK_SECURT_TRACKER_H_
miu 2016/04/26 01:25:13 s/SECURT/SECURE/
xjz 2016/04/29 00:11:42 Done.
6 #define CONTENT_RENDERER_MEDIA_CAPTURING_LINK_SECURT_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 CapturingLinkSecureTracker {
miu 2016/04/26 01:25:14 Suggestion: Since this is tracking whether downstr
xjz 2016/04/29 00:11:42 Done.
14 public:
15 CapturingLinkSecureTracker() : is_capturing_secure_(true) {}
16 ~CapturingLinkSecureTracker() { DCHECK(links_secure_status_.empty()); }
17
18 void AddLinkSecure(T* link, bool is_link_secure);
miu 2016/04/26 01:25:14 naming nit: How about just Add(), Remove(), and Up
xjz 2016/04/29 00:11:42 Done.
19 void RemoveLinkSecure(T* link);
20 void UpdateLinkSecure(T* link, bool is_link_secure);
21 bool is_capturing_secure() { return is_capturing_secure_; }
22
23 private:
24 // This is true only if all connected links are reported secure.
25 bool is_capturing_secure_;
26
27 std::vector<std::pair<T*, bool>> links_secure_status_;
miu 2016/04/26 01:25:14 Idea: What if this class just maintained a vector
xjz 2016/04/29 00:11:42 Done. Smart idea! Saves many lines of codes and co
28 };
29
30 template <typename T>
31 void CapturingLinkSecureTracker<T>::AddLinkSecure(T* link,
32 bool is_link_secure) {
33 links_secure_status_.push_back(std::make_pair(link, is_link_secure));
34 is_capturing_secure_ &= is_link_secure;
35 }
36
37 template <typename T>
38 void CapturingLinkSecureTracker<T>::RemoveLinkSecure(T* link) {
39 bool is_link_secure = true;
40 for (auto it = links_secure_status_.begin(); it != links_secure_status_.end();
41 ++it) {
42 if (it->first == link) {
43 is_link_secure = it->second;
44 links_secure_status_.erase(it);
45 break;
46 }
47 }
48 if (is_link_secure)
49 return;
50
51 DCHECK(!is_capturing_secure_);
52 // |is_track_secure_| needs to be updated as the removed link is insecure.
53 is_capturing_secure_ = true;
54 for (auto it = links_secure_status_.begin(); it != links_secure_status_.end();
55 ++it)
56 is_capturing_secure_ &= it->second;
57 }
58
59 template <typename T>
60 void CapturingLinkSecureTracker<T>::UpdateLinkSecure(T* link,
61 bool is_link_secure) {
62 for (auto it = links_secure_status_.begin(); it != links_secure_status_.end();
63 ++it) {
64 if (it->first == link) {
65 if (it->second == is_link_secure)
66 return;
67 it->second = is_link_secure;
68 break;
69 }
70 }
71 if (!is_link_secure) {
72 is_capturing_secure_ = false;
73 return;
74 }
75
76 is_capturing_secure_ = true;
77 for (auto it = links_secure_status_.begin(); it != links_secure_status_.end();
78 ++it)
79 is_capturing_secure_ &= it->second;
80 }
81
82 #endif // CONTENT_RENDERER_MEDIA_CAPTURING_LINK_SECURT_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698