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

Side by Side Diff: content/renderer/media/render_media_log.h

Issue 2660003003: Add MediaError.message (Closed)
Patch Set: --flakiness by using std::map, update virtual/stable/[win,mac] global interface listing too Created 3 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
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 <deque>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "media/base/media_log.h" 16 #include "media/base/media_log.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
(...skipping 12 matching lines...) Expand all
30 // To minimize the number of events sent over the wire, only the latest event 31 // To minimize the number of events sent over the wire, only the latest event
31 // added is sent for high frequency events (e.g., BUFFERED_EXTENTS_CHANGED). 32 // added is sent for high frequency events (e.g., BUFFERED_EXTENTS_CHANGED).
32 // 33 //
33 // It must be constructed on the render thread. 34 // It must be constructed on the render thread.
34 class CONTENT_EXPORT RenderMediaLog : public media::MediaLog { 35 class CONTENT_EXPORT RenderMediaLog : public media::MediaLog {
35 public: 36 public:
36 explicit RenderMediaLog(const GURL& security_origin); 37 explicit RenderMediaLog(const GURL& security_origin);
37 38
38 // MediaLog implementation. 39 // MediaLog implementation.
39 void AddEvent(std::unique_ptr<media::MediaLogEvent> event) override; 40 void AddEvent(std::unique_ptr<media::MediaLogEvent> event) override;
40 std::string GetLastErrorMessage() override; 41 std::map<std::string, std::vector<std::string>> GetErrorMessages() override;
41 void RecordRapporWithSecurityOrigin(const std::string& metric) override; 42 void RecordRapporWithSecurityOrigin(const std::string& metric) override;
42 43
43 // Will reset |last_ipc_send_time_| with the value of NowTicks(). 44 // Will reset |last_ipc_send_time_| with the value of NowTicks().
44 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); 45 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
45 void SetTaskRunnerForTesting( 46 void SetTaskRunnerForTesting(
46 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 47 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
47 48
48 private: 49 private:
49 ~RenderMediaLog() override; 50 ~RenderMediaLog() override;
50 51
51 // Posted as a delayed task on |task_runner_| to throttle ipc message 52 // Posted as a delayed task on |task_runner_| to throttle ipc message
52 // frequency. 53 // frequency.
53 void SendQueuedMediaEvents(); 54 void SendQueuedMediaEvents();
54 55
55 // Security origin of the current frame. 56 // Security origin of the current frame.
56 const GURL security_origin_; 57 const GURL security_origin_;
57 58
58 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 59 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
59 60
60 // |lock_| protects access to all of the following member variables. It 61 // |lock_| protects access to all of the following member variables. It
61 // allows any render process thread to AddEvent(), while preserving their 62 // allows any render process thread to AddEvent(), while preserving their
62 // sequence for throttled send on |task_runner_| and coherent retrieval by 63 // sequence for throttled send on |task_runner_| and coherent retrieval by
63 // GetLastErrorMessage(). 64 // GetErrorMessages().
64 mutable base::Lock lock_; 65 mutable base::Lock lock_;
65 std::unique_ptr<base::TickClock> tick_clock_; 66 std::unique_ptr<base::TickClock> tick_clock_;
66 base::TimeTicks last_ipc_send_time_; 67 base::TimeTicks last_ipc_send_time_;
67 std::vector<media::MediaLogEvent> queued_media_events_; 68 std::vector<media::MediaLogEvent> queued_media_events_;
68 69
69 // For enforcing max 1 pending send. 70 // For enforcing max 1 pending send.
70 bool ipc_send_pending_; 71 bool ipc_send_pending_;
71 72
72 // Limits the number of events we send over IPC to one. 73 // Limits the number of events we send over IPC to one.
73 std::unique_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_; 74 std::unique_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_;
74 std::unique_ptr<media::MediaLogEvent> last_duration_changed_event_; 75 std::unique_ptr<media::MediaLogEvent> last_duration_changed_event_;
75 76
76 // Holds a copy of the most recent MEDIA_ERROR_LOG_ENTRY, if any. 77 // Holds copies of the most recent MEDIA_ERROR_LOG_ENTRY, if any, up to a
77 std::unique_ptr<media::MediaLogEvent> last_media_error_log_entry_; 78 // capped amount.
79 std::deque<std::unique_ptr<media::MediaLogEvent>>
sandersd (OOO until July 31) 2017/04/12 01:09:38 Perhaps std::vector would be a better choice, sinc
wolenetz 2017/04/13 23:59:10 And std::unique_ptrs to them are even smaller ;)
80 recent_media_error_log_entries_;
78 81
79 // Holds a copy of the most recent PIPELINE_ERROR, if any. 82 // Holds a copy of the most recent PIPELINE_ERROR, if any.
80 std::unique_ptr<media::MediaLogEvent> last_pipeline_error_; 83 std::unique_ptr<media::MediaLogEvent> last_pipeline_error_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog); 85 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog);
83 }; 86 };
84 87
85 } // namespace content 88 } // namespace content
86 89
87 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ 90 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698