OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_SAFE_JSON_TESTING_JSON_PARSER_H_ | |
6 #define COMPONENTS_SAFE_JSON_TESTING_JSON_PARSER_H_ | |
7 | |
8 #include "components/safe_json/safe_json_parser.h" | |
9 | |
10 namespace safe_json { | |
11 | |
12 // An implementation of SafeJsonParser that parses JSON in process. This can be | |
13 // used in unit tests to avoid having to set up the multiprocess infrastructure | |
14 // necessary for the out-of-process SafeJsonParser. | |
15 class TestingJsonParser : public SafeJsonParser { | |
16 public: | |
17 // A helper class that will temporarily override the SafeJsonParser factory to | |
18 // create instances of this class. | |
19 class ScopedFactoryOverride { | |
20 public: | |
21 ScopedFactoryOverride(); | |
22 ~ScopedFactoryOverride(); | |
23 | |
24 private: | |
25 DISALLOW_COPY_AND_ASSIGN(ScopedFactoryOverride); | |
26 }; | |
27 | |
28 TestingJsonParser(const std::string& unsafe_json, | |
Robert Sesek
2015/07/02 17:28:19
Comment that this must be allocated with new and t
Bernhard Bauer
2015/07/02 22:38:24
Done.
| |
29 const SuccessCallback& success_callback, | |
30 const ErrorCallback& error_callback); | |
31 ~TestingJsonParser() override; | |
32 | |
33 private: | |
34 void Start() override; | |
35 | |
36 const std::string unsafe_json_; | |
37 SuccessCallback success_callback_; | |
38 ErrorCallback error_callback_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(TestingJsonParser); | |
41 }; | |
42 | |
43 } // namespace | |
44 | |
45 #endif // COMPONENTS_SAFE_JSON_TESTING_JSON_PARSER_H_ | |
OLD | NEW |