| 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);
|
|
|