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

Unified Diff: third_party/WebKit/Source/core/html/media/MediaError.cpp

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/media/MediaError.cpp
diff --git a/third_party/WebKit/Source/core/html/media/MediaError.cpp b/third_party/WebKit/Source/core/html/media/MediaError.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6a20659cdee4fc200050afd2c7e6b2426f395e17
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/media/MediaError.cpp
@@ -0,0 +1,32 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/media/MediaError.h"
+
+#include "platform/json/JSONValues.h"
+
+namespace blink {
+
+MediaError::MediaError(ErrorCode code, const JSONObject* messages)
+ : code_(code) {
+ if (!messages->size()) {
+ // A message containing an empty serialized JSON object ("{}") is invalid
+ // and just an empty string should be used in this case per spec:
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#mediaerror
+ // "...whose message is a string containing any details the user agent is
+ // able to supply about the cause of the error condition, or the empty
+ // string if the user agent is unable to supply such details..."
+ message_ = "";
+ return;
+ }
+
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#mediaerror
+ // "The message and message format are not generally uniform across
+ // different user agents."
+ // We use a readily-parsable serialized JSON object to represent these error
+ // messages, if we have anything additional to report beyond just the code.
+ message_ = messages->ToJSONString();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698