summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/exported/web_speech_recognizer_client.cc
blob: 8aa1aebe3cbfb4d63c7e2a1bda0ce0cded421164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/public/web/web_speech_recognizer_client.h"

#include "third_party/blink/public/web/web_speech_recognition_handle.h"
#include "third_party/blink/renderer/modules/speech/speech_recognition_client_proxy.h"

namespace blink {

WebSpeechRecognizerClient::WebSpeechRecognizerClient(
    SpeechRecognitionClientProxy* proxy)
    : private_(proxy) {}

WebSpeechRecognizerClient::~WebSpeechRecognizerClient() {
  Reset();
}

bool WebSpeechRecognizerClient::operator==(
    const WebSpeechRecognizerClient& other) const {
  return private_.Get() == other.private_.Get();
}

bool WebSpeechRecognizerClient::operator!=(
    const WebSpeechRecognizerClient& other) const {
  return !operator==(other);
}

void WebSpeechRecognizerClient::Reset() {
  private_.Reset();
}

void WebSpeechRecognizerClient::Assign(const WebSpeechRecognizerClient& other) {
  private_ = other.private_;
}

void WebSpeechRecognizerClient::DidStartAudio(
    const WebSpeechRecognitionHandle& handle) {
  DCHECK(!private_.IsNull());
  private_->DidStartAudio(handle);
}

void WebSpeechRecognizerClient::DidStartSound(
    const WebSpeechRecognitionHandle& handle) {
  DCHECK(!private_.IsNull());
  private_->DidStartSound(handle);
}

void WebSpeechRecognizerClient::DidEndSound(
    const WebSpeechRecognitionHandle& handle) {
  DCHECK(!private_.IsNull());
  private_->DidEndSound(handle);
}

void WebSpeechRecognizerClient::DidEndAudio(
    const WebSpeechRecognitionHandle& handle) {
  DCHECK(!private_.IsNull());
  private_->DidEndAudio(handle);
}

void WebSpeechRecognizerClient::DidReceiveResults(
    const WebSpeechRecognitionHandle& handle,
    const WebVector<WebSpeechRecognitionResult>& new_final_results,
    const WebVector<WebSpeechRecognitionResult>& current_interim_results) {
  DCHECK(!private_.IsNull());
  private_->DidReceiveResults(handle, new_final_results,
                              current_interim_results);
}

void WebSpeechRecognizerClient::DidReceiveNoMatch(
    const WebSpeechRecognitionHandle& handle,
    const WebSpeechRecognitionResult& result) {
  DCHECK(!private_.IsNull());
  private_->DidReceiveNoMatch(handle, result);
}

void WebSpeechRecognizerClient::DidReceiveError(
    const WebSpeechRecognitionHandle& handle,
    const WebString& message,
    ErrorCode error_code) {
  DCHECK(!private_.IsNull());
  private_->DidReceiveError(handle, message, error_code);
}

void WebSpeechRecognizerClient::DidStart(
    const WebSpeechRecognitionHandle& handle) {
  DCHECK(!private_.IsNull());
  private_->DidStart(handle);
}

void WebSpeechRecognizerClient::DidEnd(
    const WebSpeechRecognitionHandle& handle) {
  DCHECK(!private_.IsNull());
  private_->DidEnd(handle);
}

}  // namespace blink