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

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

Issue 2502413002: Release PowerSaveBlock on PeerConnection stop instead of removal (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | content/browser/webrtc/webrtc_internals.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_WEBRTC_WEBRTC_INTERNALS_H_ 5 #ifndef CONTENT_BROWSER_WEBRTC_WEBRTC_INTERNALS_H_
6 #define CONTENT_BROWSER_WEBRTC_WEBRTC_INTERNALS_H_ 6 #define CONTENT_BROWSER_WEBRTC_WEBRTC_INTERNALS_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <string>
10 11
11 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
12 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 16 #include "base/observer_list.h"
16 #include "base/process/process.h" 17 #include "base/process/process.h"
17 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "content/common/content_export.h" 20 #include "content/common/content_export.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 bool IsAudioDebugRecordingsEnabled() const; 102 bool IsAudioDebugRecordingsEnabled() const;
102 const base::FilePath& GetAudioDebugRecordingsFilePath() const; 103 const base::FilePath& GetAudioDebugRecordingsFilePath() const;
103 104
104 // Enables or disables diagnostic event log. 105 // Enables or disables diagnostic event log.
105 void EnableEventLogRecordings(content::WebContents* web_contents); 106 void EnableEventLogRecordings(content::WebContents* web_contents);
106 void DisableEventLogRecordings(); 107 void DisableEventLogRecordings();
107 108
108 bool IsEventLogRecordingsEnabled() const; 109 bool IsEventLogRecordingsEnabled() const;
109 const base::FilePath& GetEventLogFilePath() const; 110 const base::FilePath& GetEventLogFilePath() const;
110 111
112 int num_open_connections() { return num_open_connections_; }
tommi (sloooow) - chröme 2016/11/17 18:27:04 Make these const?
113 bool IsPowerSavingBlocked() { return !!power_save_blocker_; }
114
111 protected: 115 protected:
112 // Constructor/Destructor are protected to allow tests to derive from the 116 // Constructor/Destructor are protected to allow tests to derive from the
113 // class and do per-instance testing without having to use the global 117 // class and do per-instance testing without having to use the global
114 // instance. 118 // instance.
115 // The default ctor sets |aggregate_updates_ms| to 500ms. 119 // The default ctor sets |aggregate_updates_ms| to 500ms.
116 WebRTCInternals(); 120 WebRTCInternals();
117 WebRTCInternals(int aggregate_updates_ms, bool should_block_power_saving); 121 WebRTCInternals(int aggregate_updates_ms, bool should_block_power_saving);
118 ~WebRTCInternals() override; 122 ~WebRTCInternals() override;
119 123
120 private: 124 private:
(...skipping 25 matching lines...) Expand all
146 #if defined(ENABLE_WEBRTC) 150 #if defined(ENABLE_WEBRTC)
147 // Enables diagnostic audio recordings on all render process hosts using 151 // Enables diagnostic audio recordings on all render process hosts using
148 // |audio_debug_recordings_file_path_|. 152 // |audio_debug_recordings_file_path_|.
149 void EnableAudioDebugRecordingsOnAllRenderProcessHosts(); 153 void EnableAudioDebugRecordingsOnAllRenderProcessHosts();
150 154
151 // Enables event log recordings on all render process hosts using 155 // Enables event log recordings on all render process hosts using
152 // |event_log_recordings_file_path_|. 156 // |event_log_recordings_file_path_|.
153 void EnableEventLogRecordingsOnAllRenderProcessHosts(); 157 void EnableEventLogRecordingsOnAllRenderProcessHosts();
154 #endif 158 #endif
155 159
156 // Called whenever an element is added to or removed from 160 // Updates the number of open PeerConnections. Called when a PeerConnection
157 // |peer_connection_data_| to impose/release a block on suspending the current 161 // is stopped or removed.
158 // application for power-saving. 162 void MaybeClosePeerConnection(base::DictionaryValue* record);
163
164 // Called whenever a PeerConnection is created or stopped in order to
165 // impose/release a block on suspending the current application for power
166 // saving.
159 void CreateOrReleasePowerSaveBlocker(); 167 void CreateOrReleasePowerSaveBlocker();
160 168
161 // Called on a timer to deliver updates to javascript. 169 // Called on a timer to deliver updates to javascript.
162 // We throttle and bulk together updates to avoid DOS like scenarios where 170 // We throttle and bulk together updates to avoid DOS like scenarios where
163 // a page uses a lot of peerconnection instances with many event 171 // a page uses a lot of peerconnection instances with many event
164 // notifications. 172 // notifications.
165 void ProcessPendingUpdates(); 173 void ProcessPendingUpdates();
166 174
167 base::ObserverList<WebRTCInternalsUIObserver> observers_; 175 base::ObserverList<WebRTCInternalsUIObserver> observers_;
168 176
(...skipping 27 matching lines...) Expand all
196 204
197 // Diagnostic audio recording state. 205 // Diagnostic audio recording state.
198 bool audio_debug_recordings_; 206 bool audio_debug_recordings_;
199 base::FilePath audio_debug_recordings_file_path_; 207 base::FilePath audio_debug_recordings_file_path_;
200 208
201 // Diagnostic event log recording state. 209 // Diagnostic event log recording state.
202 bool event_log_recordings_; 210 bool event_log_recordings_;
203 bool selecting_event_log_; 211 bool selecting_event_log_;
204 base::FilePath event_log_recordings_file_path_; 212 base::FilePath event_log_recordings_file_path_;
205 213
206 // While |peer_connection_data_| is non-empty, hold an instance of 214 // While |num_open_connections_| is greater than zero, hold an instance of
207 // PowerSaveBlocker. This prevents the application from being suspended while 215 // PowerSaveBlocker. This prevents the application from being suspended while
208 // remoting. 216 // remoting.
217 int num_open_connections_;
209 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; 218 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
210 const bool should_block_power_saving_; 219 const bool should_block_power_saving_;
211 220
212 // Set of render process hosts that |this| is registered as an observer on. 221 // Set of render process hosts that |this| is registered as an observer on.
213 base::hash_set<int> render_process_id_set_; 222 base::hash_set<int> render_process_id_set_;
214 223
215 // Used to bulk up updates that we send to javascript. 224 // Used to bulk up updates that we send to javascript.
216 // The class owns the value/dictionary and command name of an update. 225 // The class owns the value/dictionary and command name of an update.
217 // For each update, a PendingUpdate is stored in the |pending_updates_| queue 226 // For each update, a PendingUpdate is stored in the |pending_updates_| queue
218 // and deleted as soon as the update has been delivered. 227 // and deleted as soon as the update has been delivered.
(...skipping 21 matching lines...) Expand all
240 std::queue<PendingUpdate> pending_updates_; 249 std::queue<PendingUpdate> pending_updates_;
241 const int aggregate_updates_ms_; 250 const int aggregate_updates_ms_;
242 251
243 // Weak factory for this object that we use for bulking up updates. 252 // Weak factory for this object that we use for bulking up updates.
244 base::WeakPtrFactory<WebRTCInternals> weak_factory_; 253 base::WeakPtrFactory<WebRTCInternals> weak_factory_;
245 }; 254 };
246 255
247 } // namespace content 256 } // namespace content
248 257
249 #endif // CONTENT_BROWSER_WEBRTC_WEBRTC_INTERNALS_H_ 258 #endif // CONTENT_BROWSER_WEBRTC_WEBRTC_INTERNALS_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/webrtc/webrtc_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698