Commit 13cdf372 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Remove two uses of RevocableInterfacePtr and use mojo::Remotes directly.

We've decided to move away from RevocableInterfacePtr and just use
the remote interface directly.

BUG=978694

Change-Id: I2dbc293b8c89f7a2cb7ed8067d0879f4d5deaba9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842275Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMario Sanchez Prada <mario@igalia.com>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703282}
parent a3bdfbde
...@@ -105,7 +105,7 @@ ScriptPromise CacheStorage::open(ScriptState* script_state, ...@@ -105,7 +105,7 @@ ScriptPromise CacheStorage::open(ScriptState* script_state,
// Make sure to bind the CacheStorage object to keep the mojo interface // Make sure to bind the CacheStorage object to keep the mojo interface
// pointer alive during the operation. Otherwise GC might prevent the // pointer alive during the operation. Otherwise GC might prevent the
// callback from ever being executed. // callback from ever being executed.
cache_storage_ptr_->Open( cache_storage_remote_->Open(
cache_name, trace_id, cache_name, trace_id,
WTF::Bind( WTF::Bind(
[](ScriptPromiseResolver* resolver, [](ScriptPromiseResolver* resolver,
...@@ -171,7 +171,7 @@ ScriptPromise CacheStorage::has(ScriptState* script_state, ...@@ -171,7 +171,7 @@ ScriptPromise CacheStorage::has(ScriptState* script_state,
// Make sure to bind the CacheStorage object to keep the mojo interface // Make sure to bind the CacheStorage object to keep the mojo interface
// pointer alive during the operation. Otherwise GC might prevent the // pointer alive during the operation. Otherwise GC might prevent the
// callback from ever being executed. // callback from ever being executed.
cache_storage_ptr_->Has( cache_storage_remote_->Has(
cache_name, trace_id, cache_name, trace_id,
WTF::Bind( WTF::Bind(
[](ScriptPromiseResolver* resolver, base::TimeTicks start_time, [](ScriptPromiseResolver* resolver, base::TimeTicks start_time,
...@@ -223,7 +223,7 @@ ScriptPromise CacheStorage::Delete(ScriptState* script_state, ...@@ -223,7 +223,7 @@ ScriptPromise CacheStorage::Delete(ScriptState* script_state,
// Make sure to bind the CacheStorage object to keep the mojo interface // Make sure to bind the CacheStorage object to keep the mojo interface
// pointer alive during the operation. Otherwise GC might prevent the // pointer alive during the operation. Otherwise GC might prevent the
// callback from ever being executed. // callback from ever being executed.
cache_storage_ptr_->Delete( cache_storage_remote_->Delete(
cache_name, trace_id, cache_name, trace_id,
WTF::Bind( WTF::Bind(
[](ScriptPromiseResolver* resolver, base::TimeTicks start_time, [](ScriptPromiseResolver* resolver, base::TimeTicks start_time,
...@@ -275,7 +275,7 @@ ScriptPromise CacheStorage::keys(ScriptState* script_state) { ...@@ -275,7 +275,7 @@ ScriptPromise CacheStorage::keys(ScriptState* script_state) {
// Make sure to bind the CacheStorage object to keep the mojo interface // Make sure to bind the CacheStorage object to keep the mojo interface
// pointer alive during the operation. Otherwise GC might prevent the // pointer alive during the operation. Otherwise GC might prevent the
// callback from ever being executed. // callback from ever being executed.
cache_storage_ptr_->Keys( cache_storage_remote_->Keys(
trace_id, trace_id,
WTF::Bind( WTF::Bind(
[](ScriptPromiseResolver* resolver, base::TimeTicks start_time, [](ScriptPromiseResolver* resolver, base::TimeTicks start_time,
...@@ -343,7 +343,7 @@ ScriptPromise CacheStorage::MatchImpl(ScriptState* script_state, ...@@ -343,7 +343,7 @@ ScriptPromise CacheStorage::MatchImpl(ScriptState* script_state,
// Make sure to bind the CacheStorage object to keep the mojo interface // Make sure to bind the CacheStorage object to keep the mojo interface
// pointer alive during the operation. Otherwise GC might prevent the // pointer alive during the operation. Otherwise GC might prevent the
// callback from ever being executed. // callback from ever being executed.
cache_storage_ptr_->Match( cache_storage_remote_->Match(
std::move(mojo_request), std::move(mojo_options), trace_id, std::move(mojo_request), std::move(mojo_options), trace_id,
WTF::Bind( WTF::Bind(
[](ScriptPromiseResolver* resolver, base::TimeTicks start_time, [](ScriptPromiseResolver* resolver, base::TimeTicks start_time,
...@@ -396,7 +396,9 @@ ScriptPromise CacheStorage::MatchImpl(ScriptState* script_state, ...@@ -396,7 +396,9 @@ ScriptPromise CacheStorage::MatchImpl(ScriptState* script_state,
CacheStorage::CacheStorage(ExecutionContext* context, CacheStorage::CacheStorage(ExecutionContext* context,
GlobalFetch::ScopedFetcher* fetcher) GlobalFetch::ScopedFetcher* fetcher)
: ContextClient(context), scoped_fetcher_(fetcher), ever_used_(false) { : ContextLifecycleObserver(context),
scoped_fetcher_(fetcher),
ever_used_(false) {
// See https://bit.ly/2S0zRAS for task types. // See https://bit.ly/2S0zRAS for task types.
scoped_refptr<base::SingleThreadTaskRunner> task_runner = scoped_refptr<base::SingleThreadTaskRunner> task_runner =
context->GetTaskRunner(blink::TaskType::kMiscPlatformAPI); context->GetTaskRunner(blink::TaskType::kMiscPlatformAPI);
...@@ -404,16 +406,17 @@ CacheStorage::CacheStorage(ExecutionContext* context, ...@@ -404,16 +406,17 @@ CacheStorage::CacheStorage(ExecutionContext* context,
// Service workers may already have a CacheStoragePtr provided as an // Service workers may already have a CacheStoragePtr provided as an
// optimization. // optimization.
if (auto* service_worker = DynamicTo<ServiceWorkerGlobalScope>(context)) { if (auto* service_worker = DynamicTo<ServiceWorkerGlobalScope>(context)) {
mojom::blink::CacheStoragePtrInfo info = service_worker->TakeCacheStorage(); mojo::PendingRemote<mojom::blink::CacheStorage> info =
service_worker->TakeCacheStorage();
if (info) { if (info) {
cache_storage_ptr_ = RevocableInterfacePtr<mojom::blink::CacheStorage>( cache_storage_remote_ = mojo::Remote<mojom::blink::CacheStorage>(
std::move(info), context->GetInterfaceInvalidator(), task_runner); std::move(info), task_runner);
return; return;
} }
} }
context->GetInterfaceProvider()->GetInterface(MakeRequest( context->GetInterfaceProvider()->GetInterface(
&cache_storage_ptr_, context->GetInterfaceInvalidator(), task_runner)); cache_storage_remote_.BindNewPipeAndPassReceiver(task_runner));
} }
CacheStorage::~CacheStorage() = default; CacheStorage::~CacheStorage() = default;
...@@ -432,7 +435,7 @@ bool CacheStorage::HasPendingActivity() const { ...@@ -432,7 +435,7 @@ bool CacheStorage::HasPendingActivity() const {
void CacheStorage::Trace(blink::Visitor* visitor) { void CacheStorage::Trace(blink::Visitor* visitor) {
visitor->Trace(scoped_fetcher_); visitor->Trace(scoped_fetcher_);
ScriptWrappable::Trace(visitor); ScriptWrappable::Trace(visitor);
ContextClient::Trace(visitor); ContextLifecycleObserver::Trace(visitor);
} }
bool CacheStorage::IsAllowed(ScriptState* script_state) { bool CacheStorage::IsAllowed(ScriptState* script_state) {
...@@ -443,4 +446,8 @@ bool CacheStorage::IsAllowed(ScriptState* script_state) { ...@@ -443,4 +446,8 @@ bool CacheStorage::IsAllowed(ScriptState* script_state) {
return allowed_.value(); return allowed_.value();
} }
void CacheStorage::ContextDestroyed(ExecutionContext*) {
cache_storage_remote_.reset();
}
} // namespace blink } // namespace blink
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/cache_storage/cache_storage.mojom-blink.h" #include "third_party/blink/public/mojom/cache_storage/cache_storage.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" #include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
#include "third_party/blink/renderer/modules/cache_storage/multi_cache_query_options.h" #include "third_party/blink/renderer/modules/cache_storage/multi_cache_query_options.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/mojo/revocable_interface_ptr.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h"
...@@ -25,7 +25,7 @@ namespace blink { ...@@ -25,7 +25,7 @@ namespace blink {
class CacheStorage final : public ScriptWrappable, class CacheStorage final : public ScriptWrappable,
public ActiveScriptWrappable<CacheStorage>, public ActiveScriptWrappable<CacheStorage>,
public ContextClient { public ContextLifecycleObserver {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(CacheStorage); USING_GARBAGE_COLLECTED_MIXIN(CacheStorage);
...@@ -44,6 +44,7 @@ class CacheStorage final : public ScriptWrappable, ...@@ -44,6 +44,7 @@ class CacheStorage final : public ScriptWrappable,
bool HasPendingActivity() const override; bool HasPendingActivity() const override;
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
void ContextDestroyed(ExecutionContext*) override;
private: private:
ScriptPromise MatchImpl(ScriptState*, ScriptPromise MatchImpl(ScriptState*,
...@@ -54,7 +55,7 @@ class CacheStorage final : public ScriptWrappable, ...@@ -54,7 +55,7 @@ class CacheStorage final : public ScriptWrappable,
Member<GlobalFetch::ScopedFetcher> scoped_fetcher_; Member<GlobalFetch::ScopedFetcher> scoped_fetcher_;
RevocableInterfacePtr<mojom::blink::CacheStorage> cache_storage_ptr_; mojo::Remote<mojom::blink::CacheStorage> cache_storage_remote_;
base::Optional<bool> allowed_; base::Optional<bool> allowed_;
bool ever_used_; bool ever_used_;
......
...@@ -138,6 +138,8 @@ void Geolocation::ContextDestroyed(ExecutionContext*) { ...@@ -138,6 +138,8 @@ void Geolocation::ContextDestroyed(ExecutionContext*) {
StopUpdating(); StopUpdating();
last_position_ = nullptr; last_position_ = nullptr;
geolocation_.reset();
geolocation_service_.reset();
} }
void Geolocation::RecordOriginTypeAccess() const { void Geolocation::RecordOriginTypeAccess() const {
...@@ -449,6 +451,7 @@ void Geolocation::UpdateGeolocationConnection(GeoNotifier* notifier) { ...@@ -449,6 +451,7 @@ void Geolocation::UpdateGeolocationConnection(GeoNotifier* notifier) {
if (!GetExecutionContext() || !GetPage() || !GetPage()->IsPageVisible() || if (!GetExecutionContext() || !GetPage() || !GetPage()->IsPageVisible() ||
!updating_) { !updating_) {
geolocation_.reset(); geolocation_.reset();
geolocation_service_.reset();
disconnected_geolocation_ = true; disconnected_geolocation_ = true;
return; return;
} }
...@@ -461,17 +464,15 @@ void Geolocation::UpdateGeolocationConnection(GeoNotifier* notifier) { ...@@ -461,17 +464,15 @@ void Geolocation::UpdateGeolocationConnection(GeoNotifier* notifier) {
// See https://bit.ly/2S0zRAS for task types. // See https://bit.ly/2S0zRAS for task types.
scoped_refptr<base::SingleThreadTaskRunner> task_runner = scoped_refptr<base::SingleThreadTaskRunner> task_runner =
GetExecutionContext()->GetTaskRunner(TaskType::kMiscPlatformAPI); GetExecutionContext()->GetTaskRunner(TaskType::kMiscPlatformAPI);
InterfaceInvalidator* invalidator = GetFrame()->GetInterfaceProvider().GetInterface(
GetExecutionContext()->GetInterfaceInvalidator(); geolocation_service_.BindNewPipeAndPassReceiver(task_runner));
GetFrame()->GetInterfaceProvider().GetInterface(&geolocation_service_,
invalidator, task_runner);
geolocation_service_->CreateGeolocation( geolocation_service_->CreateGeolocation(
MakeRequest(&geolocation_, invalidator, std::move(task_runner)), geolocation_.BindNewPipeAndPassReceiver(std::move(task_runner)),
LocalFrame::HasTransientUserActivation(GetFrame()), LocalFrame::HasTransientUserActivation(GetFrame()),
WTF::Bind(&Geolocation::OnGeolocationPermissionStatusUpdated, WTF::Bind(&Geolocation::OnGeolocationPermissionStatusUpdated,
WrapWeakPersistent(this), WrapWeakPersistent(notifier))); WrapWeakPersistent(this), WrapWeakPersistent(notifier)));
geolocation_.set_connection_error_handler(WTF::Bind( geolocation_.set_disconnect_handler(WTF::Bind(
&Geolocation::OnGeolocationConnectionError, WrapWeakPersistent(this))); &Geolocation::OnGeolocationConnectionError, WrapWeakPersistent(this)));
if (enable_high_accuracy_) if (enable_high_accuracy_)
geolocation_->SetHighAccuracy(true); geolocation_->SetHighAccuracy(true);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_H_
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/geolocation.mojom-blink.h" #include "services/device/public/mojom/geolocation.mojom-blink.h"
#include "third_party/blink/public/mojom/geolocation/geolocation_service.mojom-blink.h" #include "third_party/blink/public/mojom/geolocation/geolocation_service.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" #include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
...@@ -42,7 +43,6 @@ ...@@ -42,7 +43,6 @@
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/mojo/revocable_interface_ptr.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
namespace blink { namespace blink {
...@@ -220,8 +220,8 @@ class MODULES_EXPORT Geolocation final ...@@ -220,8 +220,8 @@ class MODULES_EXPORT Geolocation final
HeapVector<Member<GeoNotifier>> watchers_being_invoked_; HeapVector<Member<GeoNotifier>> watchers_being_invoked_;
Member<Geoposition> last_position_; Member<Geoposition> last_position_;
RevocableInterfacePtr<device::mojom::blink::Geolocation> geolocation_; mojo::Remote<device::mojom::blink::Geolocation> geolocation_;
RevocableInterfacePtr<mojom::blink::GeolocationService> geolocation_service_; mojo::Remote<mojom::blink::GeolocationService> geolocation_service_;
bool enable_high_accuracy_ = false; bool enable_high_accuracy_ = false;
// Whether a GeoNotifier is waiting for a position update. // Whether a GeoNotifier is waiting for a position update.
......
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