Commit faaa0d23 authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

[remoteobjects] Implement listing object methods in the renderer

This CL adds an implementation of EnumerateNamedProperties() that ends up
calling a remote GetMethods() method on a RemoteObject mojo remote.
The remote will be connected to a RemoteObject implementation
in follow-up CLs.

Bug: 794320
Change-Id: Ia3748d6842608e56b5c7985147f28985feabde93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1962985Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727591}
parent fdaa0cf2
......@@ -31,8 +31,16 @@ v8::Local<v8::Value> RemoteObject::GetNamedProperty(
std::vector<std::string> RemoteObject::EnumerateNamedProperties(
v8::Isolate* isolate) {
// TODO(crbug.com/794320): implement this.
return std::vector<std::string>();
if (!object_.is_bound()) {
gateway_->BindRemoteObjectReceiver(object_id_,
object_.BindNewPipeAndPassReceiver());
}
WTF::Vector<WTF::String> methods;
object_->GetMethods(&methods);
std::vector<std::string> result;
for (const auto& method : methods)
result.push_back(method.Utf8());
return result;
}
} // namespace blink
......@@ -39,6 +39,7 @@ class RemoteObject : public gin::Wrappable<RemoteObject>,
private:
WeakPersistent<RemoteObjectGatewayImpl> gateway_{nullptr};
mojo::Remote<mojom::blink::RemoteObject> object_;
int32_t object_id_;
};
......
......@@ -9,6 +9,8 @@
#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#undef GetObject
namespace blink {
// static
......@@ -94,6 +96,12 @@ void RemoteObjectGatewayImpl::RemoveNamedObject(const WTF::String& name) {
named_objects_.erase(iter);
}
void RemoteObjectGatewayImpl::BindRemoteObjectReceiver(
int32_t object_id,
mojo::PendingReceiver<mojom::blink::RemoteObject> receiver) {
object_host_->GetObject(object_id, std::move(receiver));
}
// static
void RemoteObjectGatewayFactoryImpl::Create(
LocalFrame* frame,
......
......@@ -54,6 +54,10 @@ class MODULES_EXPORT RemoteObjectGatewayImpl
Supplement<LocalFrame>::Trace(visitor);
}
void BindRemoteObjectReceiver(
int32_t object_id,
mojo::PendingReceiver<mojom::blink::RemoteObject>);
private:
// mojom::blink::RemoteObjectGateway
void AddNamedObject(const WTF::String& name, int32_t id) override;
......
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