| OLD | NEW |
| 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_PARSER_SAFE_JSON_PARSER_H_ | 5 #ifndef COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_ |
| 6 #define COMPONENTS_SAFE_JSON_PARSER_SAFE_JSON_PARSER_H_ | 6 #define COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/public/browser/utility_process_host_client.h" | 13 #include "content/public/browser/utility_process_host_client.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class ListValue; | 16 class ListValue; |
| 17 class Value; | 17 class Value; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace IPC { | 20 namespace IPC { |
| 21 class Message; | 21 class Message; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace safe_json_parser { | 24 namespace safe_json { |
| 25 | 25 |
| 26 // SafeJsonParser parses a given JSON safely via a utility process. The object | 26 // SafeJsonParser parses a given JSON safely via a utility process. The object |
| 27 // is ref-counted and kept alive after Start() is called until one of the two | 27 // is ref-counted and kept alive after Start() is called until one of the two |
| 28 // callbacks is called. | 28 // callbacks is called. |
| 29 class SafeJsonParser : public content::UtilityProcessHostClient { | 29 class SafeJsonParser : public content::UtilityProcessHostClient { |
| 30 public: | 30 public: |
| 31 typedef base::Callback<void(scoped_ptr<base::Value>)> SuccessCallback; | 31 typedef base::Callback<void(scoped_ptr<base::Value>)> SuccessCallback; |
| 32 typedef base::Callback<void(const std::string&)> ErrorCallback; | 32 typedef base::Callback<void(const std::string&)> ErrorCallback; |
| 33 | 33 |
| 34 SafeJsonParser(const std::string& unsafe_json, | 34 SafeJsonParser(const std::string& unsafe_json, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 const std::string unsafe_json_; | 54 const std::string unsafe_json_; |
| 55 SuccessCallback success_callback_; | 55 SuccessCallback success_callback_; |
| 56 ErrorCallback error_callback_; | 56 ErrorCallback error_callback_; |
| 57 | 57 |
| 58 scoped_ptr<base::Value> parsed_json_; | 58 scoped_ptr<base::Value> parsed_json_; |
| 59 std::string error_; | 59 std::string error_; |
| 60 | 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(SafeJsonParser); | 61 DISALLOW_COPY_AND_ASSIGN(SafeJsonParser); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace safe_json_parser | 64 } // namespace safe_json |
| 65 | 65 |
| 66 #endif // COMPONENTS_SAFE_JSON_PARSER_SAFE_JSON_PARSER_H_ | 66 #endif // COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_ |
| OLD | NEW |