| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 strategy_ = strategy; | 112 strategy_ = strategy; |
| 113 } | 113 } |
| 114 | 114 |
| 115 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value( | 115 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value( |
| 116 const base::Value* value, v8::Handle<v8::Context> context) const { | 116 const base::Value* value, v8::Handle<v8::Context> context) const { |
| 117 v8::Context::Scope context_scope(context); | 117 v8::Context::Scope context_scope(context); |
| 118 v8::EscapableHandleScope handle_scope(context->GetIsolate()); | 118 v8::EscapableHandleScope handle_scope(context->GetIsolate()); |
| 119 return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value)); | 119 return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 Value* V8ValueConverterImpl::FromV8Value( | 122 base::Value* V8ValueConverterImpl::FromV8Value( |
| 123 v8::Handle<v8::Value> val, | 123 v8::Handle<v8::Value> val, |
| 124 v8::Handle<v8::Context> context) const { | 124 v8::Handle<v8::Context> context) const { |
| 125 v8::Context::Scope context_scope(context); | 125 v8::Context::Scope context_scope(context); |
| 126 v8::HandleScope handle_scope(context->GetIsolate()); | 126 v8::HandleScope handle_scope(context->GetIsolate()); |
| 127 FromV8ValueState state(avoid_identity_hash_for_testing_); | 127 FromV8ValueState state(avoid_identity_hash_for_testing_); |
| 128 return FromV8ValueImpl(val, &state, context->GetIsolate()); | 128 return FromV8ValueImpl(val, &state, context->GetIsolate()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl( | 131 v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl( |
| 132 v8::Isolate* isolate, | 132 v8::Isolate* isolate, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer( | 226 v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer( |
| 227 const base::BinaryValue* value) const { | 227 const base::BinaryValue* value) const { |
| 228 blink::WebArrayBuffer buffer = | 228 blink::WebArrayBuffer buffer = |
| 229 blink::WebArrayBuffer::create(value->GetSize(), 1); | 229 blink::WebArrayBuffer::create(value->GetSize(), 1); |
| 230 memcpy(buffer.data(), value->GetBuffer(), value->GetSize()); | 230 memcpy(buffer.data(), value->GetBuffer(), value->GetSize()); |
| 231 return buffer.toV8Value(); | 231 return buffer.toV8Value(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 Value* V8ValueConverterImpl::FromV8ValueImpl( | 234 base::Value* V8ValueConverterImpl::FromV8ValueImpl( |
| 235 v8::Handle<v8::Value> val, | 235 v8::Handle<v8::Value> val, |
| 236 FromV8ValueState* state, | 236 FromV8ValueState* state, |
| 237 v8::Isolate* isolate) const { | 237 v8::Isolate* isolate) const { |
| 238 CHECK(!val.IsEmpty()); | 238 CHECK(!val.IsEmpty()); |
| 239 | 239 |
| 240 FromV8ValueState::Level state_level(state); | 240 FromV8ValueState::Level state_level(state); |
| 241 if (state->HasReachedMaxRecursionDepth()) | 241 if (state->HasReachedMaxRecursionDepth()) |
| 242 return NULL; | 242 return NULL; |
| 243 | 243 |
| 244 if (val->IsNull()) | 244 if (val->IsNull()) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 continue; | 464 continue; |
| 465 | 465 |
| 466 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 466 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
| 467 child.release()); | 467 child.release()); |
| 468 } | 468 } |
| 469 | 469 |
| 470 return result.release(); | 470 return result.release(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace content | 473 } // namespace content |
| OLD | NEW |