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

Side by Side Diff: content/browser/media/webrtc_internals.h

Issue 1676043002: Deliver webrtc-internals updates in bulk, every 500ms at most. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_
6 #define CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ 6 #define CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_
7 7
8 #include <queue>
9
8 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
9 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
10 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h" 15 #include "base/observer_list.h"
13 #include "base/process/process.h" 16 #include "base/process/process.h"
14 #include "base/values.h" 17 #include "base/values.h"
15 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
16 #include "content/public/browser/render_process_host_observer.h" 19 #include "content/public/browser/render_process_host_observer.h"
17 #include "ui/shell_dialogs/select_file_dialog.h" 20 #include "ui/shell_dialogs/select_file_dialog.h"
18 21
19 namespace content { 22 namespace content {
20 23
21 class PowerSaveBlocker; 24 class PowerSaveBlocker;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // is the constraints for the video. 77 // is the constraints for the video.
75 void OnGetUserMedia(int render_process_id, 78 void OnGetUserMedia(int render_process_id,
76 base::ProcessId pid, 79 base::ProcessId pid,
77 const std::string& origin, 80 const std::string& origin,
78 bool audio, 81 bool audio,
79 bool video, 82 bool video,
80 const std::string& audio_constraints, 83 const std::string& audio_constraints,
81 const std::string& video_constraints); 84 const std::string& video_constraints);
82 85
83 // Methods for adding or removing WebRTCInternalsUIObserver. 86 // Methods for adding or removing WebRTCInternalsUIObserver.
84 void AddObserver(WebRTCInternalsUIObserver *observer); 87 void AddObserver(WebRTCInternalsUIObserver* observer);
85 void RemoveObserver(WebRTCInternalsUIObserver *observer); 88 void RemoveObserver(WebRTCInternalsUIObserver* observer);
86 89
87 // Sends all update data to |observer|. 90 // Sends all update data to |observer|.
88 void UpdateObserver(WebRTCInternalsUIObserver* observer); 91 void UpdateObserver(WebRTCInternalsUIObserver* observer);
89 92
90 // Enables or disables diagnostic audio recordings for debugging purposes. 93 // Enables or disables diagnostic audio recordings for debugging purposes.
91 void EnableAudioDebugRecordings(content::WebContents* web_contents); 94 void EnableAudioDebugRecordings(content::WebContents* web_contents);
92 void DisableAudioDebugRecordings(); 95 void DisableAudioDebugRecordings();
93 96
94 bool IsAudioDebugRecordingsEnabled() const; 97 bool IsAudioDebugRecordingsEnabled() const;
95 const base::FilePath& GetAudioDebugRecordingsFilePath() const; 98 const base::FilePath& GetAudioDebugRecordingsFilePath() const;
(...skipping 13 matching lines...) Expand all
109 FRIEND_TEST_ALL_PREFIXES(WebRtcAudioDebugRecordingsBrowserTest, 112 FRIEND_TEST_ALL_PREFIXES(WebRtcAudioDebugRecordingsBrowserTest,
110 CallWithAudioDebugRecordingsEnabledThenDisabled); 113 CallWithAudioDebugRecordingsEnabledThenDisabled);
111 FRIEND_TEST_ALL_PREFIXES(WebRtcAudioDebugRecordingsBrowserTest, 114 FRIEND_TEST_ALL_PREFIXES(WebRtcAudioDebugRecordingsBrowserTest,
112 TwoCallsWithAudioDebugRecordings); 115 TwoCallsWithAudioDebugRecordings);
113 FRIEND_TEST_ALL_PREFIXES(WebRtcInternalsTest, 116 FRIEND_TEST_ALL_PREFIXES(WebRtcInternalsTest,
114 AudioDebugRecordingsFileSelectionCanceled); 117 AudioDebugRecordingsFileSelectionCanceled);
115 118
116 WebRTCInternals(); 119 WebRTCInternals();
117 ~WebRTCInternals() override; 120 ~WebRTCInternals() override;
118 121
119 void SendUpdate(const std::string& command, base::Value* value); 122 void SendUpdate(const std::string& command, scoped_ptr<base::Value> value);
120 123
121 // RenderProcessHostObserver implementation. 124 // RenderProcessHostObserver implementation.
122 void RenderProcessHostDestroyed(RenderProcessHost* host) override; 125 void RenderProcessHostDestroyed(RenderProcessHost* host) override;
123 126
124 // ui::SelectFileDialog::Listener implementation. 127 // ui::SelectFileDialog::Listener implementation.
125 void FileSelected(const base::FilePath& path, 128 void FileSelected(const base::FilePath& path,
126 int index, 129 int index,
127 void* unused_params) override; 130 void* unused_params) override;
128 void FileSelectionCanceled(void* params) override; 131 void FileSelectionCanceled(void* params) override;
129 132
130 // Called when a renderer exits (including crashes). 133 // Called when a renderer exits (including crashes).
131 void OnRendererExit(int render_process_id); 134 void OnRendererExit(int render_process_id);
132 135
133 #if defined(ENABLE_WEBRTC) 136 #if defined(ENABLE_WEBRTC)
134 // Enables diagnostic audio recordings on all render process hosts using 137 // Enables diagnostic audio recordings on all render process hosts using
135 // |audio_debug_recordings_file_path_|. 138 // |audio_debug_recordings_file_path_|.
136 void EnableAudioDebugRecordingsOnAllRenderProcessHosts(); 139 void EnableAudioDebugRecordingsOnAllRenderProcessHosts();
137 140
138 // Enables event log recordings on all render process hosts using 141 // Enables event log recordings on all render process hosts using
139 // |event_log_recordings_file_path_|. 142 // |event_log_recordings_file_path_|.
140 void EnableEventLogRecordingsOnAllRenderProcessHosts(); 143 void EnableEventLogRecordingsOnAllRenderProcessHosts();
141 #endif 144 #endif
142 145
143 // Called whenever an element is added to or removed from 146 // Called whenever an element is added to or removed from
144 // |peer_connection_data_| to impose/release a block on suspending the current 147 // |peer_connection_data_| to impose/release a block on suspending the current
145 // application for power-saving. 148 // application for power-saving.
146 void CreateOrReleasePowerSaveBlocker(); 149 void CreateOrReleasePowerSaveBlocker();
147 150
151 // Called on a timer to deliver updates to javascript.
152 // We throttle and bulk together updates to avoid DOS like scenarios where
153 // a page uses a lot of peerconnection instances with many event
154 // notifications.
155 void ProcessPendingUpdates();
156
148 base::ObserverList<WebRTCInternalsUIObserver> observers_; 157 base::ObserverList<WebRTCInternalsUIObserver> observers_;
149 158
150 // |peer_connection_data_| is a list containing all the PeerConnection 159 // |peer_connection_data_| is a list containing all the PeerConnection
151 // updates. 160 // updates.
152 // Each item of the list represents the data for one PeerConnection, which 161 // Each item of the list represents the data for one PeerConnection, which
153 // contains these fields: 162 // contains these fields:
154 // "rid" -- the renderer id. 163 // "rid" -- the renderer id.
155 // "pid" -- OS process id of the renderer that creates the PeerConnection. 164 // "pid" -- OS process id of the renderer that creates the PeerConnection.
156 // "lid" -- local Id assigned to the PeerConnection. 165 // "lid" -- local Id assigned to the PeerConnection.
157 // "url" -- url of the web page that created the PeerConnection. 166 // "url" -- url of the web page that created the PeerConnection.
(...skipping 26 matching lines...) Expand all
184 bool selecting_event_log_; 193 bool selecting_event_log_;
185 base::FilePath event_log_recordings_file_path_; 194 base::FilePath event_log_recordings_file_path_;
186 195
187 // While |peer_connection_data_| is non-empty, hold an instance of 196 // While |peer_connection_data_| is non-empty, hold an instance of
188 // PowerSaveBlocker. This prevents the application from being suspended while 197 // PowerSaveBlocker. This prevents the application from being suspended while
189 // remoting. 198 // remoting.
190 scoped_ptr<PowerSaveBlocker> power_save_blocker_; 199 scoped_ptr<PowerSaveBlocker> power_save_blocker_;
191 200
192 // Set of render process hosts that |this| is registered as an observer on. 201 // Set of render process hosts that |this| is registered as an observer on.
193 base::hash_set<int> render_process_id_set_; 202 base::hash_set<int> render_process_id_set_;
203
204 class PendingUpdate {
Henrik Grunell 2016/02/08 09:52:08 Comment on the new class and variables. Threading.
Henrik Grunell 2016/02/09 08:18:11 Not addressed yet. I think it's good to have, espe
tommi (sloooow) - chröme 2016/02/09 09:34:16 Done. I added documentation for the class that me
205 public:
206 PendingUpdate(const std::string& command, scoped_ptr<base::Value> value);
207 PendingUpdate(PendingUpdate&& other);
208 ~PendingUpdate();
209
210 const std::string& command() const { return command_; }
211 const base::Value* value() const { return value_.get(); }
212
213 private:
214 std::string command_;
215 scoped_ptr<base::Value> value_;
216 DISALLOW_COPY_AND_ASSIGN(PendingUpdate);
217 };
218
219 bool pending_updates_queued_;
220 std::queue<PendingUpdate> pending_updates_;
221
222 // Weak factory for this object that we use for bulking up updates.
223 base::WeakPtrFactory<WebRTCInternals> weak_factory_;
194 }; 224 };
195 225
196 } // namespace content 226 } // namespace content
197 227
198 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ 228 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/webrtc_internals.cc » ('j') | content/browser/media/webrtc_internals.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698