Commit 4fbb6158 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert DownloadStreamClient to new Mojo types

This CL converts DownloadStreamClientPtr to new Mojo types.
It uses Remote, PendingReceiver, and Receiver instead of
DownloadStreamClientPtr, DownloadStreamClientRequest, and
binding.

Bug: 955171
Change-Id: I20205157b4c0400b95fe0fa6ab915dbb098c7caa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810440Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#699674}
parent 4e65e383
...@@ -215,7 +215,7 @@ void DownloadResponseHandler::OnStartLoadingResponseBody( ...@@ -215,7 +215,7 @@ void DownloadResponseHandler::OnStartLoadingResponseBody(
mojom::DownloadStreamHandlePtr stream_handle = mojom::DownloadStreamHandlePtr stream_handle =
mojom::DownloadStreamHandle::New(); mojom::DownloadStreamHandle::New();
stream_handle->stream = std::move(body); stream_handle->stream = std::move(body);
stream_handle->client_request = mojo::MakeRequest(&client_ptr_); stream_handle->client_receiver = client_remote_.BindNewPipeAndPassReceiver();
OnResponseStarted(std::move(stream_handle)); OnResponseStarted(std::move(stream_handle));
} }
...@@ -229,8 +229,8 @@ void DownloadResponseHandler::OnComplete( ...@@ -229,8 +229,8 @@ void DownloadResponseHandler::OnComplete(
static_cast<net::Error>(status.error_code), has_strong_validators_, static_cast<net::Error>(status.error_code), has_strong_validators_,
cert_status_, is_partial_request_, abort_reason_); cert_status_, is_partial_request_, abort_reason_);
if (client_ptr_) { if (client_remote_) {
client_ptr_->OnStreamCompleted( client_remote_->OnStreamCompleted(
ConvertInterruptReasonToMojoNetworkRequestStatus(reason)); ConvertInterruptReasonToMojoNetworkRequestStatus(reason));
} }
......
...@@ -27,9 +27,9 @@ StreamHandleInputStream::~StreamHandleInputStream() = default; ...@@ -27,9 +27,9 @@ StreamHandleInputStream::~StreamHandleInputStream() = default;
void StreamHandleInputStream::Initialize() { void StreamHandleInputStream::Initialize() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
binding_ = std::make_unique<mojo::Binding<mojom::DownloadStreamClient>>( receiver_ = std::make_unique<mojo::Receiver<mojom::DownloadStreamClient>>(
this, std::move(stream_handle_->client_request)); this, std::move(stream_handle_->client_receiver));
binding_->set_connection_error_handler(base::BindOnce( receiver_->set_disconnect_handler(base::BindOnce(
&StreamHandleInputStream::OnStreamCompleted, base::Unretained(this), &StreamHandleInputStream::OnStreamCompleted, base::Unretained(this),
mojom::NetworkRequestStatus::USER_CANCELED)); mojom::NetworkRequestStatus::USER_CANCELED));
handle_watcher_ = std::make_unique<mojo::SimpleWatcher>( handle_watcher_ = std::make_unique<mojo::SimpleWatcher>(
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "components/download/public/common/download_stream.mojom.h" #include "components/download/public/common/download_stream.mojom.h"
#include "components/download/public/common/download_url_parameters.h" #include "components/download/public/common/download_url_parameters.h"
#include "components/download/public/common/download_utils.h" #include "components/download/public/common/download_utils.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/cert/cert_status_flags.h" #include "net/cert/cert_status_flags.h"
#include "services/network/public/cpp/resource_response.h" #include "services/network/public/cpp/resource_response.h"
#include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h"
...@@ -104,8 +105,8 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadResponseHandler ...@@ -104,8 +105,8 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadResponseHandler
// The abort reason if this class decides to block the download. // The abort reason if this class decides to block the download.
DownloadInterruptReason abort_reason_; DownloadInterruptReason abort_reason_;
// Mojo interface ptr to send the completion status to the download sink. // Mojo interface remote to send the completion status to the download sink.
mojom::DownloadStreamClientPtr client_ptr_; mojo::Remote<mojom::DownloadStreamClient> client_remote_;
// Whether the download is running in background mode. // Whether the download is running in background mode.
bool is_background_mode_; bool is_background_mode_;
......
...@@ -24,5 +24,5 @@ interface DownloadStreamClient { ...@@ -24,5 +24,5 @@ interface DownloadStreamClient {
struct DownloadStreamHandle { struct DownloadStreamHandle {
handle<data_pipe_consumer> stream; handle<data_pipe_consumer> stream;
DownloadStreamClient& client_request; pending_receiver<DownloadStreamClient> client_receiver;
}; };
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "components/download/public/common/download_export.h" #include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_stream.mojom.h" #include "components/download/public/common/download_stream.mojom.h"
#include "components/download/public/common/input_stream.h" #include "components/download/public/common/input_stream.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/system/simple_watcher.h" #include "mojo/public/cpp/system/simple_watcher.h"
namespace download { namespace download {
...@@ -40,7 +40,7 @@ class COMPONENTS_DOWNLOAD_EXPORT StreamHandleInputStream ...@@ -40,7 +40,7 @@ class COMPONENTS_DOWNLOAD_EXPORT StreamHandleInputStream
// Objects for consuming a mojo data pipe. // Objects for consuming a mojo data pipe.
mojom::DownloadStreamHandlePtr stream_handle_; mojom::DownloadStreamHandlePtr stream_handle_;
std::unique_ptr<mojo::SimpleWatcher> handle_watcher_; std::unique_ptr<mojo::SimpleWatcher> handle_watcher_;
std::unique_ptr<mojo::Binding<mojom::DownloadStreamClient>> binding_; std::unique_ptr<mojo::Receiver<mojom::DownloadStreamClient>> receiver_;
// Whether the producer has completed handling the response. // Whether the producer has completed handling the response.
bool is_response_completed_; bool is_response_completed_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment