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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/media/webrtc_internals.cc » ('j') | content/browser/media/webrtc_internals.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/webrtc_internals.h
diff --git a/content/browser/media/webrtc_internals.h b/content/browser/media/webrtc_internals.h
index f6470008dd45937dcb0e016db8528ae58cc6e367..cbec2334cabcfc772ba6ab01f8bb19f42196e2c4 100644
--- a/content/browser/media/webrtc_internals.h
+++ b/content/browser/media/webrtc_internals.h
@@ -5,10 +5,13 @@
#ifndef CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_
#define CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_
+#include <queue>
+
#include "base/containers/hash_tables.h"
#include "base/gtest_prod_util.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/process/process.h"
#include "base/values.h"
@@ -81,8 +84,8 @@ class CONTENT_EXPORT WebRTCInternals : public RenderProcessHostObserver,
const std::string& video_constraints);
// Methods for adding or removing WebRTCInternalsUIObserver.
- void AddObserver(WebRTCInternalsUIObserver *observer);
- void RemoveObserver(WebRTCInternalsUIObserver *observer);
+ void AddObserver(WebRTCInternalsUIObserver* observer);
+ void RemoveObserver(WebRTCInternalsUIObserver* observer);
// Sends all update data to |observer|.
void UpdateObserver(WebRTCInternalsUIObserver* observer);
@@ -116,7 +119,7 @@ class CONTENT_EXPORT WebRTCInternals : public RenderProcessHostObserver,
WebRTCInternals();
~WebRTCInternals() override;
- void SendUpdate(const std::string& command, base::Value* value);
+ void SendUpdate(const std::string& command, scoped_ptr<base::Value> value);
// RenderProcessHostObserver implementation.
void RenderProcessHostDestroyed(RenderProcessHost* host) override;
@@ -145,6 +148,12 @@ class CONTENT_EXPORT WebRTCInternals : public RenderProcessHostObserver,
// application for power-saving.
void CreateOrReleasePowerSaveBlocker();
+ // Called on a timer to deliver updates to javascript.
+ // We throttle and bulk together updates to avoid DOS like scenarios where
+ // a page uses a lot of peerconnection instances with many event
+ // notifications.
+ void ProcessPendingUpdates();
+
base::ObserverList<WebRTCInternalsUIObserver> observers_;
// |peer_connection_data_| is a list containing all the PeerConnection
@@ -191,6 +200,27 @@ class CONTENT_EXPORT WebRTCInternals : public RenderProcessHostObserver,
// Set of render process hosts that |this| is registered as an observer on.
base::hash_set<int> render_process_id_set_;
+
+ 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
+ public:
+ PendingUpdate(const std::string& command, scoped_ptr<base::Value> value);
+ PendingUpdate(PendingUpdate&& other);
+ ~PendingUpdate();
+
+ const std::string& command() const { return command_; }
+ const base::Value* value() const { return value_.get(); }
+
+ private:
+ std::string command_;
+ scoped_ptr<base::Value> value_;
+ DISALLOW_COPY_AND_ASSIGN(PendingUpdate);
+ };
+
+ bool pending_updates_queued_;
+ std::queue<PendingUpdate> pending_updates_;
+
+ // Weak factory for this object that we use for bulking up updates.
+ base::WeakPtrFactory<WebRTCInternals> weak_factory_;
};
} // namespace content
« 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