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

Side by Side Diff: content/child/v8_value_converter_impl.cc

Issue 2065793002: Return a unique_ptr from BinaryValue::CreateWithCopiedBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android and CrOS Created 4 years, 6 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 #include "content/child/v8_value_converter_impl.h" 5 #include "content/child/v8_value_converter_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 length = array_buffer->byteLength(); 508 length = array_buffer->byteLength();
509 } else { 509 } else {
510 view.reset(blink::WebArrayBufferView::createFromV8Value(val)); 510 view.reset(blink::WebArrayBufferView::createFromV8Value(val));
511 if (view) { 511 if (view) {
512 data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset(); 512 data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset();
513 length = view->byteLength(); 513 length = view->byteLength();
514 } 514 }
515 } 515 }
516 516
517 if (data) 517 if (data)
518 return base::WrapUnique( 518 return base::BinaryValue::CreateWithCopiedBuffer(data, length);
519 base::BinaryValue::CreateWithCopiedBuffer(data, length));
520 else 519 else
521 return nullptr; 520 return nullptr;
522 } 521 }
523 522
524 std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8Object( 523 std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8Object(
525 v8::Local<v8::Object> val, 524 v8::Local<v8::Object> val,
526 FromV8ValueState* state, 525 FromV8ValueState* state,
527 v8::Isolate* isolate) const { 526 v8::Isolate* isolate) const {
528 ScopedUniquenessGuard uniqueness_guard(state, val); 527 ScopedUniquenessGuard uniqueness_guard(state, val);
529 if (!uniqueness_guard.is_valid()) 528 if (!uniqueness_guard.is_valid())
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 continue; 619 continue;
621 620
622 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), 621 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
623 std::move(child)); 622 std::move(child));
624 } 623 }
625 624
626 return std::move(result); 625 return std::move(result);
627 } 626 }
628 627
629 } // namespace content 628 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698