OLD | NEW |
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 #include "content/renderer/v8_value_converter_impl.h" | 5 #include "content/renderer/v8_value_converter_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/float_util.h" | 9 #include "base/float_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 strip_null_from_objects_ = val; | 105 strip_null_from_objects_ = val; |
106 } | 106 } |
107 | 107 |
108 void V8ValueConverterImpl::SetStrategy(Strategy* strategy) { | 108 void V8ValueConverterImpl::SetStrategy(Strategy* strategy) { |
109 strategy_ = strategy; | 109 strategy_ = strategy; |
110 } | 110 } |
111 | 111 |
112 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value( | 112 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value( |
113 const base::Value* value, v8::Handle<v8::Context> context) const { | 113 const base::Value* value, v8::Handle<v8::Context> context) const { |
114 v8::Context::Scope context_scope(context); | 114 v8::Context::Scope context_scope(context); |
115 v8::HandleScope handle_scope; | 115 v8::HandleScope handle_scope(context->GetIsolate()); |
116 return handle_scope.Close(ToV8ValueImpl(value)); | 116 return handle_scope.Close(ToV8ValueImpl(value)); |
117 } | 117 } |
118 | 118 |
119 Value* V8ValueConverterImpl::FromV8Value( | 119 Value* V8ValueConverterImpl::FromV8Value( |
120 v8::Handle<v8::Value> val, | 120 v8::Handle<v8::Value> val, |
121 v8::Handle<v8::Context> context) const { | 121 v8::Handle<v8::Context> context) const { |
122 v8::Context::Scope context_scope(context); | 122 v8::Context::Scope context_scope(context); |
123 v8::HandleScope handle_scope; | 123 v8::HandleScope handle_scope(context->GetIsolate()); |
124 FromV8ValueState state(avoid_identity_hash_for_testing_); | 124 FromV8ValueState state(avoid_identity_hash_for_testing_); |
125 return FromV8ValueImpl(val, &state); | 125 return FromV8ValueImpl(val, &state); |
126 } | 126 } |
127 | 127 |
128 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8ValueImpl( | 128 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8ValueImpl( |
129 const base::Value* value) const { | 129 const base::Value* value) const { |
130 CHECK(value); | 130 CHECK(value); |
131 switch (value->GetType()) { | 131 switch (value->GetType()) { |
132 case base::Value::TYPE_NULL: | 132 case base::Value::TYPE_NULL: |
133 return v8::Null(); | 133 return v8::Null(); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 continue; | 450 continue; |
451 | 451 |
452 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 452 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
453 child.release()); | 453 child.release()); |
454 } | 454 } |
455 | 455 |
456 return result.release(); | 456 return result.release(); |
457 } | 457 } |
458 | 458 |
459 } // namespace content | 459 } // namespace content |
OLD | NEW |