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

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

Issue 2660003003: Add MediaError.message (Closed)
Patch Set: Address dalecurtis@'s comment: undef STRINGIFY_STATUS_CASE 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 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 981e38d823fc342be2ec23ba13c3eecfa1b58f48..66708ecf115f8c1c548d8b8d28eeed807a0c45fc 100644
--- a/content/renderer/media/render_media_log.cc
+++ b/content/renderer/media/render_media_log.cc
@@ -92,15 +92,16 @@ void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) {
last_duration_changed_event_.swap(event);
break;
- // Hold onto the most recent PIPELINE_ERROR and MEDIA_LOG_ERROR_ENTRY for
- // use in GetLastErrorMessage().
+ // Hold onto the most recent PIPELINE_ERROR and the first, if any,
+ // MEDIA_LOG_ERROR_ENTRY for use in GetErrorMessage().
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);
+ if (!cached_media_error_for_message_)
+ cached_media_error_for_message_ = std::move(event);
break;
// Just enqueue all other event types for throttled transmission.
@@ -134,18 +135,25 @@ void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) {
base::Bind(&RenderMediaLog::SendQueuedMediaEvents, weak_this_));
}
-std::string RenderMediaLog::GetLastErrorMessage() {
+std::string RenderMediaLog::GetErrorMessage() {
base::AutoLock auto_lock(lock_);
- // Return the conditional concatenation of the last pipeline error and the
- // last media error log.
+ // Keep message structure in sync with
+ // HTMLMediaElement::BuildElementErrorMessage().
+
std::stringstream result;
- if (last_pipeline_error_) {
- result << MediaEventToLogString(*last_pipeline_error_)
- << (last_media_error_log_entry_ ? ", " : "");
+ if (last_pipeline_error_)
+ result << MediaEventToMessageString(*last_pipeline_error_);
+
+ if (cached_media_error_for_message_) {
+ DCHECK(last_pipeline_error_)
+ << "Message with detail should be associated with a pipeline error";
+ // This ':' lets web apps extract the UA-specific-error-code from the
+ // MediaError.message prefix.
+ result << ": "
+ << MediaEventToMessageString(*cached_media_error_for_message_);
}
- if (last_media_error_log_entry_)
- result << MediaEventToLogString(*last_media_error_log_entry_);
+
return result.str();
}

Powered by Google App Engine
This is Rietveld 408576698