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

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

Issue 1850733003: Media: Report informational error messages to HTMLMediaElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_locking_in_rendermedialog
Patch Set: Fix null MediaLogEvent* dereference in RenderMediaLog::AddEvent() 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
Index: content/renderer/media/render_media_log.cc
diff --git a/content/renderer/media/render_media_log.cc b/content/renderer/media/render_media_log.cc
index 0c6b22d92267bcf5169fd50d2cbd2ed18d05e7e8..943b3d8dc85ca396d8ab010b571c6d0fdf660b5d 100644
--- a/content/renderer/media/render_media_log.cc
+++ b/content/renderer/media/render_media_log.cc
@@ -4,6 +4,8 @@
#include "content/renderer/media/render_media_log.h"
+#include <sstream>
+
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
@@ -51,12 +53,31 @@ void RenderMediaLog::AddEvent(scoped_ptr<media::MediaLogEvent> event) {
{
base::AutoLock auto_lock(lock_);
- // Keep track of the latest buffered extents properties to avoid sending
- // thousands of events over IPC. See http://crbug.com/352585 for details.
- if (event->type == media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED)
- last_buffered_extents_changed_event_.swap(event);
- else
- queued_media_events_.push_back(*event);
+ switch (event->type) {
+ case media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED:
+ // Keep track of the latest buffered extents properties to avoid sending
+ // thousands of events over IPC. See http://crbug.com/352585 for
+ // details.
+ last_buffered_extents_changed_event_.swap(event);
+ // SendQueuedMediaEvents() will enqueue the most recent event of this
+ // kind, if any, prior to sending the event batch.
+ break;
+
+ // Hold onto the most recent PIPELINE_ERROR and MEDIA_LOG_ERROR_ENTRY for
+ // use in GetLastErrorMessage();
watk 2016/04/04 23:47:25 nit: s/;/./
wolenetz 2016/04/05 00:23:27 Done.
+ case media::MediaLogEvent::PIPELINE_ERROR:
+ queued_media_events_.push_back(*event);
+ last_pipeline_error_.swap(event);
+ break;
+ case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY:
+ queued_media_events_.push_back(*event);
+ last_media_error_log_entry_.swap(event);
+ break;
+
+ // Just enqueue all other event types for throttled transmission.
+ default:
+ queued_media_events_.push_back(*event);
+ }
if (ipc_send_pending_)
return;
@@ -82,6 +103,20 @@ void RenderMediaLog::AddEvent(scoped_ptr<media::MediaLogEvent> event) {
FROM_HERE, base::Bind(&RenderMediaLog::SendQueuedMediaEvents, this));
}
+std::string RenderMediaLog::GetLastErrorMessage() {
+ base::AutoLock auto_lock(lock_);
+
+ // Return the conditional concatenation of the last pipeline error and the
+ // last media error log.
+ std::stringstream result;
+ if (last_pipeline_error_)
+ result << MediaEventToLogString(*last_pipeline_error_)
+ << (last_media_error_log_entry_ ? ", " : "");
watk 2016/04/04 23:47:25 braces around multi-line statement
wolenetz 2016/04/05 00:23:27 Argh!! git cl format strikes again :/ Done.
+ if (last_media_error_log_entry_)
+ result << MediaEventToLogString(*last_media_error_log_entry_);
+ return result.str();
+}
+
void RenderMediaLog::SendQueuedMediaEvents() {
DCHECK(task_runner_->BelongsToCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698