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

Unified Diff: third_party/protobuf/java/src/main/java/com/google/protobuf/UnsafeByteStrings.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/UnsafeByteStrings.java
diff --git a/third_party/protobuf/src/google/protobuf/unittest_optimize_for.proto b/third_party/protobuf/java/src/main/java/com/google/protobuf/UnsafeByteStrings.java
similarity index 63%
copy from third_party/protobuf/src/google/protobuf/unittest_optimize_for.proto
copy to third_party/protobuf/java/src/main/java/com/google/protobuf/UnsafeByteStrings.java
index feecbef8d4a90961b35be988402e49e74fed313c..c1997515d0fc8ac03078aecb027c3d1246ff564f 100644
--- a/third_party/protobuf/src/google/protobuf/unittest_optimize_for.proto
+++ b/third_party/protobuf/java/src/main/java/com/google/protobuf/UnsafeByteStrings.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,34 +28,28 @@
// (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.
-//
-// A proto file which uses optimize_for = CODE_SIZE.
-
-import "google/protobuf/unittest.proto";
-
-package protobuf_unittest;
-
-option optimize_for = CODE_SIZE;
-
-message TestOptimizedForSize {
- optional int32 i = 1;
- optional ForeignMessage msg = 19;
-
- extensions 1000 to max;
-
- extend TestOptimizedForSize {
- optional int32 test_extension = 1234;
- optional TestRequiredOptimizedForSize test_extension2 = 1235;
+package com.google.protobuf;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Provides unsafe factory methods for {@link ByteString} instances.
+ *
+ * <p><strong>DISCLAIMER:</strong> The methods in this class should only be called if it is
+ * guaranteed that the the buffer backing the {@link ByteString} will never change! Mutation of a
+ * {@link ByteString} can lead to unexpected and undesirable consequences in your application,
+ * and will likely be difficult to debug. Proceed with caution!
+ */
+public final class UnsafeByteStrings {
+ private UnsafeByteStrings() {}
+
+ /**
+ * An unsafe operation that returns a {@link ByteString} that is backed by the provided buffer.
+ *
+ * @param buffer the Java NIO buffer to be wrapped.
+ * @return a {@link ByteString} backed by the provided buffer.
+ */
+ public static ByteString unsafeWrap(ByteBuffer buffer) {
+ return new NioByteString(buffer);
}
}
-
-message TestRequiredOptimizedForSize {
- required int32 x = 1;
-}
-
-message TestOptionalOptimizedForSize {
- optional TestRequiredOptimizedForSize o = 1;
-}

Powered by Google App Engine
This is Rietveld 408576698