Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: components/devtools_bridge/test/android/javatests/src/org/chromium/components/devtools_bridge/gcd/TestMessageReader.java

Issue 1142463003: Remove devtools_bridge component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/devtools_bridge/test/android/javatests/src/org/chromium/components/devtools_bridge/gcd/TestMessageReader.java
diff --git a/components/devtools_bridge/test/android/javatests/src/org/chromium/components/devtools_bridge/gcd/TestMessageReader.java b/components/devtools_bridge/test/android/javatests/src/org/chromium/components/devtools_bridge/gcd/TestMessageReader.java
deleted file mode 100644
index 3505af8ae35307f63b6d1e81f232b3f47922d7c2..0000000000000000000000000000000000000000
--- a/components/devtools_bridge/test/android/javatests/src/org/chromium/components/devtools_bridge/gcd/TestMessageReader.java
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.components.devtools_bridge.gcd;
-
-import android.util.JsonReader;
-import android.util.Log;
-
-import org.chromium.components.devtools_bridge.commands.Command;
-import org.chromium.components.devtools_bridge.commands.CommandFormatException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Reader for additional messages (used only in the testing app).
- */
-public final class TestMessageReader {
- private static final String TAG = "TestMessageReader";
-
- private final JsonReader mReader;
-
- public TestMessageReader(JsonReader reader) {
- mReader = reader;
- }
-
- public List<RemoteInstance> readRemoteInstances() throws IOException {
- final List<RemoteInstance> result = new ArrayList<RemoteInstance>();
-
- mReader.beginObject();
- while (mReader.hasNext()) {
- String name = mReader.nextName();
- if (name.equals("devices")) {
- mReader.beginArray();
- while (mReader.hasNext()) {
- result.add(readInstance());
- }
- mReader.endArray();
- } else {
- mReader.skipValue();
- }
- }
- mReader.endObject();
- return result;
- }
-
- private RemoteInstance readInstance() throws IOException {
- String id = null;
- String displayName = null;
-
- mReader.beginObject();
- while (mReader.hasNext()) {
- String name = mReader.nextName();
- if (name.equals("id")) {
- id = mReader.nextString();
- } else if (name.equals("displayName")) {
- displayName = mReader.nextString();
- } else {
- mReader.skipValue();
- }
- }
- mReader.endObject();
- if (id == null) {
- throw new IllegalArgumentException("Missing remote instance id");
- }
- if (displayName == null) {
- throw new IllegalArgumentException("Missing remote instance display name");
- }
- return new RemoteInstance(id, displayName);
- }
-
- public void readCommandResult(Command command) throws IOException {
- String state = null;
- Map<String, String> outParams = null;
- String errorMessage = null;
-
- mReader.beginObject();
- while (mReader.hasNext()) {
- String name = mReader.nextName();
- if (name.equals("state")) {
- state = mReader.nextString();
- } else if (name.equals("results")) {
- outParams = MessageReader.readStringMap(mReader);
- } else if (name.equals("error")) {
- errorMessage = readErrorMessage();
- } else {
- mReader.skipValue();
- }
- }
- mReader.endObject();
-
- if ("done".equals(state) && outParams != null) {
- try {
- command.setSuccess(outParams);
- } catch (CommandFormatException e) {
- Log.e(TAG, "Invalid command format", e);
- command.setFailure("Invalid format: " + e.getMessage());
- }
- } else if ("error".equals(state) && errorMessage != null) {
- Log.w(TAG, "Command error: " + errorMessage);
- command.setFailure(errorMessage);
- } else {
- Log.w(TAG, "Invalid command state: " + state);
- command.setFailure("Invalid state: " + state);
- }
- }
-
- private String readErrorMessage() throws IOException {
- String result = null;
- mReader.beginObject();
- while (mReader.hasNext()) {
- if (mReader.nextName().equals("message")) {
- result = mReader.nextString();
- } else {
- mReader.skipValue();
- }
- }
- mReader.endObject();
- return result;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698