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

Unified Diff: components/safe_json/safe_json_parser_impl.h

Issue 1214903010: Make JSONParser a pure interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: review Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/safe_json/safe_json_parser_impl.h
diff --git a/components/safe_json/safe_json_parser.h b/components/safe_json/safe_json_parser_impl.h
similarity index 58%
copy from components/safe_json/safe_json_parser.h
copy to components/safe_json/safe_json_parser_impl.h
index 8fb703b3e9a619f630906418841a8c87bd6d395f..99af9320e2402be0ce39745c8884f403fd97e680 100644
--- a/components/safe_json/safe_json_parser.h
+++ b/components/safe_json/safe_json_parser_impl.h
@@ -7,14 +7,14 @@
#include <string>
-#include "base/basictypes.h"
-#include "base/callback.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "components/safe_json/safe_json_parser.h"
#include "content/public/browser/utility_process_host_client.h"
namespace base {
class ListValue;
-class SingleThreadTaskRunner;
+class SequencedTaskRunner;
class Value;
}
@@ -24,22 +24,15 @@ class Message;
namespace safe_json {
-// SafeJsonParser parses a given JSON safely via a utility process. The object
-// is ref-counted and kept alive after Start() is called until one of the two
-// callbacks is called.
-class SafeJsonParser : public content::UtilityProcessHostClient {
+class SafeJsonParserImpl : public content::UtilityProcessHostClient,
+ public SafeJsonParser {
public:
- typedef base::Callback<void(scoped_ptr<base::Value>)> SuccessCallback;
- typedef base::Callback<void(const std::string&)> ErrorCallback;
-
- SafeJsonParser(const std::string& unsafe_json,
- const SuccessCallback& success_callback,
- const ErrorCallback& error_callback);
-
- void Start();
+ SafeJsonParserImpl(const std::string& unsafe_json,
+ const SuccessCallback& success_callback,
+ const ErrorCallback& error_callback);
private:
- ~SafeJsonParser() override;
+ ~SafeJsonParserImpl() override;
void StartWorkOnIOThread();
@@ -52,15 +45,18 @@ class SafeJsonParser : public content::UtilityProcessHostClient {
// Implementing pieces of the UtilityProcessHostClient interface.
bool OnMessageReceived(const IPC::Message& message) override;
+ // SafeJsonParser implementation.
+ void Start() override;
+
const std::string unsafe_json_;
SuccessCallback success_callback_;
ErrorCallback error_callback_;
- scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> caller_task_runner_;
scoped_ptr<base::Value> parsed_json_;
std::string error_;
- DISALLOW_COPY_AND_ASSIGN(SafeJsonParser);
+ DISALLOW_COPY_AND_ASSIGN(SafeJsonParserImpl);
};
} // namespace safe_json

Powered by Google App Engine
This is Rietveld 408576698