Commit c6e93dcd authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert QueryableDataStore to new Mojo types

This CL converts QueryableDataStorePtr and QueryableDataStoreRequest
to new Mojo types.

It uses Remote, PendingReceiver and ReceiverSet instead of
QueryableDataStorePtr, QueryableDataStoreRequest and BindingSet.

Bug: 955171
Change-Id: Iecdac72ae103960845b4764b0513c7ac98a99ade
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804712Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#697038}
parent 17238d32
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "content/public/common/bindings_policy.h" #include "content/public/common/bindings_policy.h"
#include "content/public/common/favicon_url.h" #include "content/public/common/favicon_url.h"
#include "content/public/common/resource_load_info.mojom.h" #include "content/public/common/resource_load_info.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
...@@ -376,12 +377,13 @@ void CastWebContentsImpl::RenderFrameCreated( ...@@ -376,12 +377,13 @@ void CastWebContentsImpl::RenderFrameCreated(
media_playback_options->SetUseCmaRenderer(use_cma_renderer_); media_playback_options->SetUseCmaRenderer(use_cma_renderer_);
// Send queryable values // Send queryable values
chromecast::shell::mojom::QueryableDataStorePtr queryable_data_store_ptr; mojo::Remote<chromecast::shell::mojom::QueryableDataStore>
queryable_data_store_remote;
render_frame_host->GetRemoteInterfaces()->GetInterface( render_frame_host->GetRemoteInterfaces()->GetInterface(
&queryable_data_store_ptr); queryable_data_store_remote.BindNewPipeAndPassReceiver());
for (const auto& value : QueryableData::GetValues()) { for (const auto& value : QueryableData::GetValues()) {
// base::Value is not copyable. // base::Value is not copyable.
queryable_data_store_ptr->Set(value.first, value.second.Clone()); queryable_data_store_remote->Set(value.first, value.second.Clone());
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "chromecast/common/mojom/queryable_data_store.mojom.h" #include "chromecast/common/mojom/queryable_data_store.mojom.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
namespace chromecast { namespace chromecast {
...@@ -22,10 +23,10 @@ void QueryableDataHostCast::SendQueryableValue(const std::string& key, ...@@ -22,10 +23,10 @@ void QueryableDataHostCast::SendQueryableValue(const std::string& key,
const base::Value& value) { const base::Value& value) {
for (content::RenderFrameHost* render_frame_host : for (content::RenderFrameHost* render_frame_host :
web_contents_->GetAllFrames()) { web_contents_->GetAllFrames()) {
shell::mojom::QueryableDataStorePtr queryable_data_store_ptr; mojo::Remote<shell::mojom::QueryableDataStore> queryable_data_store_remote;
render_frame_host->GetRemoteInterfaces()->GetInterface( render_frame_host->GetRemoteInterfaces()->GetInterface(
&queryable_data_store_ptr); queryable_data_store_remote.BindNewPipeAndPassReceiver());
queryable_data_store_ptr->Set(key, value.Clone()); queryable_data_store_remote->Set(key, value.Clone());
} }
} }
......
...@@ -27,7 +27,7 @@ QueryableDataBindings::QueryableDataBindings(content::RenderFrame* frame) ...@@ -27,7 +27,7 @@ QueryableDataBindings::QueryableDataBindings(content::RenderFrame* frame)
queryable_data_store_(std::make_unique<QueryableDataStore>( queryable_data_store_(std::make_unique<QueryableDataStore>(
base::ThreadTaskRunnerHandle::Get())) { base::ThreadTaskRunnerHandle::Get())) {
registry_.AddInterface<shell::mojom::QueryableDataStore>( registry_.AddInterface<shell::mojom::QueryableDataStore>(
base::BindRepeating(&QueryableDataStore::BindQueryableDataStoreRequest, base::BindRepeating(&QueryableDataStore::BindQueryableDataStoreReceiver,
base::Unretained(queryable_data_store_.get()))); base::Unretained(queryable_data_store_.get())));
} }
......
...@@ -25,9 +25,9 @@ void QueryableDataStore::Set(const std::string& key, base::Value value) { ...@@ -25,9 +25,9 @@ void QueryableDataStore::Set(const std::string& key, base::Value value) {
std::move(value))); std::move(value)));
} }
void QueryableDataStore::BindQueryableDataStoreRequest( void QueryableDataStore::BindQueryableDataStoreReceiver(
shell::mojom::QueryableDataStoreRequest request) { mojo::PendingReceiver<shell::mojom::QueryableDataStore> receiver) {
queryable_data_bindings_.AddBinding(this, std::move(request)); queryable_data_receivers_.Add(this, std::move(receiver));
} }
} // namespace chromecast } // namespace chromecast
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "chromecast/common/mojom/queryable_data_store.mojom.h" #include "chromecast/common/mojom/queryable_data_store.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
namespace base { namespace base {
class Value; class Value;
...@@ -27,8 +28,8 @@ class QueryableDataStore : public shell::mojom::QueryableDataStore { ...@@ -27,8 +28,8 @@ class QueryableDataStore : public shell::mojom::QueryableDataStore {
const scoped_refptr<base::TaskRunner> render_main_thread); const scoped_refptr<base::TaskRunner> render_main_thread);
~QueryableDataStore() override; ~QueryableDataStore() override;
void BindQueryableDataStoreRequest( void BindQueryableDataStoreReceiver(
shell::mojom::QueryableDataStoreRequest request); mojo::PendingReceiver<shell::mojom::QueryableDataStore> receiver);
private: private:
// shell::mojom::QueryableDataStore implementation: // shell::mojom::QueryableDataStore implementation:
...@@ -36,7 +37,7 @@ class QueryableDataStore : public shell::mojom::QueryableDataStore { ...@@ -36,7 +37,7 @@ class QueryableDataStore : public shell::mojom::QueryableDataStore {
const scoped_refptr<base::TaskRunner> render_main_thread_; const scoped_refptr<base::TaskRunner> render_main_thread_;
mojo::BindingSet<shell::mojom::QueryableDataStore> queryable_data_bindings_; mojo::ReceiverSet<shell::mojom::QueryableDataStore> queryable_data_receivers_;
DISALLOW_COPY_AND_ASSIGN(QueryableDataStore); DISALLOW_COPY_AND_ASSIGN(QueryableDataStore);
}; };
......
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