downstream_loader_client.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_
  5. #define COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_
  6. #include "base/strings/string_piece.h"
  7. namespace speech {
  8. // An interface containing the callback functions required by consumers
  9. // of the DownstreamLoader. The class that implements this client
  10. // interface must outlive the DownstreamLoader.
  11. class DownstreamLoaderClient {
  12. public:
  13. DownstreamLoaderClient(const DownstreamLoaderClient&) = delete;
  14. DownstreamLoaderClient& operator=(const DownstreamLoaderClient&) = delete;
  15. protected:
  16. DownstreamLoaderClient() = default;
  17. virtual ~DownstreamLoaderClient() = default;
  18. private:
  19. friend class DownstreamLoader;
  20. // Executed when downstream data is received.
  21. virtual void OnDownstreamDataReceived(
  22. base::StringPiece new_response_data) = 0;
  23. // Executed when downstream data is completed.
  24. // success: True on 2xx responses where the entire body was successfully
  25. // received. response_code: The HTTP response code if available, or -1 on
  26. // network errors.
  27. virtual void OnDownstreamDataComplete(bool success, int response_code) = 0;
  28. };
  29. } // namespace speech
  30. #endif // COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_