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

Unified Diff: content/common/android/gin_java_bridge_value.h

Issue 252393004: [Android] Add GinJavaBridgeValue for Gin Java Bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 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
« no previous file with comments | « no previous file | content/common/android/gin_java_bridge_value.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/android/gin_java_bridge_value.h
diff --git a/content/common/android/gin_java_bridge_value.h b/content/common/android/gin_java_bridge_value.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a7f3eb8f51d5cb7615f3ca25951e69171d4bc09
--- /dev/null
+++ b/content/common/android/gin_java_bridge_value.h
@@ -0,0 +1,65 @@
+// 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.
+
+#ifndef CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
+#define CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/pickle.h"
+#include "base/values.h"
+#include "content/common/content_export.h"
+
+// In Java Bridge, we need to pass some kinds of values that can't
+// be put into base::Value. And since base::Value is not extensible,
+// we transfer these special values via base::BinaryValue.
+
+namespace content {
+
+class GinJavaBridgeValue {
+ public:
+ enum Type {
+ TYPE_FIRST_VALUE = 0,
+ // JavaScript 'undefined'
+ TYPE_UNDEFINED = 0,
+ // JavaScript NaN and Infinity
+ TYPE_NONFINITE,
+ // Bridge Object ID
+ TYPE_OBJECT_ID,
+ TYPE_LAST_VALUE
+ };
+
+ // Serialization
+ CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateUndefinedValue();
+ CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateNonFiniteValue(
+ float in_value);
+ CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateNonFiniteValue(
+ double in_value);
+ CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateObjectIDValue(
+ int32 in_value);
+
+ // De-serialization
+ CONTENT_EXPORT static bool ContainsGinJavaBridgeValue(
+ const base::Value* value);
+ CONTENT_EXPORT static scoped_ptr<const GinJavaBridgeValue> FromValue(
+ const base::Value* value);
+
+ CONTENT_EXPORT Type GetType() const;
+ CONTENT_EXPORT bool IsType(Type type) const;
+
+ CONTENT_EXPORT bool GetAsNonFinite(float* out_value) const;
+ CONTENT_EXPORT bool GetAsObjectID(int32* out_object_id) const;
+
+ private:
+ explicit GinJavaBridgeValue(Type type);
+ explicit GinJavaBridgeValue(const base::BinaryValue* value);
+ base::BinaryValue* SerializeToBinaryValue();
+
+ Pickle pickle_;
+
+ DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeValue);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
« no previous file with comments | « no previous file | content/common/android/gin_java_bridge_value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698