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

Side by Side Diff: extensions/renderer/argument_spec.cc

Issue 2931393003: [Content] Update V8ValueConverter::create to return a std::unique_ptr (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « extensions/renderer/api_signature.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "extensions/renderer/argument_spec.h" 5 #include "extensions/renderer/argument_spec.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 *out_value = std::move(result); 611 *out_value = std::move(result);
612 return true; 612 return true;
613 } 613 }
614 614
615 bool ArgumentSpec::ParseArgumentToAny(v8::Local<v8::Context> context, 615 bool ArgumentSpec::ParseArgumentToAny(v8::Local<v8::Context> context,
616 v8::Local<v8::Value> value, 616 v8::Local<v8::Value> value,
617 std::unique_ptr<base::Value>* out_value, 617 std::unique_ptr<base::Value>* out_value,
618 std::string* error) const { 618 std::string* error) const {
619 DCHECK(type_ == ArgumentType::ANY || type_ == ArgumentType::BINARY); 619 DCHECK(type_ == ArgumentType::ANY || type_ == ArgumentType::BINARY);
620 if (out_value) { 620 if (out_value) {
621 std::unique_ptr<content::V8ValueConverter> converter( 621 std::unique_ptr<content::V8ValueConverter> converter =
622 content::V8ValueConverter::create()); 622 content::V8ValueConverter::Create();
623 converter->SetStripNullFromObjects(!preserve_null_); 623 converter->SetStripNullFromObjects(!preserve_null_);
624 std::unique_ptr<base::Value> converted( 624 std::unique_ptr<base::Value> converted =
625 converter->FromV8Value(value, context)); 625 converter->FromV8Value(value, context);
626 if (!converted) { 626 if (!converted) {
627 *error = api_errors::UnserializableValue(); 627 *error = api_errors::UnserializableValue();
628 return false; 628 return false;
629 } 629 }
630 if (type_ == ArgumentType::BINARY) 630 if (type_ == ArgumentType::BINARY)
631 DCHECK_EQ(base::Value::Type::BINARY, converted->GetType()); 631 DCHECK_EQ(base::Value::Type::BINARY, converted->GetType());
632 *out_value = std::move(converted); 632 *out_value = std::move(converted);
633 } 633 }
634 return true; 634 return true;
635 } 635 }
636 636
637 std::string ArgumentSpec::GetInvalidTypeError( 637 std::string ArgumentSpec::GetInvalidTypeError(
638 v8::Local<v8::Value> value) const { 638 v8::Local<v8::Value> value) const {
639 return api_errors::InvalidType(GetTypeName().c_str(), 639 return api_errors::InvalidType(GetTypeName().c_str(),
640 GetV8ValueTypeString(value)); 640 GetV8ValueTypeString(value));
641 } 641 }
642 642
643 } // namespace extensions 643 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api_signature.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698