Skip to content

Commit

Permalink
Allow multiple DataDecoderService receivers
Browse files Browse the repository at this point in the history
DataDecoderService is currently set up to allow only a single client
pipe. This is reasonable for the out-of-process case in most production
environments. For the in-process case (in tests and on iOS) however, it
is possible and reasonable for a single instance to have multiple
DataDecoderService pipes connected to it.

This upgrades the lone Receiver to a ReceiverSet, allowing for multiple
clients.

Fixed: 1022313
Change-Id: Iaeea6e1b1316351da0b6f57ae4a432eed62b5575
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903748
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#713566}
  • Loading branch information
krockot authored and Commit Bot committed Nov 7, 2019
1 parent 4fd6c99 commit 8b59897
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions services/data_decoder/data_decoder_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ DataDecoderService::DataDecoderService() = default;

DataDecoderService::DataDecoderService(
mojo::PendingReceiver<mojom::DataDecoderService> receiver) {
receiver_.Bind(std::move(receiver));
receivers_.Add(this, std::move(receiver));
}

DataDecoderService::~DataDecoderService() = default;

void DataDecoderService::BindReceiver(
mojo::PendingReceiver<mojom::DataDecoderService> receiver) {
receiver_.Bind(std::move(receiver));
receivers_.Add(this, std::move(receiver));
}

void DataDecoderService::BindImageDecoder(
Expand Down
6 changes: 4 additions & 2 deletions services/data_decoder/data_decoder_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "base/macros.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/data_decoder/public/mojom/bundled_exchanges_parser.mojom.h"
#include "services/data_decoder/public/mojom/data_decoder_service.mojom.h"
#include "services/data_decoder/public/mojom/image_decoder.mojom.h"
Expand Down Expand Up @@ -61,7 +61,9 @@ class DataDecoderService : public mojom::DataDecoderService {
mojo::PendingReceiver<mojom::BleScanParser> receiver) override;
#endif // OS_CHROMEOS

mojo::Receiver<mojom::DataDecoderService> receiver_{this};
// In-process instances (e.g. on iOS or in tests) may have multiple concurrent
// remote DataDecoderService clients.
mojo::ReceiverSet<mojom::DataDecoderService> receivers_;

bool drop_image_decoders_ = false;
bool drop_json_parsers_ = false;
Expand Down

0 comments on commit 8b59897

Please sign in to comment.