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

Side by Side Diff: content/public/child/v8_value_converter.h

Issue 1113783002: Use Local instead of Handle in src/content/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PUBLIC_CHILD_V8_VALUE_CONVERTER_H_ 5 #ifndef CONTENT_PUBLIC_CHILD_V8_VALUE_CONVERTER_H_
6 #define CONTENT_PUBLIC_CHILD_V8_VALUE_CONVERTER_H_ 6 #define CONTENT_PUBLIC_CHILD_V8_VALUE_CONVERTER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 #include "v8/include/v8.h" 10 #include "v8/include/v8.h"
(...skipping 11 matching lines...) Expand all
22 // The JSON types (null, boolean, string, number, array, and object) as well as 22 // The JSON types (null, boolean, string, number, array, and object) as well as
23 // binary values are supported. For binary values, we convert to WebKit 23 // binary values are supported. For binary values, we convert to WebKit
24 // ArrayBuffers, and support converting from an ArrayBuffer or any of the 24 // ArrayBuffers, and support converting from an ArrayBuffer or any of the
25 // ArrayBufferView subclasses (Uint8Array, etc.). 25 // ArrayBufferView subclasses (Uint8Array, etc.).
26 class CONTENT_EXPORT V8ValueConverter { 26 class CONTENT_EXPORT V8ValueConverter {
27 public: 27 public:
28 // Extends the default behaviour of V8ValueConverter. 28 // Extends the default behaviour of V8ValueConverter.
29 class CONTENT_EXPORT Strategy { 29 class CONTENT_EXPORT Strategy {
30 public: 30 public:
31 typedef base::Callback<base::Value*( 31 typedef base::Callback<base::Value*(
32 v8::Handle<v8::Value>, v8::Isolate* isolate)> FromV8ValueCallback; 32 v8::Local<v8::Value>, v8::Isolate* isolate)> FromV8ValueCallback;
33 33
34 virtual ~Strategy() {} 34 virtual ~Strategy() {}
35 35
36 // If false is returned, V8ValueConverter proceeds with the default 36 // If false is returned, V8ValueConverter proceeds with the default
37 // behavior. 37 // behavior.
38 // Use |callback| to convert any child values, as this will retain 38 // Use |callback| to convert any child values, as this will retain
39 // the ValueConverter's internal checks for depth and cycles. 39 // the ValueConverter's internal checks for depth and cycles.
40 virtual bool FromV8Object(v8::Handle<v8::Object> value, 40 virtual bool FromV8Object(v8::Local<v8::Object> value,
41 base::Value** out, 41 base::Value** out,
42 v8::Isolate* isolate, 42 v8::Isolate* isolate,
43 const FromV8ValueCallback& callback) const; 43 const FromV8ValueCallback& callback) const;
44 44
45 // If false is returned, V8ValueConverter proceeds with the default 45 // If false is returned, V8ValueConverter proceeds with the default
46 // behavior. 46 // behavior.
47 // Use |callback| to convert any child values, as this will retain 47 // Use |callback| to convert any child values, as this will retain
48 // the ValueConverter's internal checks for depth and cycles. 48 // the ValueConverter's internal checks for depth and cycles.
49 virtual bool FromV8Array(v8::Handle<v8::Array> value, 49 virtual bool FromV8Array(v8::Local<v8::Array> value,
50 base::Value** out, 50 base::Value** out,
51 v8::Isolate* isolate, 51 v8::Isolate* isolate,
52 const FromV8ValueCallback& callback) const; 52 const FromV8ValueCallback& callback) const;
53 53
54 // If false is returned, V8ValueConverter proceeds with the default 54 // If false is returned, V8ValueConverter proceeds with the default
55 // behavior. v8::Object is passed as ArrayBuffer and ArrayBufferView 55 // behavior. v8::Object is passed as ArrayBuffer and ArrayBufferView
56 // classes are siblings. 56 // classes are siblings.
57 virtual bool FromV8ArrayBuffer(v8::Handle<v8::Object> value, 57 virtual bool FromV8ArrayBuffer(v8::Local<v8::Object> value,
58 base::Value** out, 58 base::Value** out,
59 v8::Isolate* isolate) const; 59 v8::Isolate* isolate) const;
60 60
61 // If false is returned, V8ValueConverter proceeds with the default 61 // If false is returned, V8ValueConverter proceeds with the default
62 // behavior. This allows to intercept "non-finite" values and do something 62 // behavior. This allows to intercept "non-finite" values and do something
63 // with them. 63 // with them.
64 virtual bool FromV8Number(v8::Handle<v8::Number> value, 64 virtual bool FromV8Number(v8::Local<v8::Number> value,
65 base::Value** out) const; 65 base::Value** out) const;
66 66
67 // If false is returned, V8ValueConverter proceeds with the default 67 // If false is returned, V8ValueConverter proceeds with the default
68 // behavior. 68 // behavior.
69 virtual bool FromV8Undefined(base::Value** out) const; 69 virtual bool FromV8Undefined(base::Value** out) const;
70 }; 70 };
71 71
72 static V8ValueConverter* create(); 72 static V8ValueConverter* create();
73 73
74 virtual ~V8ValueConverter() {} 74 virtual ~V8ValueConverter() {}
(...skipping 23 matching lines...) Expand all
98 virtual void SetStripNullFromObjects(bool val) = 0; 98 virtual void SetStripNullFromObjects(bool val) = 0;
99 99
100 // Extend default behavior of V8ValueConverter. 100 // Extend default behavior of V8ValueConverter.
101 virtual void SetStrategy(Strategy* strategy) = 0; 101 virtual void SetStrategy(Strategy* strategy) = 0;
102 102
103 // Converts a base::Value to a v8::Value. 103 // Converts a base::Value to a v8::Value.
104 // 104 //
105 // Unsupported types are replaced with null. If an array or object throws 105 // Unsupported types are replaced with null. If an array or object throws
106 // while setting a value, that property or item is skipped, leaving a hole in 106 // while setting a value, that property or item is skipped, leaving a hole in
107 // the case of arrays. 107 // the case of arrays.
108 virtual v8::Handle<v8::Value> ToV8Value( 108 virtual v8::Local<v8::Value> ToV8Value(
109 const base::Value* value, 109 const base::Value* value,
110 v8::Handle<v8::Context> context) const = 0; 110 v8::Local<v8::Context> context) const = 0;
111 111
112 // Converts a v8::Value to base::Value. 112 // Converts a v8::Value to base::Value.
113 // 113 //
114 // Unsupported types (unless explicitly configured) are not converted, so 114 // Unsupported types (unless explicitly configured) are not converted, so
115 // this method may return NULL -- the exception is when converting arrays, 115 // this method may return NULL -- the exception is when converting arrays,
116 // where unsupported types are converted to Value(TYPE_NULL). 116 // where unsupported types are converted to Value(TYPE_NULL).
117 // 117 //
118 // Likewise, if an object throws while converting a property it will not be 118 // Likewise, if an object throws while converting a property it will not be
119 // converted, whereas if an array throws while converting an item it will be 119 // converted, whereas if an array throws while converting an item it will be
120 // converted to Value(TYPE_NULL). 120 // converted to Value(TYPE_NULL).
121 virtual base::Value* FromV8Value(v8::Handle<v8::Value> value, 121 virtual base::Value* FromV8Value(v8::Local<v8::Value> value,
122 v8::Handle<v8::Context> context) const = 0; 122 v8::Local<v8::Context> context) const = 0;
123 }; 123 };
124 124
125 } // namespace content 125 } // namespace content
126 126
127 #endif // CONTENT_PUBLIC_CHILD_V8_VALUE_CONVERTER_H_ 127 #endif // CONTENT_PUBLIC_CHILD_V8_VALUE_CONVERTER_H_
OLDNEW
« no previous file with comments | « content/child/webmessageportchannel_impl.cc ('k') | content/public/renderer/render_frame_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698