Commit e921922e authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Migrate DataReductionProxy to the new Mojo types

This CL converts old Mojo types to the new Mojo types
in DataReductionProxy interface.

 - Apply pending_remote to DataReductionProxyThrottleConfigObserver
   argument in AddThrottleConfigObserver.

Bug: 955171
Change-Id: I97e09e918f3ef206196d5f856b00a60b9e382650
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787762Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#694718}
parent ca5efa8e
...@@ -146,12 +146,10 @@ ClientConfig CreateEmptyConfig() { ...@@ -146,12 +146,10 @@ ClientConfig CreateEmptyConfig() {
class ScopedConfigWaiter class ScopedConfigWaiter
: public mojom::DataReductionProxyThrottleConfigObserver { : public mojom::DataReductionProxyThrottleConfigObserver {
public: public:
explicit ScopedConfigWaiter(Profile* profile) : binding_(this) { explicit ScopedConfigWaiter(Profile* profile) {
mojom::DataReductionProxyThrottleConfigObserverPtr observer;
binding_.Bind(mojo::MakeRequest(&observer));
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile) DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile)
->data_reduction_proxy_service() ->data_reduction_proxy_service()
->AddThrottleConfigObserver(std::move(observer)); ->AddThrottleConfigObserver(receiver_.BindNewPipeAndPassRemote());
} }
~ScopedConfigWaiter() override { run_loop_.Run(); } ~ScopedConfigWaiter() override { run_loop_.Run(); }
...@@ -170,7 +168,8 @@ class ScopedConfigWaiter ...@@ -170,7 +168,8 @@ class ScopedConfigWaiter
} }
mojom::DataReductionProxyThrottleConfigPtr initial_config_; mojom::DataReductionProxyThrottleConfigPtr initial_config_;
mojo::Binding<mojom::DataReductionProxyThrottleConfigObserver> binding_; mojo::Receiver<mojom::DataReductionProxyThrottleConfigObserver> receiver_{
this};
base::RunLoop run_loop_; base::RunLoop run_loop_;
}; };
......
...@@ -37,8 +37,7 @@ DataReductionProxyURLLoaderThrottle::DataReductionProxyURLLoaderThrottle( ...@@ -37,8 +37,7 @@ DataReductionProxyURLLoaderThrottle::DataReductionProxyURLLoaderThrottle(
DataReductionProxyThrottleManager* manager) DataReductionProxyThrottleManager* manager)
: post_cache_headers_(post_cache_headers), : post_cache_headers_(post_cache_headers),
manager_(manager), manager_(manager),
data_reduction_proxy_(manager_->data_reduction_proxy()), data_reduction_proxy_(manager_->data_reduction_proxy()) {
private_config_observer_binding_(this) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(manager_); DCHECK(manager_);
...@@ -76,9 +75,8 @@ void DataReductionProxyURLLoaderThrottle::SetUpPrivateMojoPipes() { ...@@ -76,9 +75,8 @@ void DataReductionProxyURLLoaderThrottle::SetUpPrivateMojoPipes() {
std::move(private_data_reduction_proxy_info_)); std::move(private_data_reduction_proxy_info_));
data_reduction_proxy_ = private_data_reduction_proxy_.get(); data_reduction_proxy_ = private_data_reduction_proxy_.get();
mojom::DataReductionProxyThrottleConfigObserverPtr observer_ptr; data_reduction_proxy_->AddThrottleConfigObserver(
private_config_observer_binding_.Bind(mojo::MakeRequest(&observer_ptr)); private_config_observer_receiver_.BindNewPipeAndPassRemote());
data_reduction_proxy_->AddThrottleConfigObserver(std::move(observer_ptr));
} }
void DataReductionProxyURLLoaderThrottle::WillStartRequest( void DataReductionProxyURLLoaderThrottle::WillStartRequest(
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_server.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_server.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_throttle_manager.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_throttle_manager.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h" #include "third_party/blink/public/common/loader/url_loader_throttle.h"
namespace data_reduction_proxy { namespace data_reduction_proxy {
...@@ -106,8 +106,8 @@ class DataReductionProxyURLLoaderThrottle ...@@ -106,8 +106,8 @@ class DataReductionProxyURLLoaderThrottle
// Throttles that run on different sequences need "private" mojo pipes. // Throttles that run on different sequences need "private" mojo pipes.
mojom::DataReductionProxyPtrInfo private_data_reduction_proxy_info_; mojom::DataReductionProxyPtrInfo private_data_reduction_proxy_info_;
mojom::DataReductionProxyPtr private_data_reduction_proxy_; mojom::DataReductionProxyPtr private_data_reduction_proxy_;
mojo::Binding<mojom::DataReductionProxyThrottleConfigObserver> mojo::Receiver<mojom::DataReductionProxyThrottleConfigObserver>
private_config_observer_binding_; private_config_observer_receiver_{this};
// The last seen config values. // The last seen config values.
std::vector<DataReductionProxyServer> proxies_for_http_; std::vector<DataReductionProxyServer> proxies_for_http_;
......
...@@ -46,7 +46,8 @@ class MockMojoDataReductionProxy : public mojom::DataReductionProxy { ...@@ -46,7 +46,8 @@ class MockMojoDataReductionProxy : public mojom::DataReductionProxy {
} }
void AddThrottleConfigObserver( void AddThrottleConfigObserver(
mojom::DataReductionProxyThrottleConfigObserverPtr /* observer */) mojo::PendingRemote<
mojom::DataReductionProxyThrottleConfigObserver> /* observer */)
override { override {
++observer_count_; ++observer_count_;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "components/data_reduction_proxy/proto/data_store.pb.h" #include "components/data_reduction_proxy/proto/data_store.pb.h"
#include "components/data_use_measurement/core/data_use_measurement.h" #include "components/data_use_measurement/core/data_use_measurement.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace data_reduction_proxy { namespace data_reduction_proxy {
...@@ -435,9 +436,12 @@ void DataReductionProxyService::MarkProxiesAsBad( ...@@ -435,9 +436,12 @@ void DataReductionProxyService::MarkProxiesAsBad(
} }
void DataReductionProxyService::AddThrottleConfigObserver( void DataReductionProxyService::AddThrottleConfigObserver(
mojom::DataReductionProxyThrottleConfigObserverPtr observer) { mojo::PendingRemote<mojom::DataReductionProxyThrottleConfigObserver>
observer->OnThrottleConfigChanged(CreateThrottleConfig()); observer) {
drp_throttle_config_observers_.AddPtr(std::move(observer)); mojo::Remote<mojom::DataReductionProxyThrottleConfigObserver> observer_remote(
std::move(observer));
observer_remote->OnThrottleConfigChanged(CreateThrottleConfig());
drp_throttle_config_observers_.Add(std::move(observer_remote));
} }
void DataReductionProxyService::Clone( void DataReductionProxyService::Clone(
...@@ -460,10 +464,8 @@ void DataReductionProxyService::UpdateThrottleConfig() { ...@@ -460,10 +464,8 @@ void DataReductionProxyService::UpdateThrottleConfig() {
auto config = CreateThrottleConfig(); auto config = CreateThrottleConfig();
drp_throttle_config_observers_.ForAllPtrs( for (auto& it : drp_throttle_config_observers_)
[&config](mojom::DataReductionProxyThrottleConfigObserver* observer) { it->OnThrottleConfigChanged(config->Clone());
observer->OnThrottleConfigChanged(config->Clone());
});
} }
mojom::DataReductionProxyThrottleConfigPtr mojom::DataReductionProxyThrottleConfigPtr
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "components/data_reduction_proxy/core/browser/db_data_owner.h" #include "components/data_reduction_proxy/core/browser/db_data_owner.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy.mojom.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy.mojom.h"
#include "components/data_use_measurement/core/data_use_measurement.h" #include "components/data_use_measurement/core/data_use_measurement.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote_set.h" #include "mojo/public/cpp/bindings/remote_set.h"
#include "net/nqe/effective_connection_type.h" #include "net/nqe/effective_connection_type.h"
#include "services/network/public/cpp/network_connection_tracker.h" #include "services/network/public/cpp/network_connection_tracker.h"
...@@ -168,7 +168,8 @@ class DataReductionProxyService ...@@ -168,7 +168,8 @@ class DataReductionProxyService
const net::ProxyList& bad_proxies, const net::ProxyList& bad_proxies,
MarkProxiesAsBadCallback callback) override; MarkProxiesAsBadCallback callback) override;
void AddThrottleConfigObserver( void AddThrottleConfigObserver(
mojom::DataReductionProxyThrottleConfigObserverPtr observer) override; mojo::PendingRemote<mojom::DataReductionProxyThrottleConfigObserver>
observer) override;
void Clone(mojom::DataReductionProxyRequest request) override; void Clone(mojom::DataReductionProxyRequest request) override;
// Accessor methods. // Accessor methods.
...@@ -328,7 +329,7 @@ class DataReductionProxyService ...@@ -328,7 +329,7 @@ class DataReductionProxyService
mojo::BindingSet<mojom::DataReductionProxy> drp_bindings_; mojo::BindingSet<mojom::DataReductionProxy> drp_bindings_;
mojo::InterfacePtrSet<mojom::DataReductionProxyThrottleConfigObserver> mojo::RemoteSet<mojom::DataReductionProxyThrottleConfigObserver>
drp_throttle_config_observers_; drp_throttle_config_observers_;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
......
...@@ -34,7 +34,8 @@ interface DataReductionProxy { ...@@ -34,7 +34,8 @@ interface DataReductionProxy {
MarkProxiesAsBad(mojo_base.mojom.TimeDelta bypass_duration, MarkProxiesAsBad(mojo_base.mojom.TimeDelta bypass_duration,
network.mojom.ProxyList bad_proxies) => (); network.mojom.ProxyList bad_proxies) => ();
AddThrottleConfigObserver(DataReductionProxyThrottleConfigObserver observer); AddThrottleConfigObserver(
pending_remote<DataReductionProxyThrottleConfigObserver> observer);
Clone(DataReductionProxy& request); Clone(DataReductionProxy& request);
}; };
...@@ -17,13 +17,11 @@ namespace data_reduction_proxy { ...@@ -17,13 +17,11 @@ namespace data_reduction_proxy {
DataReductionProxyThrottleManager::DataReductionProxyThrottleManager( DataReductionProxyThrottleManager::DataReductionProxyThrottleManager(
mojom::DataReductionProxy* data_reduction_proxy, mojom::DataReductionProxy* data_reduction_proxy,
mojom::DataReductionProxyThrottleConfigPtr initial_config) mojom::DataReductionProxyThrottleConfigPtr initial_config)
: shared_data_reduction_proxy_(data_reduction_proxy), binding_(this) { : shared_data_reduction_proxy_(data_reduction_proxy) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
mojom::DataReductionProxyThrottleConfigObserverPtr observer; shared_data_reduction_proxy_->AddThrottleConfigObserver(
binding_.Bind(mojo::MakeRequest(&observer)); receiver_.BindNewPipeAndPassRemote());
shared_data_reduction_proxy_->AddThrottleConfigObserver(std::move(observer));
OnThrottleConfigChanged(std::move(initial_config)); OnThrottleConfigChanged(std::move(initial_config));
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy.mojom.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy.mojom.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
namespace data_reduction_proxy { namespace data_reduction_proxy {
...@@ -72,9 +72,9 @@ class DataReductionProxyThrottleManager ...@@ -72,9 +72,9 @@ class DataReductionProxyThrottleManager
/* check_empty = */ true> /* check_empty = */ true>
same_sequence_observers_; same_sequence_observers_;
mojo::Binding< mojo::Receiver<
data_reduction_proxy::mojom::DataReductionProxyThrottleConfigObserver> data_reduction_proxy::mojom::DataReductionProxyThrottleConfigObserver>
binding_; receiver_{this};
// The last seen config values. // The last seen config values.
mojom::DataReductionProxyThrottleConfigPtr last_proxy_config_; mojom::DataReductionProxyThrottleConfigPtr last_proxy_config_;
......
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