Commit bd1aa509 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert SpeechRecognitionSessionClient to new Mojo types

This CL converts SpeechRecognitionSessionClient{Ptr, PtrInfo} in
blink and content to the new Mojo type, and uses
pending_remote<SpeechRecognitionSessionClient>
in speech_recognizer.mojom.

Bug: 955171, 978694
Change-Id: Ie6316bc231d269bf95439d30c3952db7cf458e7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809042Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#697470}
parent 396756c4
......@@ -199,11 +199,11 @@ void SpeechRecognitionDispatcherHost::StartSessionOnIO(
// ---------------------- SpeechRecognizerSession -----------------------------
SpeechRecognitionSession::SpeechRecognitionSession(
blink::mojom::SpeechRecognitionSessionClientPtrInfo client_ptr_info)
mojo::PendingRemote<blink::mojom::SpeechRecognitionSessionClient> client)
: session_id_(SpeechRecognitionManager::kSessionIDInvalid),
client_(std::move(client_ptr_info)),
client_(std::move(client)),
stopped_(false) {
client_.set_connection_error_handler(
client_.set_disconnect_handler(
base::BindOnce(&SpeechRecognitionSession::ConnectionErrorHandler,
base::Unretained(this)));
}
......
......@@ -15,6 +15,8 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/speech_recognition_event_listener.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/speech/speech_recognizer.mojom.h"
namespace network {
......@@ -74,13 +76,14 @@ class CONTENT_EXPORT SpeechRecognitionDispatcherHost
// SpeechRecognitionSession implements the
// blink::mojom::SpeechRecognitionSession interface for a particular session. It
// also acts as a proxy for events sent from SpeechRecognitionManager, and
// forwards the events to the renderer using a SpeechRecognitionSessionClientPtr
// (that is passed from the render process).
// forwards the events to the renderer using a
// mojo::Remote<SpeechRecognitionSessionClient> (that is passed from the render
// process).
class SpeechRecognitionSession : public blink::mojom::SpeechRecognitionSession,
public SpeechRecognitionEventListener {
public:
explicit SpeechRecognitionSession(
blink::mojom::SpeechRecognitionSessionClientPtrInfo client_ptr_info);
mojo::PendingRemote<blink::mojom::SpeechRecognitionSessionClient> client);
~SpeechRecognitionSession() override;
base::WeakPtr<SpeechRecognitionSession> AsWeakPtr();
......@@ -113,7 +116,7 @@ class SpeechRecognitionSession : public blink::mojom::SpeechRecognitionSession,
void ConnectionErrorHandler();
int session_id_;
blink::mojom::SpeechRecognitionSessionClientPtr client_;
mojo::Remote<blink::mojom::SpeechRecognitionSessionClient> client_;
bool stopped_;
base::WeakPtrFactory<SpeechRecognitionSession> weak_factory_{this};
......
......@@ -18,7 +18,7 @@ struct StartSpeechRecognitionRequestParams {
// Used by the browser to communicate with a SpeechRecognitionSessionClient
// implementation created for the new session.
SpeechRecognitionSessionClient client;
pending_remote<SpeechRecognitionSessionClient> client;
// Language to use for speech recognition.
string language;
......
......@@ -27,6 +27,7 @@
#include <algorithm>
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/speech/speech_recognition_controller.h"
......@@ -56,8 +57,9 @@ void SpeechRecognition::start(ExceptionState& exception_state) {
// See https://bit.ly/2S0zRAS for task types.
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
GetExecutionContext()->GetTaskRunner(blink::TaskType::kMiscPlatformAPI);
mojom::blink::SpeechRecognitionSessionClientPtrInfo session_client;
binding_.Bind(mojo::MakeRequest(&session_client),
mojo::PendingRemote<mojom::blink::SpeechRecognitionSessionClient>
session_client;
binding_.Bind(session_client.InitWithNewPipeAndPassReceiver(),
GetExecutionContext()->GetInterfaceInvalidator(), task_runner);
binding_.set_connection_error_handler(WTF::Bind(
&SpeechRecognition::OnConnectionError, WrapWeakPersistent(this)));
......
......@@ -51,7 +51,8 @@ SpeechRecognitionController* SpeechRecognitionController::Create(
void SpeechRecognitionController::Start(
mojom::blink::SpeechRecognitionSessionRequest session_request,
mojom::blink::SpeechRecognitionSessionClientPtrInfo session_client,
mojo::PendingRemote<mojom::blink::SpeechRecognitionSessionClient>
session_client,
const SpeechGrammarList& grammars,
const String& lang,
bool continuous,
......
......@@ -28,6 +28,7 @@
#include <memory>
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/speech/speech_recognizer.mojom-blink.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
......@@ -49,7 +50,8 @@ class SpeechRecognitionController final
virtual ~SpeechRecognitionController();
void Start(mojom::blink::SpeechRecognitionSessionRequest session_request,
mojom::blink::SpeechRecognitionSessionClientPtrInfo session_client,
mojo::PendingRemote<mojom::blink::SpeechRecognitionSessionClient>
session_client,
const SpeechGrammarList& grammars,
const String& lang,
bool continuous,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment