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

Unified Diff: components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/commands/ParamDefinitions.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/android/java/src/org/chromium/components/devtools_bridge/commands/ParamDefinitions.java
diff --git a/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/commands/ParamDefinitions.java b/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/commands/ParamDefinitions.java
deleted file mode 100644
index c2b0446df72cfe56d2206429aee6a46138a856e1..0000000000000000000000000000000000000000
--- a/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/commands/ParamDefinitions.java
+++ /dev/null
@@ -1,203 +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.commands;
-
-import android.util.JsonReader;
-import android.util.JsonWriter;
-
-import org.chromium.components.devtools_bridge.RTCConfiguration;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Hepler class with a collection of parameter definitions.
- */
-final class ParamDefinitions {
- public static ParamDefinition<String> newStringParam(String name) {
- return new ParamDefinition<String>(name) {
- @Override
- protected String fromString(String value) {
- return value;
- }
-
- @Override
- protected String toString(String value) {
- return value;
- }
- };
- }
-
- public static ParamDefinition<List<String>> newStringListParam(String name) {
- return new ParamDefinition<List<String>>(name) {
- @Override
- protected List<String> fromString(String value) throws CommandFormatException {
- try {
- return new ParamReader(value)
- .readStringList()
- .close()
- .stringListResult;
- } catch (Exception e) {
- throw newException(this, "Expected JSON-serialized string list", e);
- }
- }
-
- @Override
- protected String toString(List<String> value) {
- try {
- return new ParamWriter().write(value).close().toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- };
- }
-
- public static ParamDefinition<RTCConfiguration> newConfigParam(String name) {
- return new ParamDefinition<RTCConfiguration>(name) {
- @Override
- protected RTCConfiguration fromString(String value) throws CommandFormatException {
- try {
- return new ParamReader(value)
- .readConfig()
- .close()
- .configResult;
- } catch (Exception e) {
- throw newException(this, "Expected WebRTC configuration", e);
- }
- }
-
- @Override
- protected String toString(RTCConfiguration value) {
- try {
- return new ParamWriter().write(value).close().toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- };
- }
-
- private static CommandFormatException newException(
- ParamDefinition<?> param, String message, Exception cause) {
- return new CommandFormatException(
- "Exception in parameter " + param.name() + ": " + message, cause);
- }
-
- private static class ParamReader {
- private final JsonReader mReader;
-
- public List<String> stringListResult;
- public RTCConfiguration configResult;
-
- public ParamReader(String source) {
- mReader = new JsonReader(new StringReader(source));
- }
-
- public ParamReader readStringList() throws IOException {
- stringListResult = new ArrayList<String>();
- mReader.beginArray();
- while (mReader.hasNext()) {
- stringListResult.add(mReader.nextString());
- }
- mReader.endArray();
- return this;
- }
-
- public ParamReader readConfig() throws IOException {
- RTCConfiguration.Builder builder = new RTCConfiguration.Builder();
- mReader.beginObject();
- while (mReader.hasNext()) {
- String name = mReader.nextName();
- if ("iceServers".equals(name)) {
- readIceServerList(builder);
- } else {
- mReader.skipValue();
- }
- }
- configResult = builder.build();
- return this;
- }
-
- public ParamReader close() throws IOException {
- mReader.close();
- return this;
- }
-
- private void readIceServerList(RTCConfiguration.Builder builder) throws IOException {
- mReader.beginArray();
- while (mReader.hasNext()) {
- readIceServer(builder);
- }
- mReader.endArray();
- }
-
- private void readIceServer(RTCConfiguration.Builder builder) throws IOException {
- String uri = null;
- String username = "";
- String credential = "";
- mReader.beginObject();
- while (mReader.hasNext()) {
- String name = mReader.nextName();
- if ("uri".equals(name)) {
- uri = mReader.nextString();
- } else if ("username".equals(name)) {
- username = mReader.nextString();
- } else if ("credential".equals(name)) {
- credential = mReader.nextString();
- } else {
- mReader.skipValue();
- }
- }
- mReader.endObject();
- if (uri != null) {
- builder.addIceServer(uri, username, credential);
- }
- }
- }
-
- private static class ParamWriter {
- private final StringWriter mStringWriter = new StringWriter();
- private final JsonWriter mWriter = new JsonWriter(mStringWriter);
-
- public ParamWriter write(List<String> value) throws IOException {
- mWriter.beginArray();
- for (String item : value) {
- mWriter.value(item);
- }
- mWriter.endArray();
- return this;
- }
-
- public ParamWriter write(RTCConfiguration config) throws IOException {
- mWriter.beginObject();
- mWriter.name("iceServers");
- mWriter.beginArray();
- for (RTCConfiguration.IceServer server : config.iceServers) {
- mWriter.beginObject();
- mWriter.name("uri").value(server.uri);
- mWriter.name("username").value(server.username);
- mWriter.name("credential").value(server.credential);
- mWriter.endObject();
- }
- mWriter.endArray();
- mWriter.endObject();
- return this;
- }
-
- public ParamWriter close() throws IOException {
- mWriter.close();
- return this;
- }
-
- @Override
- public String toString() {
- return mStringWriter.toString();
- }
- }
-}

Powered by Google App Engine
This is Rietveld 408576698