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

Unified Diff: components/safe_json/safe_json_parser_impl.h

Issue 2049303002: Add the UtilityProcessMojoClient class and convert SafeJsonParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed android sandbox browser tests Created 4 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
« no previous file with comments | « no previous file | components/safe_json/safe_json_parser_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 eefa187d35b9d0f16800cfb2d6afe914d4711488..abc5194500bd1558b6e79c39b8b51c516f0b268f 100644
--- a/components/safe_json/safe_json_parser_impl.h
+++ b/components/safe_json/safe_json_parser_impl.h
@@ -8,13 +8,13 @@
#include <memory>
#include <string>
+#include "base/callback.h"
#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"
+#include "content/public/browser/utility_process_mojo_client.h"
namespace base {
class ListValue;
@@ -22,18 +22,9 @@ class SequencedTaskRunner;
class Value;
}
-namespace content {
-class UtilityProcessHost;
-}
-
-namespace IPC {
-class Message;
-}
-
namespace safe_json {
-class SafeJsonParserImpl : public content::UtilityProcessHostClient,
- public SafeJsonParser {
+class SafeJsonParserImpl : public SafeJsonParser {
public:
SafeJsonParserImpl(const std::string& unsafe_json,
const SuccessCallback& success_callback,
@@ -42,34 +33,32 @@ class SafeJsonParserImpl : public content::UtilityProcessHostClient,
private:
~SafeJsonParserImpl() override;
- void StartWorkOnIOThread();
-
- void ReportResults();
- void ReportResultsOnOriginThread();
-
- // Implementing pieces of the UtilityProcessHostClient interface.
- bool OnMessageReceived(const IPC::Message& message) override;
-
// SafeJsonParser implementation.
void Start() override;
+ void StartOnIOThread();
+ void OnConnectionError();
+
// mojom::SafeJsonParser::Parse callback.
- void OnParseDone(const base::ListValue& wrapper, mojo::String error);
+ void OnParseDone(const base::ListValue& wrapper, const mojo::String& error);
+
+ // Reports the result on the calling task runner via the |success_callback_|
+ // or the |error_callback_|.
+ void ReportResults(std::unique_ptr<base::Value> parsed_json,
+ const std::string& error);
const std::string unsafe_json_;
SuccessCallback success_callback_;
ErrorCallback error_callback_;
scoped_refptr<base::SequencedTaskRunner> caller_task_runner_;
- std::unique_ptr<base::Value> parsed_json_;
- std::string error_;
-
- base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
-
- mojom::SafeJsonParserPtr service_;
+ std::unique_ptr<content::UtilityProcessMojoClient<mojom::SafeJsonParser>>
+ mojo_json_parser_;
- // To ensure the UtilityProcessHost and Mojo service are only accessed on the
- // IO thread.
+ // Used instead of DCHECK_CURRENTLY_ON(BrowserThread::IO) because it's
+ // posssible that it fails when the IO thread message loop is shutting down.
+ // This happens after the IO thread has unregistered from the BrowserThread
+ // list.
base::ThreadChecker io_thread_checker_;
DISALLOW_COPY_AND_ASSIGN(SafeJsonParserImpl);
« no previous file with comments | « no previous file | components/safe_json/safe_json_parser_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698