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

Side by Side Diff: components/safe_json/safe_json_parser.h

Issue 2076163002: Migrate SequencedTaskRunnerHandle calls to TaskRunnerHandle calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mix_c_Ab_1_scheduler_support_parallelTRH
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_ 5 #ifndef COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_
6 #define COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_ 6 #define COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 12
13 namespace base { 13 namespace base {
14 class Value; 14 class Value;
15 } 15 }
16 16
17 namespace safe_json { 17 namespace safe_json {
18 18
19 // SafeJsonParser parses a given JSON safely via a platform-dependent mechanism 19 // SafeJsonParser parses a given JSON safely via a platform-dependent mechanism
20 // (like parsing it in a utility process or in a memory-safe environment). 20 // (like parsing it in a utility process or in a memory-safe environment).
21 // Internally, an instance of this class is created when Parse() is called and 21 // Internally, an instance of this class is created when Parse() is called and
22 // is kept alive until one of the two callbacks is called, after which it 22 // is kept alive until one of the two callbacks is executed on the original
23 // deletes itself. 23 // caller's TaskRunner, after which it deletes itself.
24 class SafeJsonParser { 24 class SafeJsonParser {
25 public: 25 public:
26 using SuccessCallback = base::Callback<void(std::unique_ptr<base::Value>)>; 26 using SuccessCallback = base::Callback<void(std::unique_ptr<base::Value>)>;
27 using ErrorCallback = base::Callback<void(const std::string&)>; 27 using ErrorCallback = base::Callback<void(const std::string&)>;
28 28
29 using Factory = SafeJsonParser* (*)(const std::string& unsafe_json, 29 using Factory = SafeJsonParser* (*)(const std::string& unsafe_json,
30 const SuccessCallback& success_callback, 30 const SuccessCallback& success_callback,
31 const ErrorCallback& error_callback); 31 const ErrorCallback& error_callback);
32 32
33 // Starts parsing the passed in |unsafe_json| and calls either 33 // Starts parsing the passed in |unsafe_json| and calls either
34 // |success_callback| or |error_callback| when finished. 34 // |success_callback| or |error_callback| when finished.
35 static void Parse(const std::string& unsafe_json, 35 static void Parse(const std::string& unsafe_json,
36 const SuccessCallback& success_callback, 36 const SuccessCallback& success_callback,
37 const ErrorCallback& error_callback); 37 const ErrorCallback& error_callback);
38 38
39 static void SetFactoryForTesting(Factory factory); 39 static void SetFactoryForTesting(Factory factory);
40 40
41 protected: 41 protected:
42 virtual ~SafeJsonParser() {} 42 virtual ~SafeJsonParser() {}
43 43
44 private: 44 private:
45 virtual void Start() = 0; 45 virtual void Start() = 0;
46 }; 46 };
47 47
48 } // namespace safe_json 48 } // namespace safe_json
49 49
50 #endif // COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_ 50 #endif // COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_
OLDNEW
« no previous file with comments | « components/safe_json/json_sanitizer_android.cc ('k') | components/safe_json/safe_json_parser_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698