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

Side by Side Diff: components/safe_json/utility/safe_json_parser_mojo_impl.cc

Issue 2577563002: Add struct traits for base::Value. (Closed)
Patch Set: rebase Created 4 years 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 | « components/safe_json/safe_json_parser_impl.cc ('k') | components/typemaps.gni » ('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 "components/safe_json/utility/safe_json_parser_mojo_impl.h" 5 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 12 matching lines...) Expand all
23 mojo::MakeStrongBinding(base::MakeUnique<SafeJsonParserMojoImpl>(), 23 mojo::MakeStrongBinding(base::MakeUnique<SafeJsonParserMojoImpl>(),
24 std::move(request)); 24 std::move(request));
25 } 25 }
26 26
27 void SafeJsonParserMojoImpl::Parse(const std::string& json, 27 void SafeJsonParserMojoImpl::Parse(const std::string& json,
28 const ParseCallback& callback) { 28 const ParseCallback& callback) {
29 int error_code; 29 int error_code;
30 std::string error; 30 std::string error;
31 std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError( 31 std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
32 json, base::JSON_PARSE_RFC, &error_code, &error); 32 json, base::JSON_PARSE_RFC, &error_code, &error);
33 base::ListValue wrapper;
34 if (value) { 33 if (value) {
35 wrapper.Append(std::move(value)); 34 callback.Run(std::move(value), base::nullopt);
36 callback.Run(wrapper, base::nullopt);
37 } else { 35 } else {
38 callback.Run(wrapper, base::make_optional(std::move(error))); 36 callback.Run(nullptr, base::make_optional(std::move(error)));
39 } 37 }
40 } 38 }
41 39
42 } // namespace safe_json 40 } // namespace safe_json
OLDNEW
« no previous file with comments | « components/safe_json/safe_json_parser_impl.cc ('k') | components/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698