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

Unified Diff: components/safe_json/safe_json_parser_impl.h

Issue 1861573002: Convert the utility process JSON parser into a Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove from IPC message start. Created 4 years, 8 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_impl.h b/components/safe_json/safe_json_parser_impl.h
index 5f29bc03c52cd98a35a38485dcdb121d67f155d4..eefa187d35b9d0f16800cfb2d6afe914d4711488 100644
--- a/components/safe_json/safe_json_parser_impl.h
+++ b/components/safe_json/safe_json_parser_impl.h
@@ -10,6 +10,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "components/safe_json/public/interfaces/safe_json.mojom.h"
#include "components/safe_json/safe_json_parser.h"
#include "content/public/browser/utility_process_host_client.h"
@@ -19,6 +22,10 @@ class SequencedTaskRunner;
class Value;
}
+namespace content {
+class UtilityProcessHost;
+}
+
namespace IPC {
class Message;
}
@@ -37,9 +44,6 @@ class SafeJsonParserImpl : public content::UtilityProcessHostClient,
void StartWorkOnIOThread();
- void OnJSONParseSucceeded(const base::ListValue& wrapper);
- void OnJSONParseFailed(const std::string& error_message);
-
void ReportResults();
void ReportResultsOnOriginThread();
@@ -49,6 +53,9 @@ class SafeJsonParserImpl : public content::UtilityProcessHostClient,
// SafeJsonParser implementation.
void Start() override;
+ // mojom::SafeJsonParser::Parse callback.
+ void OnParseDone(const base::ListValue& wrapper, mojo::String error);
+
const std::string unsafe_json_;
SuccessCallback success_callback_;
ErrorCallback error_callback_;
@@ -57,6 +64,14 @@ class SafeJsonParserImpl : public content::UtilityProcessHostClient,
std::unique_ptr<base::Value> parsed_json_;
std::string error_;
+ base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
+
+ mojom::SafeJsonParserPtr service_;
+
+ // To ensure the UtilityProcessHost and Mojo service are only accessed on the
+ // IO thread.
+ base::ThreadChecker io_thread_checker_;
+
DISALLOW_COPY_AND_ASSIGN(SafeJsonParserImpl);
};
« no previous file with comments | « components/safe_json/public/interfaces/safe_json.typemap ('k') | components/safe_json/safe_json_parser_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698