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

Unified Diff: content/renderer/media/render_media_log.h

Issue 1846913004: MediaLog: Replace task posting in AddEvent with lock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses watk@'s comments from PS4. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/media/render_media_log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/render_media_log.h
diff --git a/content/renderer/media/render_media_log.h b/content/renderer/media/render_media_log.h
index a67927d1228d3574449a9035750a164089ded399..80316e60bcd77740d0ac0b67f0d80bedac360954 100644
--- a/content/renderer/media/render_media_log.h
+++ b/content/renderer/media/render_media_log.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/macros.h"
+#include "base/synchronization/lock.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "media/base/media_log.h"
@@ -40,17 +41,25 @@ class CONTENT_EXPORT RenderMediaLog : public media::MediaLog {
private:
~RenderMediaLog() override;
- // Add event on the |task_runner_|.
- void AddEventInternal(scoped_ptr<media::MediaLogEvent> event);
-
- // Posted as a delayed task to throttle ipc message frequency.
+ // Posted as a delayed task on |task_runner_| to throttle ipc message
+ // frequency.
void SendQueuedMediaEvents();
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ // |lock_| serializes access to |tick_clock_|, |last_ipc_send_time_|,
+ // |queued_media_events_|, |ipc_send_pending_| and
+ // |last_buffered_extents_changed_event_|. It allows any render process thread
+ // to AddEvent(), while preserving their sequence for throttled send on
+ // |task_runner_|.
+ mutable base::Lock lock_;
scoped_ptr<base::TickClock> tick_clock_;
base::TimeTicks last_ipc_send_time_;
std::vector<media::MediaLogEvent> queued_media_events_;
+ // For enforcing max 1 pending send.
+ bool ipc_send_pending_;
+
// Limits the number buffered extents changed events we send over IPC to one.
scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_;
« no previous file with comments | « no previous file | content/renderer/media/render_media_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698