summaryrefslogtreecommitdiff
path: root/chromium/components/speech/downstream_loader.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/speech/downstream_loader.h')
-rw-r--r--chromium/components/speech/downstream_loader.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/chromium/components/speech/downstream_loader.h b/chromium/components/speech/downstream_loader.h
new file mode 100644
index 00000000000..f6682a7f8be
--- /dev/null
+++ b/chromium/components/speech/downstream_loader.h
@@ -0,0 +1,46 @@
+// Copyright 2020 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.
+
+#ifndef COMPONENTS_SPEECH_DOWNSTREAM_LOADER_H_
+#define COMPONENTS_SPEECH_DOWNSTREAM_LOADER_H_
+
+#include <memory>
+
+#include "base/callback_forward.h"
+#include "base/strings/string_piece.h"
+#include "services/network/public/cpp/resource_request.h"
+#include "services/network/public/cpp/simple_url_loader.h"
+#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
+
+namespace speech {
+
+class DownstreamLoaderClient;
+
+// Streams response data from the server to the DownstreamLoaderClient.
+class DownstreamLoader : public network::SimpleURLLoaderStreamConsumer {
+ public:
+ DownstreamLoader(std::unique_ptr<network::ResourceRequest> resource_request,
+ net::NetworkTrafficAnnotationTag upstream_traffic_annotation,
+ network::mojom::URLLoaderFactory* url_loader_factory,
+ DownstreamLoaderClient* downstream_loader_client);
+ DownstreamLoader(const DownstreamLoader&) = delete;
+ DownstreamLoader& operator=(const DownstreamLoader&) = delete;
+ ~DownstreamLoader() override;
+
+ // SimpleURLLoaderStreamConsumer implementation:
+ void OnDataReceived(base::StringPiece string_piece,
+ base::OnceClosure resume) override;
+ void OnComplete(bool success) override;
+ void OnRetry(base::OnceClosure start_retry) override;
+
+ private:
+ // The DownstreamLoaderClient must outlive the DownstreamLoader.
+ DownstreamLoaderClient* const downstream_loader_client_;
+
+ std::unique_ptr<network::SimpleURLLoader> simple_url_loader_;
+};
+
+} // namespace speech
+
+#endif // COMPONENTS_SPEECH_DOWNSTREAM_LOADER_H_