org.chromium.sdk/src/org/chromium/sdk/internal/tools/v8/V8CommandCallbackBase.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Mon, 07 Jun 2010 16:51:19 -0700
changeset 355 8726e95bcbba
parent 276 f2f4a1259de8
permissions -rw-r--r--
Initial commit of updated Chrome Java SDK
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
276
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
// Use of this source code is governed by a BSD-style license that can be
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
// found in the LICENSE file.
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
package org.chromium.sdk.internal.tools.v8;
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
import org.chromium.sdk.internal.protocol.CommandResponse;
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
import org.chromium.sdk.internal.protocol.SuccessCommandResponse;
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
/**
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * A basic implementation of {@link V8CommandProcessor.V8HandlerCallback} that introduces
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * command success and failure handlers and dispatches the V8 response accordingly.
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 */
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
public abstract class V8CommandCallbackBase implements V8CommandProcessor.V8HandlerCallback {
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
  public abstract void success(SuccessCommandResponse successResponse);
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
  public abstract void failure(String message);
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
  public void messageReceived(CommandResponse response) {
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
    SuccessCommandResponse successResponse = response.asSuccess();
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
    if (successResponse == null) {
355
8726e95bcbba Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 276
diff changeset
    22
      this.failure("Remote error: " + response.asFailure().getMessage());
276
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
      return;
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
    } else {
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
      success(successResponse);
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
    }
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
  }
f2f4a1259de8 Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
}