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..3496e25af4e9bb0d05f4b859cdee94c7019e1737 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, |
DaleCurtis
2017/04/20 20:57:13
I thought we wanted the earliest one ?
wolenetz
2017/04/20 21:09:03
Interesting. I hadn't considered that we might rep
wolenetz
2017/04/20 21:23:40
I dug a little further: it looks like we only repo
|
+ // 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,19 +135,27 @@ 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. |
- std::stringstream result; |
+ // Keep message structure in sync with |
+ // HTMLMediaElement::BuildElementErrorMessage(). |
+ |
+ std::string result = ""; |
DaleCurtis
2017/04/20 20:57:13
Why did you drop the std::stringstream? Generally
wolenetz
2017/04/20 21:09:03
Before a MediaError is constructed by the HTMLMedi
wolenetz
2017/04/20 21:58:08
w.r.t. my not using std::stringstream here: Oops!
wolenetz
2017/04/20 22:13:38
In patch set 10, I've added a comment to media_log
|
if (last_pipeline_error_) { |
- result << MediaEventToLogString(*last_pipeline_error_) |
- << (last_media_error_log_entry_ ? ", " : ""); |
+ 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 += ": "; |
+ result += MediaEventToMessageString(*cached_media_error_for_message_); |
} |
- if (last_media_error_log_entry_) |
- result << MediaEventToLogString(*last_media_error_log_entry_); |
- return result.str(); |
+ |
+ return result; |
} |
void RenderMediaLog::RecordRapporWithSecurityOrigin(const std::string& metric) { |