| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" | 5 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 { | 64 { |
| 65 NOTREACHED(); | 65 NOTREACHED(); |
| 66 reject(InvalidStateError, "Unexpected completion."); | 66 reject(InvalidStateError, "Unexpected completion."); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ContentDecryptionModuleResultPromise::completeWithError(WebContentDecryptio
nModuleException exceptionCode, unsigned long systemCode, const WebString& error
Message) | 69 void ContentDecryptionModuleResultPromise::completeWithError(WebContentDecryptio
nModuleException exceptionCode, unsigned long systemCode, const WebString& error
Message) |
| 70 { | 70 { |
| 71 // Non-zero |systemCode| is appended to the |errorMessage|. If the | 71 // Non-zero |systemCode| is appended to the |errorMessage|. If the |
| 72 // |errorMessage| is empty, we'll report "Rejected with system code | 72 // |errorMessage| is empty, we'll report "Rejected with system code |
| 73 // (systemCode)". | 73 // (systemCode)". |
| 74 String errorString = errorMessage; | 74 StringBuilder result; |
| 75 result.append(errorMessage); |
| 75 if (systemCode != 0) { | 76 if (systemCode != 0) { |
| 76 if (errorString.isEmpty()) | 77 if (result.isEmpty()) |
| 77 errorString.append("Rejected with system code"); | 78 result.append("Rejected with system code"); |
| 78 errorString.append(" (" + String::number(systemCode) + ")"); | 79 result.append(" ("); |
| 80 result.appendNumber(systemCode); |
| 81 result.append(')'); |
| 79 } | 82 } |
| 80 reject(WebCdmExceptionToExceptionCode(exceptionCode), errorString); | 83 reject(WebCdmExceptionToExceptionCode(exceptionCode), result.toString()); |
| 81 } | 84 } |
| 82 | 85 |
| 83 ScriptPromise ContentDecryptionModuleResultPromise::promise() | 86 ScriptPromise ContentDecryptionModuleResultPromise::promise() |
| 84 { | 87 { |
| 85 return m_resolver->promise(); | 88 return m_resolver->promise(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri
ng& errorMessage) | 91 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri
ng& errorMessage) |
| 89 { | 92 { |
| 90 // Reject the promise asynchronously. This avoids problems when gc is | 93 // Reject the promise asynchronously. This avoids problems when gc is |
| (...skipping 16 matching lines...) Expand all Loading... |
| 107 return m_resolver->getExecutionContext(); | 110 return m_resolver->getExecutionContext(); |
| 108 } | 111 } |
| 109 | 112 |
| 110 DEFINE_TRACE(ContentDecryptionModuleResultPromise) | 113 DEFINE_TRACE(ContentDecryptionModuleResultPromise) |
| 111 { | 114 { |
| 112 visitor->trace(m_resolver); | 115 visitor->trace(m_resolver); |
| 113 ContentDecryptionModuleResult::trace(visitor); | 116 ContentDecryptionModuleResult::trace(visitor); |
| 114 } | 117 } |
| 115 | 118 |
| 116 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |