Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_ | |
| 6 #define CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_ | |
| 7 | |
| 8 #include "base/pickle.h" | |
| 9 #include "base/values.h" | |
| 10 | |
| 11 // In Java Bridge, we need to pass some kinds of values that can't | |
| 12 // be put into base::Value. And since base::Value is not extensible, | |
| 13 // we transfer these special values via base::BinaryValue. | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class GinJavaBridgeValue { | |
| 18 public: | |
| 19 enum Type { | |
| 20 TYPE_FIRST_VALUE = 0, | |
| 21 // JavaScript 'undefined' | |
| 22 TYPE_UNDEFINED = 0, | |
| 23 // JavaScript NaN and Infinity | |
| 24 TYPE_NONFINITE, | |
| 25 // Bridge Object ID | |
| 26 TYPE_OBJECT_ID, | |
| 27 TYPE_LAST_VALUE | |
| 28 }; | |
| 29 | |
| 30 // Serialization | |
| 31 static base::BinaryValue* CreateUndefinedValue(); | |
|
bulach
2014/04/24 12:49:27
should these be returning scoped_ptr? I think fact
mnaganov (inactive)
2014/04/24 15:24:42
A great idea! After making this change I discovere
| |
| 32 static base::BinaryValue* CreateNonFiniteValue(float in_value); | |
| 33 static base::BinaryValue* CreateNonFiniteValue(double in_value); | |
| 34 static base::BinaryValue* CreateObjectIDValue(int32 in_value); | |
| 35 | |
| 36 // De-serialization | |
| 37 static bool ContainsGinJavaBridgeValue(const base::Value* value); | |
| 38 static const GinJavaBridgeValue* FromValue(const base::Value* value); | |
| 39 | |
| 40 Type GetType() const; | |
| 41 bool IsType(Type type) const; | |
| 42 | |
| 43 bool GetAsNonFinite(float* out_value) const; | |
| 44 bool GetAsObjectID(int32* out_object_id) const; | |
| 45 | |
| 46 private: | |
| 47 explicit GinJavaBridgeValue(Type type); | |
| 48 explicit GinJavaBridgeValue(const base::BinaryValue* value); | |
| 49 base::BinaryValue* SerializeToBinaryValue(); | |
| 50 | |
| 51 Pickle pickle_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeValue); | |
| 54 }; | |
| 55 | |
| 56 } // namespace content | |
| 57 | |
| 58 #endif // CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_ | |
| OLD | NEW |