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

Side by Side Diff: components/safe_json/safe_json_parser_android.cc

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 | « components/safe_json/safe_json_parser.h ('k') | components/safe_json/safe_json_parser_impl.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/safe_json_parser_android.h" 5 #include "components/safe_json/safe_json_parser_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 17 matching lines...) Expand all
28 unsafe_json_, 28 unsafe_json_,
29 base::Bind(&SafeJsonParserAndroid::OnSanitizationSuccess, 29 base::Bind(&SafeJsonParserAndroid::OnSanitizationSuccess,
30 base::Unretained(this)), 30 base::Unretained(this)),
31 base::Bind(&SafeJsonParserAndroid::OnSanitizationError, 31 base::Bind(&SafeJsonParserAndroid::OnSanitizationError,
32 base::Unretained(this))); 32 base::Unretained(this)));
33 } 33 }
34 34
35 void SafeJsonParserAndroid::OnSanitizationSuccess( 35 void SafeJsonParserAndroid::OnSanitizationSuccess(
36 const std::string& sanitized_json) { 36 const std::string& sanitized_json) {
37 // Self-destruct at the end of this method. 37 // Self-destruct at the end of this method.
38 scoped_ptr<SafeJsonParserAndroid> deleter(this); 38 std::unique_ptr<SafeJsonParserAndroid> deleter(this);
39 39
40 int error_code; 40 int error_code;
41 std::string error; 41 std::string error;
42 scoped_ptr<base::Value> value = base::JSONReader::ReadAndReturnError( 42 std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
43 sanitized_json, base::JSON_PARSE_RFC, &error_code, &error); 43 sanitized_json, base::JSON_PARSE_RFC, &error_code, &error);
44 44
45 if (!value) { 45 if (!value) {
46 error_callback_.Run(error); 46 error_callback_.Run(error);
47 return; 47 return;
48 } 48 }
49 49
50 success_callback_.Run(std::move(value)); 50 success_callback_.Run(std::move(value));
51 } 51 }
52 52
53 void SafeJsonParserAndroid::OnSanitizationError(const std::string& error) { 53 void SafeJsonParserAndroid::OnSanitizationError(const std::string& error) {
54 error_callback_.Run(error); 54 error_callback_.Run(error);
55 delete this; 55 delete this;
56 } 56 }
57 57
58 } // namespace safe_json 58 } // namespace safe_json
OLDNEW
« no previous file with comments | « components/safe_json/safe_json_parser.h ('k') | components/safe_json/safe_json_parser_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698