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

Unified Diff: third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.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/javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java
diff --git a/third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc b/third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java
similarity index 51%
copy from third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc
copy to third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java
index a6197854bdef63dc11bbdf0b3cf1f7884348b0e3..b1678d1b93a0b63d0e9df35adc038c233c4fc10a 100644
--- a/third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc
+++ b/third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
-// Copyright 2009 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// Copyright 2013 Google Inc. All rights reserved.
+// 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,46 +28,61 @@
// (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: brianolson@google.com (Brian Olson)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Test program to verify that GzipInputStream is compatible with command line
-// gunzip or java.util.zip.GzipInputStream
-//
-// Reads gzip stream on standard input and writes decompressed data to standard
-// output.
+package com.google.protobuf.nano;
-#include "config.h"
+import java.io.IOException;
+import java.util.Arrays;
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
+/**
+ * Stores unknown fields. These might be extensions or fields that the generated
+ * API doesn't know about yet.
+ *
+ * @author bduff@google.com (Brian Duff)
+ */
+final class UnknownFieldData {
-#include <google/protobuf/io/gzip_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
+ final int tag;
+ /**
+ * Important: this should be treated as immutable, even though it's possible
+ * to change the array values.
+ */
+ final byte[] bytes;
-using google::protobuf::io::FileInputStream;
-using google::protobuf::io::GzipInputStream;
+ UnknownFieldData(int tag, byte[] bytes) {
+ this.tag = tag;
+ this.bytes = bytes;
+ }
-int main(int argc, const char** argv) {
- FileInputStream fin(STDIN_FILENO);
- GzipInputStream in(&fin);
+ int computeSerializedSize() {
+ int size = 0;
+ size += CodedOutputByteBufferNano.computeRawVarint32Size(tag);
+ size += bytes.length;
+ return size;
+ }
- while (true) {
- const void* inptr;
- int inlen;
- bool ok;
- ok = in.Next(&inptr, &inlen);
- if (!ok) {
- break;
+ void writeTo(CodedOutputByteBufferNano output) throws IOException {
+ output.writeRawVarint32(tag);
+ output.writeRawBytes(bytes);
}
- if (inlen > 0) {
- int err = write(STDOUT_FILENO, inptr, inlen);
- assert(err == inlen);
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof UnknownFieldData)) {
+ return false;
+ }
+
+ UnknownFieldData other = (UnknownFieldData) o;
+ return tag == other.tag && Arrays.equals(bytes, other.bytes);
}
- }
- return 0;
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + tag;
+ result = 31 * result + Arrays.hashCode(bytes);
+ return result;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698