| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 package org.chromium.sdk.internal.v8native; | 5 package org.chromium.sdk.internal.v8native; |
| 6 | 6 |
| 7 import org.chromium.sdk.internal.v8native.protocol.input.CommandResponse; | 7 import org.chromium.sdk.internal.v8native.protocol.input.CommandResponse; |
| 8 import org.chromium.sdk.internal.v8native.protocol.input.FailedCommandResponse; | 8 import org.chromium.sdk.internal.v8native.protocol.input.FailedCommandResponse; |
| 9 import org.chromium.sdk.internal.v8native.protocol.input.SuccessCommandResponse; | 9 import org.chromium.sdk.internal.v8native.protocol.input.SuccessCommandResponse; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A basic implementation of {@link V8CommandProcessor.V8HandlerCallback} that i
ntroduces | 12 * A basic implementation of {@link V8CommandProcessor.V8HandlerCallback} that i
ntroduces |
| 13 * command success and failure handlers and dispatches the V8 response according
ly. | 13 * command success and failure handlers and dispatches the V8 response according
ly. |
| 14 */ | 14 */ |
| 15 public abstract class V8CommandCallbackBase implements V8CommandProcessor.V8Hand
lerCallback { | 15 public abstract class V8CommandCallbackBase implements V8CommandProcessor.V8Hand
lerCallback { |
| 16 public abstract void success(SuccessCommandResponse successResponse); | 16 public abstract void success(SuccessCommandResponse successResponse); |
| 17 | 17 |
| 18 @Override |
| 19 final public void failure(String message) { |
| 20 failure(message, null); |
| 21 } |
| 22 |
| 18 public abstract void failure(String message, FailedCommandResponse.ErrorDetail
s errorDetails); | 23 public abstract void failure(String message, FailedCommandResponse.ErrorDetail
s errorDetails); |
| 19 | 24 |
| 20 @Override | 25 @Override |
| 21 public void messageReceived(CommandResponse response) { | 26 public void messageReceived(CommandResponse response) { |
| 22 SuccessCommandResponse successResponse = response.asSuccess(); | 27 SuccessCommandResponse successResponse = response.asSuccess(); |
| 23 if (successResponse == null) { | 28 if (successResponse == null) { |
| 24 FailedCommandResponse failure = response.asFailure(); | 29 FailedCommandResponse failure = response.asFailure(); |
| 25 failure("Remote error: " + failure.message(), failure.errorDetails()); | 30 failure("Remote error: " + failure.message(), failure.errorDetails()); |
| 26 } else { | 31 } else { |
| 27 success(successResponse); | 32 success(successResponse); |
| 28 } | 33 } |
| 29 } | 34 } |
| 30 | |
| 31 @Override | |
| 32 final public void failure(String message) { | |
| 33 failure(message, null); | |
| 34 } | |
| 35 } | 35 } |
| OLD | NEW |