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

Side by Side Diff: content/common/android/gin_java_bridge_value.h

Issue 2799093006: Remove base::BinaryValue (Closed)
Patch Set: Rebase Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_ 5 #ifndef CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
6 #define CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_ 6 #define CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/pickle.h" 13 #include "base/pickle.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 16
17 // In Java Bridge, we need to pass some kinds of values that can't 17 // In Java Bridge, we need to pass some kinds of values that can't
18 // be put into base::Value. And since base::Value is not extensible, 18 // be put into base::Value. And since base::Value is not extensible,
19 // we transfer these special values via base::BinaryValue. 19 // we transfer these special values via base::Value.
20 20
21 namespace content { 21 namespace content {
22 22
23 class GinJavaBridgeValue { 23 class GinJavaBridgeValue {
24 public: 24 public:
25 enum Type { 25 enum Type {
26 TYPE_FIRST_VALUE = 0, 26 TYPE_FIRST_VALUE = 0,
27 // JavaScript 'undefined' 27 // JavaScript 'undefined'
28 TYPE_UNDEFINED = 0, 28 TYPE_UNDEFINED = 0,
29 // JavaScript NaN and Infinity 29 // JavaScript NaN and Infinity
30 TYPE_NONFINITE, 30 TYPE_NONFINITE,
31 // Bridge Object ID 31 // Bridge Object ID
32 TYPE_OBJECT_ID, 32 TYPE_OBJECT_ID,
33 TYPE_LAST_VALUE 33 TYPE_LAST_VALUE
34 }; 34 };
35 35
36 // Serialization 36 // Serialization
37 CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> 37 CONTENT_EXPORT static std::unique_ptr<base::Value> CreateUndefinedValue();
38 CreateUndefinedValue(); 38 CONTENT_EXPORT static std::unique_ptr<base::Value> CreateNonFiniteValue(
39 CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateNonFiniteValue(
40 float in_value); 39 float in_value);
41 CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateNonFiniteValue( 40 CONTENT_EXPORT static std::unique_ptr<base::Value> CreateNonFiniteValue(
42 double in_value); 41 double in_value);
43 CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateObjectIDValue( 42 CONTENT_EXPORT static std::unique_ptr<base::Value> CreateObjectIDValue(
44 int32_t in_value); 43 int32_t in_value);
45 44
46 // De-serialization 45 // De-serialization
47 CONTENT_EXPORT static bool ContainsGinJavaBridgeValue( 46 CONTENT_EXPORT static bool ContainsGinJavaBridgeValue(
48 const base::Value* value); 47 const base::Value* value);
49 CONTENT_EXPORT static std::unique_ptr<const GinJavaBridgeValue> FromValue( 48 CONTENT_EXPORT static std::unique_ptr<const GinJavaBridgeValue> FromValue(
50 const base::Value* value); 49 const base::Value* value);
51 50
52 CONTENT_EXPORT Type GetType() const; 51 CONTENT_EXPORT Type GetType() const;
53 CONTENT_EXPORT bool IsType(Type type) const; 52 CONTENT_EXPORT bool IsType(Type type) const;
54 53
55 CONTENT_EXPORT bool GetAsNonFinite(float* out_value) const; 54 CONTENT_EXPORT bool GetAsNonFinite(float* out_value) const;
56 CONTENT_EXPORT bool GetAsObjectID(int32_t* out_object_id) const; 55 CONTENT_EXPORT bool GetAsObjectID(int32_t* out_object_id) const;
57 56
58 private: 57 private:
59 explicit GinJavaBridgeValue(Type type); 58 explicit GinJavaBridgeValue(Type type);
60 explicit GinJavaBridgeValue(const base::BinaryValue* value); 59 explicit GinJavaBridgeValue(const base::Value* value);
61 std::unique_ptr<base::BinaryValue> SerializeToBinaryValue(); 60 std::unique_ptr<base::Value> SerializeToBinaryValue();
62 61
63 base::Pickle pickle_; 62 base::Pickle pickle_;
64 63
65 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeValue); 64 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeValue);
66 }; 65 };
67 66
68 } // namespace content 67 } // namespace content
69 68
70 #endif // CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_ 69 #endif // CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
OLDNEW
« no previous file with comments | « content/child/v8_value_converter_impl_unittest.cc ('k') | content/common/android/gin_java_bridge_value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698