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

Unified Diff: third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pull whole protobuf 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/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java
diff --git a/third_party/WebKit/Source/core/animation/AnimationClock.cpp b/third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java
similarity index 52%
copy from third_party/WebKit/Source/core/animation/AnimationClock.cpp
copy to third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java
index 8350e211e7d5e5c4f7aad8cc6b6b2675dce51a7c..2cf210d26f58548e03805eef04114c5c337e85d6 100644
--- a/third_party/WebKit/Source/core/animation/AnimationClock.cpp
+++ b/third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java
@@ -1,5 +1,7 @@
/*
- * Copyright (c) 2014, Google Inc. All rights reserved.
+ * Protocol Buffers - Google's data interchange format
+ * Copyright 2014 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,54 +30,39 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "core/animation/AnimationClock.h"
+package com.google.protobuf.jruby;
-#include "wtf/CurrentTime.h"
-#include <math.h>
+import org.jruby.Ruby;
+import org.jruby.RubyModule;
+import org.jruby.anno.JRubyMethod;
+import org.jruby.anno.JRubyModule;
+import org.jruby.runtime.ThreadContext;
+import org.jruby.runtime.builtin.IRubyObject;
-namespace {
+@JRubyModule(name = "Protobuf")
+public class RubyProtobuf {
-// FIXME: This is an approximation of time between frames, used when
-// ticking the animation clock outside of animation frame callbacks.
-// Ideally this would be generated by the compositor.
-const double approximateFrameTime = 1 / 60.0;
-
-}
-
-namespace blink {
-
-unsigned AnimationClock::s_currentTask = 0;
-
-void AnimationClock::updateTime(double time)
-{
- if (time > m_time)
- m_time = time;
- m_currentTask = s_currentTask;
-}
+ public static void createProtobuf(Ruby runtime) {
+ RubyModule mGoogle = runtime.getModule("Google");
+ RubyModule mProtobuf = mGoogle.defineModuleUnder("Protobuf");
+ mProtobuf.defineAnnotatedMethods(RubyProtobuf.class);
+ }
-double AnimationClock::currentTime()
-{
- if (m_currentTask != s_currentTask) {
- const double currentTime = m_monotonicallyIncreasingTime();
- if (m_time < currentTime) {
- // Advance to the first estimated frame after the current time.
- const double frameShift = fmod(currentTime - m_time, approximateFrameTime);
- const double newTime = currentTime + (approximateFrameTime - frameShift);
- ASSERT(newTime >= currentTime);
- ASSERT(newTime <= currentTime + approximateFrameTime);
- updateTime(newTime);
+ /*
+ * call-seq:
+ * Google::Protobuf.deep_copy(obj) => copy_of_obj
+ *
+ * Performs a deep copy of either a RepeatedField instance or a message object,
+ * recursively copying its members.
+ */
+ @JRubyMethod(name = "deep_copy", meta = true)
+ public static IRubyObject deepCopy(ThreadContext context, IRubyObject self, IRubyObject message) {
+ if (message instanceof RubyMessage) {
+ return ((RubyMessage) message).deepCopy(context);
+ } else if (message instanceof RubyRepeatedField) {
+ return ((RubyRepeatedField) message).deepCopy(context);
} else {
- m_currentTask = s_currentTask;
+ return ((RubyMap) message).deepCopy(context);
}
}
- return m_time;
}
-
-void AnimationClock::resetTimeForTesting(double time)
-{
- m_time = time;
- m_currentTask = 0;
- s_currentTask = 0;
-}
-
-} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698