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

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

Issue 2851173004: Eliminate bind callback that doesn't take a BindSourceInfo parameter. (Closed)
Patch Set: . Created 3 years, 7 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 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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 13 #include "mojo/public/cpp/bindings/strong_binding.h"
14 14
15 namespace safe_json { 15 namespace safe_json {
16 16
17 SafeJsonParserMojoImpl::SafeJsonParserMojoImpl() = default; 17 SafeJsonParserMojoImpl::SafeJsonParserMojoImpl() = default;
18 18
19 SafeJsonParserMojoImpl::~SafeJsonParserMojoImpl() = default; 19 SafeJsonParserMojoImpl::~SafeJsonParserMojoImpl() = default;
20 20
21 // static 21 // static
22 void SafeJsonParserMojoImpl::Create( 22 void SafeJsonParserMojoImpl::Create(
23 mojo::InterfaceRequest<mojom::SafeJsonParser> request) { 23 const service_manager::BindSourceInfo& source_info,
24 mojom::SafeJsonParserRequest request) {
24 mojo::MakeStrongBinding(base::MakeUnique<SafeJsonParserMojoImpl>(), 25 mojo::MakeStrongBinding(base::MakeUnique<SafeJsonParserMojoImpl>(),
25 std::move(request)); 26 std::move(request));
26 } 27 }
27 28
28 void SafeJsonParserMojoImpl::Parse(const std::string& json, 29 void SafeJsonParserMojoImpl::Parse(const std::string& json,
29 const ParseCallback& callback) { 30 const ParseCallback& callback) {
30 int error_code; 31 int error_code;
31 std::string error; 32 std::string error;
32 std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError( 33 std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
33 json, base::JSON_PARSE_RFC, &error_code, &error); 34 json, base::JSON_PARSE_RFC, &error_code, &error);
34 if (value) { 35 if (value) {
35 callback.Run(std::move(value), base::nullopt); 36 callback.Run(std::move(value), base::nullopt);
36 } else { 37 } else {
37 callback.Run(nullptr, base::make_optional(std::move(error))); 38 callback.Run(nullptr, base::make_optional(std::move(error)));
38 } 39 }
39 } 40 }
40 41
41 } // namespace safe_json 42 } // namespace safe_json
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698