Commit c774d5e3 authored by harkness's avatar harkness Committed by Commit bot

DCHECK in BudgetService getCost and reserve if an invalid type is supplied.

If an incorrect type is provided to the call, the generated IDL code will
reject with a TypeError. This patch removes code in the service
implementation which was checking whether the type was invalid and returning
a NotSupportedError. The only way this code could be hit would be if there
was a programming error, so it should be a DCHECK.

BUG=672113

Review-Url: https://codereview.chromium.org/2570463003
Cr-Commit-Position: refs/heads/master@{#437897}
parent 7ff01856
...@@ -65,10 +65,7 @@ ScriptPromise BudgetService::getCost(ScriptState* scriptState, ...@@ -65,10 +65,7 @@ ScriptPromise BudgetService::getCost(ScriptState* scriptState,
scriptState, DOMException::create(SecurityError, errorMessage)); scriptState, DOMException::create(SecurityError, errorMessage));
mojom::blink::BudgetOperationType type = stringToOperationType(operation); mojom::blink::BudgetOperationType type = stringToOperationType(operation);
if (type == mojom::blink::BudgetOperationType::INVALID_OPERATION) DCHECK_NE(type, mojom::blink::BudgetOperationType::INVALID_OPERATION);
return ScriptPromise::rejectWithDOMException(
scriptState, DOMException::create(NotSupportedError,
"Invalid operation type specified"));
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise(); ScriptPromise promise = resolver->promise();
...@@ -129,10 +126,7 @@ ScriptPromise BudgetService::reserve(ScriptState* scriptState, ...@@ -129,10 +126,7 @@ ScriptPromise BudgetService::reserve(ScriptState* scriptState,
DCHECK(m_service); DCHECK(m_service);
mojom::blink::BudgetOperationType type = stringToOperationType(operation); mojom::blink::BudgetOperationType type = stringToOperationType(operation);
if (type == mojom::blink::BudgetOperationType::INVALID_OPERATION) DCHECK_NE(type, mojom::blink::BudgetOperationType::INVALID_OPERATION);
return ScriptPromise::rejectWithDOMException(
scriptState, DOMException::create(NotSupportedError,
"Invalid operation type specified"));
String errorMessage; String errorMessage;
if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) if (!scriptState->getExecutionContext()->isSecureContext(errorMessage))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment