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

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 50%
copy from components/safe_json/safe_json_parser.h
copy to components/safe_json/safe_json_parser_impl.h
index 8fb703b3e9a619f630906418841a8c87bd6d395f..277ee08f95674c0e1178ac0244e0177061638276 100644
--- a/components/safe_json/safe_json_parser.h
+++ b/components/safe_json/safe_json_parser_impl.h
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_
-#define COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_
+#ifndef COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_IMPL_H_
+#define COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_IMPL_H_
#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,17 +45,20 @@ 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
-#endif // COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_H_
+#endif // COMPONENTS_SAFE_JSON_SAFE_JSON_PARSER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698