Commit e2fcda03 authored by Minoru Chikamune's avatar Minoru Chikamune Committed by Commit Bot

Migrate PermissionStatus to use GC mojo wrappers.

No behavior change. This CL reduces potential risks of use-after-free bugs.

Bug: 1049056
Change-Id: Iecbd1024d347a21fe03a0a08926ee5e0eb1a145d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135553Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756634}
parent d99d630b
...@@ -39,7 +39,8 @@ PermissionStatus::PermissionStatus(ExecutionContext* execution_context, ...@@ -39,7 +39,8 @@ PermissionStatus::PermissionStatus(ExecutionContext* execution_context,
MojoPermissionDescriptor descriptor) MojoPermissionDescriptor descriptor)
: ExecutionContextLifecycleStateObserver(execution_context), : ExecutionContextLifecycleStateObserver(execution_context),
status_(status), status_(status),
descriptor_(std::move(descriptor)) {} descriptor_(std::move(descriptor)),
receiver_(this, execution_context) {}
PermissionStatus::~PermissionStatus() = default; PermissionStatus::~PermissionStatus() = default;
...@@ -67,10 +68,6 @@ void PermissionStatus::ContextLifecycleStateChanged( ...@@ -67,10 +68,6 @@ void PermissionStatus::ContextLifecycleStateChanged(
StopListening(); StopListening();
} }
void PermissionStatus::ContextDestroyed() {
StopListening();
}
String PermissionStatus::state() const { String PermissionStatus::state() const {
return PermissionStatusToString(status_); return PermissionStatusToString(status_);
} }
...@@ -102,6 +99,7 @@ void PermissionStatus::OnPermissionStatusChange(MojoPermissionStatus status) { ...@@ -102,6 +99,7 @@ void PermissionStatus::OnPermissionStatusChange(MojoPermissionStatus status) {
} }
void PermissionStatus::Trace(Visitor* visitor) { void PermissionStatus::Trace(Visitor* visitor) {
visitor->Trace(receiver_);
EventTargetWithInlineData::Trace(visitor); EventTargetWithInlineData::Trace(visitor);
ExecutionContextLifecycleStateObserver::Trace(visitor); ExecutionContextLifecycleStateObserver::Trace(visitor);
} }
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSION_STATUS_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSION_STATUS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSION_STATUS_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSION_STATUS_H_
#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/blink/public/mojom/permissions/permission.mojom-blink.h" #include "third_party/blink/public/mojom/permissions/permission.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/core/dom/events/event_target.h" #include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_state_observer.h" #include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_state_observer.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/heap_mojo_receiver.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -56,7 +56,7 @@ class PermissionStatus final : public EventTargetWithInlineData, ...@@ -56,7 +56,7 @@ class PermissionStatus final : public EventTargetWithInlineData,
// ExecutionContextLifecycleStateObserver implementation. // ExecutionContextLifecycleStateObserver implementation.
void ContextLifecycleStateChanged(mojom::FrameLifecycleState) override; void ContextLifecycleStateChanged(mojom::FrameLifecycleState) override;
void ContextDestroyed() override; void ContextDestroyed() override {}
String state() const; String state() const;
...@@ -72,7 +72,7 @@ class PermissionStatus final : public EventTargetWithInlineData, ...@@ -72,7 +72,7 @@ class PermissionStatus final : public EventTargetWithInlineData,
MojoPermissionStatus status_; MojoPermissionStatus status_;
MojoPermissionDescriptor descriptor_; MojoPermissionDescriptor descriptor_;
mojo::Receiver<mojom::blink::PermissionObserver> receiver_{this}; HeapMojoReceiver<mojom::blink::PermissionObserver> receiver_;
}; };
} // namespace blink } // namespace blink
......
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