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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 return base::Value::CreateNullValue(); | 314 return base::Value::CreateNullValue(); |
315 | 315 |
316 scoped_ptr<v8::Context::Scope> scope; | 316 scoped_ptr<v8::Context::Scope> scope; |
317 // If val was created in a different context than our current one, change to | 317 // If val was created in a different context than our current one, change to |
318 // that context, but change back after val is converted. | 318 // that context, but change back after val is converted. |
319 if (!val->CreationContext().IsEmpty() && | 319 if (!val->CreationContext().IsEmpty() && |
320 val->CreationContext() != isolate->GetCurrentContext()) | 320 val->CreationContext() != isolate->GetCurrentContext()) |
321 scope.reset(new v8::Context::Scope(val->CreationContext())); | 321 scope.reset(new v8::Context::Scope(val->CreationContext())); |
322 | 322 |
323 if (strategy_) { | 323 if (strategy_) { |
324 Value* out = NULL; | 324 base::Value* out = NULL; |
325 if (strategy_->FromV8Array(val, &out, isolate)) | 325 if (strategy_->FromV8Array(val, &out, isolate)) |
326 return out; | 326 return out; |
327 } | 327 } |
328 | 328 |
329 base::ListValue* result = new base::ListValue(); | 329 base::ListValue* result = new base::ListValue(); |
330 | 330 |
331 // Only fields with integer keys are carried over to the ListValue. | 331 // Only fields with integer keys are carried over to the ListValue. |
332 for (uint32 i = 0; i < val->Length(); ++i) { | 332 for (uint32 i = 0; i < val->Length(); ++i) { |
333 v8::TryCatch try_catch; | 333 v8::TryCatch try_catch; |
334 v8::Handle<v8::Value> child_v8 = val->Get(i); | 334 v8::Handle<v8::Value> child_v8 = val->Get(i); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 return base::Value::CreateNullValue(); | 384 return base::Value::CreateNullValue(); |
385 | 385 |
386 scoped_ptr<v8::Context::Scope> scope; | 386 scoped_ptr<v8::Context::Scope> scope; |
387 // If val was created in a different context than our current one, change to | 387 // If val was created in a different context than our current one, change to |
388 // that context, but change back after val is converted. | 388 // that context, but change back after val is converted. |
389 if (!val->CreationContext().IsEmpty() && | 389 if (!val->CreationContext().IsEmpty() && |
390 val->CreationContext() != isolate->GetCurrentContext()) | 390 val->CreationContext() != isolate->GetCurrentContext()) |
391 scope.reset(new v8::Context::Scope(val->CreationContext())); | 391 scope.reset(new v8::Context::Scope(val->CreationContext())); |
392 | 392 |
393 if (strategy_) { | 393 if (strategy_) { |
394 Value* out = NULL; | 394 base::Value* out = NULL; |
395 if (strategy_->FromV8Object(val, &out, isolate)) | 395 if (strategy_->FromV8Object(val, &out, isolate)) |
396 return out; | 396 return out; |
397 } | 397 } |
398 | 398 |
399 // Don't consider DOM objects. This check matches isHostObject() in Blink's | 399 // Don't consider DOM objects. This check matches isHostObject() in Blink's |
400 // bindings/v8/V8Binding.h used in structured cloning. It reads: | 400 // bindings/v8/V8Binding.h used in structured cloning. It reads: |
401 // | 401 // |
402 // If the object has any internal fields, then we won't be able to serialize | 402 // If the object has any internal fields, then we won't be able to serialize |
403 // or deserialize them; conveniently, this is also a quick way to detect DOM | 403 // or deserialize them; conveniently, this is also a quick way to detect DOM |
404 // wrapper objects, because the mechanism for these relies on data stored in | 404 // wrapper objects, because the mechanism for these relies on data stored in |
(...skipping 59 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 |