Commit 260cde16 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert Hyphenation to new Mojo types

This CL converts HyphenationRequest and HyphenationPtr to
new Mojo types.

Bug: 955171, 978694
Change-Id: I3be08953612cc01ea30d1f2ed65ea971df263b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1778898
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693134}
parent 0b98e5cc
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace { namespace {
...@@ -58,9 +58,10 @@ HyphenationImpl::HyphenationImpl() {} ...@@ -58,9 +58,10 @@ HyphenationImpl::HyphenationImpl() {}
HyphenationImpl::~HyphenationImpl() {} HyphenationImpl::~HyphenationImpl() {}
// static // static
void HyphenationImpl::Create(blink::mojom::HyphenationRequest request) { void HyphenationImpl::Create(
mojo::MakeStrongBinding(std::make_unique<HyphenationImpl>(), mojo::PendingReceiver<blink::mojom::Hyphenation> receiver) {
std::move(request)); mojo::MakeSelfOwnedReceiver(std::make_unique<HyphenationImpl>(),
std::move(receiver));
} }
// static // static
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/hyphenation/hyphenation.mojom.h" #include "third_party/blink/public/mojom/hyphenation/hyphenation.mojom.h"
namespace hyphenation { namespace hyphenation {
...@@ -17,7 +17,7 @@ class HyphenationImpl : public blink::mojom::Hyphenation { ...@@ -17,7 +17,7 @@ class HyphenationImpl : public blink::mojom::Hyphenation {
HyphenationImpl(); HyphenationImpl();
~HyphenationImpl() override; ~HyphenationImpl() override;
static void Create(blink::mojom::HyphenationRequest); static void Create(mojo::PendingReceiver<blink::mojom::Hyphenation>);
static scoped_refptr<base::SequencedTaskRunner> GetTaskRunner(); static scoped_refptr<base::SequencedTaskRunner> GetTaskRunner();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/files/memory_mapped_file.h" #include "base/files/memory_mapped_file.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/hyphenation/hyphenation.mojom-blink.h" #include "third_party/blink/public/mojom/hyphenation/hyphenation.mojom-blink.h"
#include "third_party/blink/public/platform/interface_provider.h" #include "third_party/blink/public/platform/interface_provider.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
...@@ -48,21 +49,21 @@ StringView SkipLeadingSpaces(const StringView& text, ...@@ -48,21 +49,21 @@ StringView SkipLeadingSpaces(const StringView& text,
using Hyphenator = android::Hyphenator; using Hyphenator = android::Hyphenator;
static mojom::blink::HyphenationPtr ConnectToRemoteService() { static mojo::Remote<mojom::blink::Hyphenation> ConnectToRemoteService() {
mojom::blink::HyphenationPtr service; mojo::Remote<mojom::blink::Hyphenation> service;
Platform::Current()->GetInterfaceProvider()->GetInterface( Platform::Current()->GetInterfaceProvider()->GetInterface(
mojo::MakeRequest(&service)); service.BindNewPipeAndPassReceiver());
return service; return service;
} }
static const mojom::blink::HyphenationPtr& GetService() { static mojom::blink::Hyphenation* GetService() {
DEFINE_STATIC_LOCAL(mojom::blink::HyphenationPtr, service, DEFINE_STATIC_LOCAL(mojo::Remote<mojom::blink::Hyphenation>, service,
(ConnectToRemoteService())); (ConnectToRemoteService()));
return service; return service.get();
} }
bool HyphenationMinikin::OpenDictionary(const AtomicString& locale) { bool HyphenationMinikin::OpenDictionary(const AtomicString& locale) {
const mojom::blink::HyphenationPtr& service = GetService(); mojom::blink::Hyphenation* service = GetService();
base::File file; base::File file;
service->OpenDictionary(locale, &file); service->OpenDictionary(locale, &file);
return OpenDictionary(std::move(file)); return OpenDictionary(std::move(file));
......
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