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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/render_media_log.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) 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_RENDER_MEDIA_LOG_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
6 #define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ 6 #define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/synchronization/lock.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 #include "media/base/media_log.h" 14 #include "media/base/media_log.h"
14 15
15 namespace base { 16 namespace base {
16 class TickClock; 17 class TickClock;
17 } 18 }
18 19
19 namespace content { 20 namespace content {
20 21
(...skipping 12 matching lines...) Expand all
33 void AddEvent(scoped_ptr<media::MediaLogEvent> event) override; 34 void AddEvent(scoped_ptr<media::MediaLogEvent> event) override;
34 35
35 // Will reset |last_ipc_send_time_| with the value of NowTicks(). 36 // Will reset |last_ipc_send_time_| with the value of NowTicks().
36 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); 37 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock);
37 void SetTaskRunnerForTesting( 38 void SetTaskRunnerForTesting(
38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
39 40
40 private: 41 private:
41 ~RenderMediaLog() override; 42 ~RenderMediaLog() override;
42 43
43 // Add event on the |task_runner_|. 44 // Posted as a delayed task on |task_runner_| to throttle ipc message
44 void AddEventInternal(scoped_ptr<media::MediaLogEvent> event); 45 // frequency.
45
46 // Posted as a delayed task to throttle ipc message frequency.
47 void SendQueuedMediaEvents(); 46 void SendQueuedMediaEvents();
48 47
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
49
50 // |lock_| serializes access to |tick_clock_|, |last_ipc_send_time_|,
51 // |queued_media_events_|, |ipc_send_pending_| and
52 // |last_buffered_extents_changed_event_|. It allows any render process thread
53 // to AddEvent(), while preserving their sequence for throttled send on
54 // |task_runner_|.
55 mutable base::Lock lock_;
50 scoped_ptr<base::TickClock> tick_clock_; 56 scoped_ptr<base::TickClock> tick_clock_;
51 base::TimeTicks last_ipc_send_time_; 57 base::TimeTicks last_ipc_send_time_;
52 std::vector<media::MediaLogEvent> queued_media_events_; 58 std::vector<media::MediaLogEvent> queued_media_events_;
53 59
60 // For enforcing max 1 pending send.
61 bool ipc_send_pending_;
62
54 // Limits the number buffered extents changed events we send over IPC to one. 63 // Limits the number buffered extents changed events we send over IPC to one.
55 scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_; 64 scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_;
56 65
57 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog); 66 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog);
58 }; 67 };
59 68
60 } // namespace content 69 } // namespace content
61 70
62 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ 71 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
OLDNEW
« 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