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

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

Issue 2660003003: Add MediaError.message (Closed)
Patch Set: Simplify to just 1 string with no newlines: [status plus first MEDIA_ERROR_LOG_ENTRY], if any 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 1169f685b5a81ec6885ef39e92a8cb96195c0301..26e85b20ac5e24b031f85b189e6a566795d2ff38 100644
--- a/content/renderer/media/render_media_log.cc
+++ b/content/renderer/media/render_media_log.cc
@@ -78,15 +78,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.
@@ -118,19 +119,23 @@ void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) {
FROM_HERE, base::Bind(&RenderMediaLog::SendQueuedMediaEvents, 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 = "";
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_)
+ result += ": ";
}
- if (last_media_error_log_entry_)
- result << MediaEventToLogString(*last_media_error_log_entry_);
- return result.str();
+
+ if (cached_media_error_for_message_)
+ result += MediaEventToMessageString(*cached_media_error_for_message_);
+
+ return result;
}
void RenderMediaLog::RecordRapporWithSecurityOrigin(const std::string& metric) {

Powered by Google App Engine
This is Rietveld 408576698