Promote LoseForTesting to ForceLoss device so that user agents can use.

Bug: chromium:1356738
Change-Id: I348837ad4224124d9adba1ecf69a05b2060760c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100566
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Loko Kung
2022-08-29 22:33:50 +00:00
committed by Dawn LUCI CQ
parent be4c9f48aa
commit 3a53edcf18
5 changed files with 21 additions and 10 deletions

View File

@@ -479,7 +479,9 @@ void DeviceBase::APIDestroy() {
Destroy();
}
void DeviceBase::HandleError(InternalErrorType type, const char* message) {
void DeviceBase::HandleError(InternalErrorType type,
const char* message,
WGPUDeviceLostReason lost_reason) {
if (type == InternalErrorType::DeviceLost) {
mState = State::Disconnected;
@@ -519,7 +521,7 @@ void DeviceBase::HandleError(InternalErrorType type, const char* message) {
if (type == InternalErrorType::DeviceLost) {
// The device was lost, call the application callback.
if (mDeviceLostCallback != nullptr) {
mDeviceLostCallback(WGPUDeviceLostReason_Undefined, message, mDeviceLostUserdata);
mDeviceLostCallback(lost_reason, message, mDeviceLostUserdata);
mDeviceLostCallback = nullptr;
}
@@ -668,12 +670,11 @@ MaybeError DeviceBase::ValidateIsAlive() const {
return {};
}
void DeviceBase::APILoseForTesting() {
void DeviceBase::APIForceLoss(wgpu::DeviceLostReason reason, const char* message) {
if (mState != State::Alive) {
return;
}
HandleError(InternalErrorType::Internal, "Device lost for testing");
HandleError(InternalErrorType::Internal, message, ToAPI(reason));
}
DeviceBase::State DeviceBase::GetState() const {