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

Unified Diff: third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 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: third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
diff --git a/third_party/protobuf/src/google/protobuf/unittest_mset.proto b/third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
similarity index 52%
copy from third_party/protobuf/src/google/protobuf/unittest_mset.proto
copy to third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
index 3497f09fa6d41b7b38357e7f2610dfb5c087d3e4..d2f82ac5135b3664770afc8968c6fd5873541f70 100644
--- a/third_party/protobuf/src/google/protobuf/unittest_mset.proto
+++ b/third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,45 +28,72 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Author: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// This file contains messages for testing message_set_wire_format.
-
-package protobuf_unittest;
+package com.google.protobuf;
-option optimize_for = SPEED;
+import com.google.protobuf.Internal.ProtobufList;
-// A message with message_set_wire_format.
-message TestMessageSet {
- option message_set_wire_format = true;
- extensions 4 to max;
-}
+import java.util.ArrayList;
+import java.util.List;
-message TestMessageSetContainer {
- optional TestMessageSet message_set = 1;
-}
+/**
+ * Implements {@link ProtobufList} for non-primitive and {@link String} types.
+ */
+class ProtobufArrayList<E> extends AbstractProtobufList<E> {
-message TestMessageSetExtension1 {
- extend TestMessageSet {
- optional TestMessageSetExtension1 message_set_extension = 1545008;
+ private static final ProtobufArrayList<Object> EMPTY_LIST = new ProtobufArrayList<Object>();
+ static {
+ EMPTY_LIST.makeImmutable();
+ }
+
+ @SuppressWarnings("unchecked") // Guaranteed safe by runtime.
+ public static <E> ProtobufArrayList<E> emptyList() {
+ return (ProtobufArrayList<E>) EMPTY_LIST;
+ }
+
+ private final List<E> list;
+
+ ProtobufArrayList() {
+ list = new ArrayList<E>();
+ }
+
+ ProtobufArrayList(List<E> toCopy) {
+ list = new ArrayList<E>(toCopy);
+ }
+
+ ProtobufArrayList(int capacity) {
+ list = new ArrayList<E>(capacity);
+ }
+
+ @Override
+ public void add(int index, E element) {
+ ensureIsMutable();
+ list.add(index, element);
+ modCount++;
}
- optional int32 i = 15;
-}
-message TestMessageSetExtension2 {
- extend TestMessageSet {
- optional TestMessageSetExtension2 message_set_extension = 1547769;
+ @Override
+ public E get(int index) {
+ return list.get(index);
+ }
+
+ @Override
+ public E remove(int index) {
+ ensureIsMutable();
+ E toReturn = list.remove(index);
+ modCount++;
+ return toReturn;
+ }
+
+ @Override
+ public E set(int index, E element) {
+ ensureIsMutable();
+ E toReturn = list.set(index, element);
+ modCount++;
+ return toReturn;
}
- optional string str = 25;
-}
-// MessageSet wire format is equivalent to this.
-message RawMessageSet {
- repeated group Item = 1 {
- required int32 type_id = 2;
- required bytes message = 3;
+ @Override
+ public int size() {
+ return list.size();
}
}
-

Powered by Google App Engine
This is Rietveld 408576698