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

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

Issue 2909103002: Deprecate NonThreadSafe in content/renderer/media in favor of SequenceChecker. (Closed)
Patch Set: fix compile Created 3 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/sequence_checker.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/public/common/media_stream_request.h" 12 #include "content/public/common/media_stream_request.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 // Used to investigate where UserMediaRequests end up. 16 // Used to investigate where UserMediaRequests end up.
17 // Only UserMediaRequests that do not log with LogUserMediaRequestResult 17 // Only UserMediaRequests that do not log with LogUserMediaRequestResult
18 // should call LogUserMediaRequestWithNoResult. 18 // should call LogUserMediaRequestWithNoResult.
19 // 19 //
20 // Elements in this enum should not be deleted or rearranged; the only 20 // Elements in this enum should not be deleted or rearranged; the only
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // A singleton that keeps track of the number of MediaStreams being 60 // A singleton that keeps track of the number of MediaStreams being
61 // sent over PeerConnections. It uses the transition to zero such 61 // sent over PeerConnections. It uses the transition to zero such
62 // streams to demarcate the start of a new "session". Note that this 62 // streams to demarcate the start of a new "session". Note that this
63 // is a rough approximation of sessions, as you could conceivably have 63 // is a rough approximation of sessions, as you could conceivably have
64 // multiple tabs using this renderer process, and each of them using 64 // multiple tabs using this renderer process, and each of them using
65 // PeerConnections. 65 // PeerConnections.
66 // 66 //
67 // The UpdateWebRTCMethodCount function above uses this class to log a 67 // The UpdateWebRTCMethodCount function above uses this class to log a
68 // metric at most once per session. 68 // metric at most once per session.
69 class CONTENT_EXPORT PerSessionWebRTCAPIMetrics : public base::NonThreadSafe { 69 class CONTENT_EXPORT PerSessionWebRTCAPIMetrics {
70 public: 70 public:
71 virtual ~PerSessionWebRTCAPIMetrics(); 71 virtual ~PerSessionWebRTCAPIMetrics();
72 72
73 static PerSessionWebRTCAPIMetrics* GetInstance(); 73 static PerSessionWebRTCAPIMetrics* GetInstance();
74 74
75 // Increment/decrement the number of streams being sent or received 75 // Increment/decrement the number of streams being sent or received
76 // over any current PeerConnection. 76 // over any current PeerConnection.
77 void IncrementStreamCounter(); 77 void IncrementStreamCounter();
78 void DecrementStreamCounter(); 78 void DecrementStreamCounter();
79 79
80 protected: 80 protected:
81 friend struct base::DefaultSingletonTraits<PerSessionWebRTCAPIMetrics>; 81 friend struct base::DefaultSingletonTraits<PerSessionWebRTCAPIMetrics>;
82 friend void UpdateWebRTCMethodCount(JavaScriptAPIName); 82 friend void UpdateWebRTCMethodCount(JavaScriptAPIName);
83 83
84 // Protected so that unit tests can test without this being a 84 // Protected so that unit tests can test without this being a
85 // singleton. 85 // singleton.
86 PerSessionWebRTCAPIMetrics(); 86 PerSessionWebRTCAPIMetrics();
87 87
88 // Overridable by unit tests. 88 // Overridable by unit tests.
89 virtual void LogUsage(JavaScriptAPIName api_name); 89 virtual void LogUsage(JavaScriptAPIName api_name);
90 90
91 // Called by UpdateWebRTCMethodCount above. Protected rather than 91 // Called by UpdateWebRTCMethodCount above. Protected rather than
92 // private so that unit tests can call it. 92 // private so that unit tests can call it.
93 void LogUsageOnlyOnce(JavaScriptAPIName api_name); 93 void LogUsageOnlyOnce(JavaScriptAPIName api_name);
94 94
95 private: 95 private:
96 void ResetUsage(); 96 void ResetUsage();
97 97
98 int num_streams_; 98 int num_streams_;
99 bool has_used_api_[INVALID_NAME]; 99 bool has_used_api_[INVALID_NAME];
mcasas 2017/06/02 15:01:13 <rant mode> Ugh, this should be s/INVALID_NAME/NUM
100 100
101 SEQUENCE_CHECKER(sequence_checker_);
102
101 DISALLOW_COPY_AND_ASSIGN(PerSessionWebRTCAPIMetrics); 103 DISALLOW_COPY_AND_ASSIGN(PerSessionWebRTCAPIMetrics);
102 }; 104 };
103 105
104 } // namespace content 106 } // namespace content
105 107
106 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_ 108 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_renderer.h ('k') | content/renderer/media/webrtc_uma_histograms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698