Commit 07bfead9 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert WiFiDisplaySessionService to new Mojo types

This CL converts WiFiDisplaySessionService{Ptr, Request} in
extensions to the new Mojo type.

Bug: 955171
Change-Id: I5eba79faacfb08a099feeca4d003270f21c5364a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862456Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#706313}
parent 52139e8f
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "extensions/browser/api/display_source/display_source_connection_delegate_factory.h" #include "extensions/browser/api/display_source/display_source_connection_delegate_factory.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace { namespace {
const char kErrorCannotHaveMultipleSessions[] = const char kErrorCannotHaveMultipleSessions[] =
...@@ -33,17 +32,17 @@ WiFiDisplaySessionServiceImpl::~WiFiDisplaySessionServiceImpl() { ...@@ -33,17 +32,17 @@ WiFiDisplaySessionServiceImpl::~WiFiDisplaySessionServiceImpl() {
} }
// static // static
void WiFiDisplaySessionServiceImpl::BindToRequest( void WiFiDisplaySessionServiceImpl::BindToReceiver(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
WiFiDisplaySessionServiceRequest request, mojo::PendingReceiver<WiFiDisplaySessionService> receiver,
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
DisplaySourceConnectionDelegate* delegate = DisplaySourceConnectionDelegate* delegate =
DisplaySourceConnectionDelegateFactory::GetForBrowserContext( DisplaySourceConnectionDelegateFactory::GetForBrowserContext(
browser_context); browser_context);
CHECK(delegate); CHECK(delegate);
auto* impl = new WiFiDisplaySessionServiceImpl(delegate); auto* impl = new WiFiDisplaySessionServiceImpl(delegate);
impl->binding_ = impl->receiver_ =
mojo::MakeStrongBinding(base::WrapUnique(impl), std::move(request)); mojo::MakeSelfOwnedReceiver(base::WrapUnique(impl), std::move(receiver));
} }
void WiFiDisplaySessionServiceImpl::SetClient( void WiFiDisplaySessionServiceImpl::SetClient(
...@@ -200,7 +199,7 @@ void WiFiDisplaySessionServiceImpl::OnDisconnectFailed( ...@@ -200,7 +199,7 @@ void WiFiDisplaySessionServiceImpl::OnDisconnectFailed(
void WiFiDisplaySessionServiceImpl::OnClientConnectionError() { void WiFiDisplaySessionServiceImpl::OnClientConnectionError() {
DLOG(ERROR) << "IPC connection error"; DLOG(ERROR) << "IPC connection error";
binding_->Close(); receiver_->reset();
} }
} // namespace extensions } // namespace extensions
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "extensions/browser/api/display_source/display_source_connection_delegate.h" #include "extensions/browser/api/display_source/display_source_connection_delegate.h"
#include "extensions/common/mojom/wifi_display_session_service.mojom.h" #include "extensions/common/mojom/wifi_display_session_service.mojom.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/pending_reciever.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace content { namespace content {
class BrowserContext; class BrowserContext;
...@@ -27,8 +27,9 @@ class WiFiDisplaySessionServiceImpl ...@@ -27,8 +27,9 @@ class WiFiDisplaySessionServiceImpl
public DisplaySourceConnectionDelegate::Observer { public DisplaySourceConnectionDelegate::Observer {
public: public:
~WiFiDisplaySessionServiceImpl() override; ~WiFiDisplaySessionServiceImpl() override;
static void BindToRequest(content::BrowserContext* browser_context, static void BindToReceiver(
mojom::WiFiDisplaySessionServiceRequest request, content::BrowserContext* browser_context,
mojo::PendingReceiver<mojom::WiFiDisplaySessionService> receiver,
content::RenderFrameHost* render_frame_host); content::RenderFrameHost* render_frame_host);
private: private:
...@@ -67,7 +68,7 @@ class WiFiDisplaySessionServiceImpl ...@@ -67,7 +68,7 @@ class WiFiDisplaySessionServiceImpl
// Id of the sink of the session this object is associated with. // Id of the sink of the session this object is associated with.
int sink_id_; int sink_id_;
mojo::StrongBindingPtr<mojom::WiFiDisplaySessionService> binding_; mojo::SelfOwnedReceiverRef<mojom::WiFiDisplaySessionService> receiver_;
base::WeakPtrFactory<WiFiDisplaySessionServiceImpl> weak_factory_; base::WeakPtrFactory<WiFiDisplaySessionServiceImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WiFiDisplaySessionServiceImpl); DISALLOW_COPY_AND_ASSIGN(WiFiDisplaySessionServiceImpl);
......
...@@ -60,7 +60,7 @@ void RegisterInterfacesForExtension(service_manager::BinderRegistryWithArgs< ...@@ -60,7 +60,7 @@ void RegisterInterfacesForExtension(service_manager::BinderRegistryWithArgs<
if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), if (ExtensionHasPermission(extension, render_frame_host->GetProcess(),
"displaySource")) { "displaySource")) {
registry->AddInterface( registry->AddInterface(
base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest, base::Bind(WiFiDisplaySessionServiceImpl::BindToReceiver,
render_frame_host->GetProcess()->GetBrowserContext())); render_frame_host->GetProcess()->GetBrowserContext()));
registry->AddInterface( registry->AddInterface(
base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest)); base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest));
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "extensions/common/mojom/wifi_display_session_service.mojom.h" #include "extensions/common/mojom/wifi_display_session_service.mojom.h"
#include "extensions/renderer/api/display_source/display_source_session.h" #include "extensions/renderer/api/display_source/display_source_session.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/wds/src/libwds/public/source.h" #include "third_party/wds/src/libwds/public/source.h"
namespace base { namespace base {
...@@ -74,7 +75,7 @@ class WiFiDisplaySession : public DisplaySourceSession, ...@@ -74,7 +75,7 @@ class WiFiDisplaySession : public DisplaySourceSession,
private: private:
std::unique_ptr<wds::Source> wfd_source_; std::unique_ptr<wds::Source> wfd_source_;
std::unique_ptr<WiFiDisplayMediaManager> media_manager_; std::unique_ptr<WiFiDisplayMediaManager> media_manager_;
mojom::WiFiDisplaySessionServicePtr service_; mojo::Remote<mojom::WiFiDisplaySessionService> service_;
mojo::Receiver<WiFiDisplaySessionServiceClient> receiver_{this}; mojo::Receiver<WiFiDisplaySessionServiceClient> receiver_{this};
std::string local_ip_address_; std::string local_ip_address_;
std::map<int, std::unique_ptr<base::RepeatingTimer>> timers_; std::map<int, std::unique_ptr<base::RepeatingTimer>> timers_;
......
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