blob: 1c401256348bfdc86040e366751c39d6ae110f12 [file] [log] [blame]
Avi Drissman8ba1bad2022-09-13 19:22:361// Copyright 2020 The Chromium Authors
evliu6a88379d2020-05-19 18:22:322// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_
6#define COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_
7
evliu6a88379d2020-05-19 18:22:328namespace speech {
9
10// An interface containing the callback functions required by consumers
11// of the DownstreamLoader. The class that implements this client
12// interface must outlive the DownstreamLoader.
13class DownstreamLoaderClient {
14 public:
15 DownstreamLoaderClient(const DownstreamLoaderClient&) = delete;
16 DownstreamLoaderClient& operator=(const DownstreamLoaderClient&) = delete;
17
18 protected:
19 DownstreamLoaderClient() = default;
20 virtual ~DownstreamLoaderClient() = default;
21
22 private:
23 friend class DownstreamLoader;
24
25 // Executed when downstream data is received.
Helmut Januschka3ae90002024-05-02 18:42:2826 virtual void OnDownstreamDataReceived(std::string_view new_response_data) = 0;
evliu6a88379d2020-05-19 18:22:3227
28 // Executed when downstream data is completed.
29 // success: True on 2xx responses where the entire body was successfully
30 // received. response_code: The HTTP response code if available, or -1 on
31 // network errors.
32 virtual void OnDownstreamDataComplete(bool success, int response_code) = 0;
33};
34
35} // namespace speech
36
37#endif // COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_