Commit 17319fd6 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Migrate interventions_internals.mojom to the new Mojo types

Convert the implementation and all users of the
mojom::InterventionsInternalsPageHandler and InterventionsInternalsPage
interfaces.

Bug: 955171
Change-Id: I7a11210d5c392bc8b11ae2ef283f66222d1c17cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808860Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarBen Greenstein <bengr@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#697814}
parent 2ea9f475
......@@ -58,7 +58,7 @@ interface InterventionsInternalsPageHandler {
GetPreviewsFlagsDetails() => (array<PreviewsFlag> flags);
// Inject the client side page object.
SetClientPage(InterventionsInternalsPage page);
SetClientPage(pending_remote<InterventionsInternalsPage> page);
// Change the status of ignoring blacklist to |ignored|. |ignored| will
// indicate whether the blacklist decision would be ignored when deciding if a
......
......@@ -14,10 +14,15 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/flag_descriptions.h"
#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
#include "chrome/common/chrome_switches.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/previews/core/previews_experiments.h"
#include "components/previews/core/previews_switches.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "services/network/public/cpp/network_quality_tracker.h"
......@@ -123,10 +128,10 @@ std::string GetEnabledStateForSwitch(const std::string& switch_name) {
} // namespace
InterventionsInternalsPageHandler::InterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request,
mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver,
previews::PreviewsUIService* previews_ui_service,
network::NetworkQualityTracker* network_quality_tracker)
: binding_(this, std::move(request)),
: receiver_(this, std::move(receiver)),
previews_ui_service_(previews_ui_service),
network_quality_tracker_(network_quality_tracker),
current_estimated_ect_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
......@@ -143,8 +148,8 @@ InterventionsInternalsPageHandler::~InterventionsInternalsPageHandler() {
}
void InterventionsInternalsPageHandler::SetClientPage(
mojom::InterventionsInternalsPagePtr page) {
page_ = std::move(page);
mojo::PendingRemote<mojom::InterventionsInternalsPage> page) {
page_.Bind(std::move(page));
DCHECK(page_);
logger_->AddAndNotifyObserver(this);
(network_quality_tracker_ ? network_quality_tracker_
......
......@@ -13,7 +13,10 @@
#include "components/previews/content/previews_ui_service.h"
#include "components/previews/core/previews_logger.h"
#include "components/previews/core/previews_logger_observer.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/nqe/effective_connection_type.h"
#include "services/network/public/cpp/network_quality_tracker.h"
......@@ -23,7 +26,7 @@ class InterventionsInternalsPageHandler
public mojom::InterventionsInternalsPageHandler {
public:
InterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request,
mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver,
previews::PreviewsUIService* previews_ui_service,
network::NetworkQualityTracker* network_quality_tracker);
~InterventionsInternalsPageHandler() override;
......@@ -32,7 +35,8 @@ class InterventionsInternalsPageHandler
void GetPreviewsEnabled(GetPreviewsEnabledCallback callback) override;
void GetPreviewsFlagsDetails(
GetPreviewsFlagsDetailsCallback callback) override;
void SetClientPage(mojom::InterventionsInternalsPagePtr page) override;
void SetClientPage(
mojo::PendingRemote<mojom::InterventionsInternalsPage> page) override;
void SetIgnorePreviewsBlacklistDecision(bool ignore) override;
// previews::PreviewsLoggerObserver:
......@@ -49,7 +53,7 @@ class InterventionsInternalsPageHandler
void OnEffectiveConnectionTypeChanged(
net::EffectiveConnectionType type) override;
mojo::Binding<mojom::InterventionsInternalsPageHandler> binding_;
mojo::Receiver<mojom::InterventionsInternalsPageHandler> receiver_;
// The PreviewsLogger that this handler is listening to, and guaranteed to
// outlive |this|.
......@@ -67,7 +71,7 @@ class InterventionsInternalsPageHandler
net::EffectiveConnectionType current_estimated_ect_;
// Handle back to the page by which we can pass in new log messages.
mojom::InterventionsInternalsPagePtr page_;
mojo::Remote<mojom::InterventionsInternalsPage> page_;
DISALLOW_COPY_AND_ASSIGN(InterventionsInternalsPageHandler);
};
......
......@@ -39,7 +39,9 @@
#include "components/previews/core/previews_logger_observer.h"
#include "components/previews/core/previews_switches.h"
#include "content/public/test/browser_task_environment.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/base/features.h"
#include "net/nqe/effective_connection_type.h"
#include "net/nqe/network_quality_estimator_params.h"
......@@ -145,8 +147,8 @@ class TestInterventionsInternalsPage
: public mojom::InterventionsInternalsPage {
public:
TestInterventionsInternalsPage(
mojom::InterventionsInternalsPageRequest request)
: binding_(this, std::move(request)), blacklist_ignored_(false) {}
mojo::PendingReceiver<mojom::InterventionsInternalsPage> receiver)
: receiver_(this, std::move(receiver)), blacklist_ignored_(false) {}
~TestInterventionsInternalsPage() override {}
......@@ -188,7 +190,7 @@ class TestInterventionsInternalsPage
bool blacklist_ignored() const { return blacklist_ignored_; }
private:
mojo::Binding<mojom::InterventionsInternalsPage> binding_;
mojo::Receiver<mojom::InterventionsInternalsPage> receiver_;
// The MessageLogPtr passed in LogNewMessage method.
std::unique_ptr<mojom::MessageLogPtr> message_;
......@@ -285,21 +287,21 @@ class InterventionsInternalsPageHandlerTest : public testing::Test {
ASSERT_TRUE(profile_manager_.SetUp());
mojom::InterventionsInternalsPageHandlerPtr page_handler_ptr;
mojom::InterventionsInternalsPageHandlerRequest handler_request =
mojo::MakeRequest(&page_handler_ptr);
mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler>
handler_receiver =
mojo::PendingRemote<mojom::InterventionsInternalsPageHandler>()
.InitWithNewPipeAndPassReceiver();
page_handler_ = std::make_unique<InterventionsInternalsPageHandler>(
std::move(handler_request), previews_ui_service_.get(),
std::move(handler_receiver), previews_ui_service_.get(),
&test_network_quality_tracker_);
mojom::InterventionsInternalsPagePtr page_ptr;
mojom::InterventionsInternalsPageRequest page_request =
mojo::MakeRequest(&page_ptr);
mojo::PendingRemote<mojom::InterventionsInternalsPage> page;
mojo::PendingReceiver<mojom::InterventionsInternalsPage> page_receiver =
page.InitWithNewPipeAndPassReceiver();
page_ = std::make_unique<TestInterventionsInternalsPage>(
std::move(page_request));
std::move(page_receiver));
page_handler_->SetClientPage(std::move(page_ptr));
page_handler_->SetClientPage(std::move(page));
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
}
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
......@@ -12,10 +13,12 @@
#include "chrome/browser/previews/previews_service.h"
#include "chrome/browser/previews/previews_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "components/previews/content/previews_ui_service.h"
#include "content/public/browser/web_ui_data_source.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace {
......@@ -62,8 +65,8 @@ InterventionsInternalsUI::InterventionsInternalsUI(content::WebUI* web_ui)
InterventionsInternalsUI::~InterventionsInternalsUI() {}
void InterventionsInternalsUI::BindInterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request) {
mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver) {
DCHECK(previews_ui_service_);
page_handler_ = std::make_unique<InterventionsInternalsPageHandler>(
std::move(request), previews_ui_service_, nullptr);
std::move(receiver), previews_ui_service_, nullptr);
}
......@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
#include "chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"
namespace previews {
......@@ -22,7 +23,7 @@ class InterventionsInternalsUI : public ui::MojoWebUIController {
private:
void BindInterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request);
mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver);
// The PreviewsUIService associated with this UI.
previews::PreviewsUIService* previews_ui_service_;
......
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