OLD | NEW |
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/json_sanitizer.h" | 5 #include "components/safe_json/json_sanitizer.h" |
6 | 6 |
7 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
8 #error Build json_sanitizer_android.cc instead of this file on Android. | 8 #error Build json_sanitizer_android.cc instead of this file on Android. |
9 #endif | 9 #endif |
10 | 10 |
| 11 #include <memory> |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "components/safe_json/safe_json_parser.h" | 18 #include "components/safe_json/safe_json_parser.h" |
18 | 19 |
19 namespace safe_json { | 20 namespace safe_json { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 class OopJsonSanitizer : public JsonSanitizer { | 24 class OopJsonSanitizer : public JsonSanitizer { |
24 public: | 25 public: |
25 OopJsonSanitizer(const std::string& unsafe_json, | 26 OopJsonSanitizer(const std::string& unsafe_json, |
26 const StringCallback& success_callback, | 27 const StringCallback& success_callback, |
27 const StringCallback& error_callback); | 28 const StringCallback& error_callback); |
28 | 29 |
29 private: | 30 private: |
30 friend struct base::DefaultDeleter<OopJsonSanitizer>; | 31 friend std::default_delete<OopJsonSanitizer>; |
31 ~OopJsonSanitizer() {} | 32 ~OopJsonSanitizer() {} |
32 | 33 |
33 void OnParseSuccess(scoped_ptr<base::Value> value); | 34 void OnParseSuccess(scoped_ptr<base::Value> value); |
34 void OnParseError(const std::string& error); | 35 void OnParseError(const std::string& error); |
35 | 36 |
36 StringCallback success_callback_; | 37 StringCallback success_callback_; |
37 StringCallback error_callback_; | 38 StringCallback error_callback_; |
38 | 39 |
39 DISALLOW_COPY_AND_ASSIGN(OopJsonSanitizer); | 40 DISALLOW_COPY_AND_ASSIGN(OopJsonSanitizer); |
40 }; | 41 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 81 |
81 // static | 82 // static |
82 void JsonSanitizer::Sanitize(const std::string& unsafe_json, | 83 void JsonSanitizer::Sanitize(const std::string& unsafe_json, |
83 const StringCallback& success_callback, | 84 const StringCallback& success_callback, |
84 const StringCallback& error_callback) { | 85 const StringCallback& error_callback) { |
85 // OopJsonSanitizer destroys itself when it is finished. | 86 // OopJsonSanitizer destroys itself when it is finished. |
86 new OopJsonSanitizer(unsafe_json, success_callback, error_callback); | 87 new OopJsonSanitizer(unsafe_json, success_callback, error_callback); |
87 } | 88 } |
88 | 89 |
89 } // namespace safe_json | 90 } // namespace safe_json |
OLD | NEW |