Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
evliu | 6a88379d | 2020-05-19 18:22:32 | [diff] [blame] | 2 | // 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 | |
evliu | 6a88379d | 2020-05-19 18:22:32 | [diff] [blame] | 8 | namespace 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. |
| 13 | class 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 Januschka | 3ae9000 | 2024-05-02 18:42:28 | [diff] [blame] | 26 | virtual void OnDownstreamDataReceived(std::string_view new_response_data) = 0; |
evliu | 6a88379d | 2020-05-19 18:22:32 | [diff] [blame] | 27 | |
| 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_ |