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

Migrate Geolocation to use GC mojo wrappers.

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

Bug: 1049056
Change-Id: I364c818d7dc04e616114f50f8265e3c5a04b3718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147393Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758509}
parent 3566b750
......@@ -107,7 +107,9 @@ Geolocation* Geolocation::Create(ExecutionContext* context) {
Geolocation::Geolocation(ExecutionContext* context)
: ExecutionContextLifecycleObserver(context),
PageVisibilityObserver(GetDocument()->GetPage()),
watchers_(MakeGarbageCollected<GeolocationWatchers>()) {}
watchers_(MakeGarbageCollected<GeolocationWatchers>()),
geolocation_(context),
geolocation_service_(context) {}
Geolocation::~Geolocation() = default;
......@@ -117,6 +119,8 @@ void Geolocation::Trace(Visitor* visitor) {
visitor->Trace(one_shots_being_invoked_);
visitor->Trace(watchers_being_invoked_);
visitor->Trace(last_position_);
visitor->Trace(geolocation_);
visitor->Trace(geolocation_service_);
ScriptWrappable::Trace(visitor);
ExecutionContextLifecycleObserver::Trace(visitor);
PageVisibilityObserver::Trace(visitor);
......@@ -138,8 +142,6 @@ void Geolocation::ContextDestroyed() {
StopUpdating();
last_position_ = nullptr;
geolocation_.reset();
geolocation_service_.reset();
}
void Geolocation::RecordOriginTypeAccess() const {
......@@ -431,7 +433,7 @@ void Geolocation::StartUpdating(GeoNotifier* notifier) {
updating_ = true;
if (notifier->Options()->enableHighAccuracy() && !enable_high_accuracy_) {
enable_high_accuracy_ = true;
if (geolocation_)
if (geolocation_.is_bound())
geolocation_->SetHighAccuracy(true);
}
UpdateGeolocationConnection(notifier);
......@@ -451,7 +453,7 @@ void Geolocation::UpdateGeolocationConnection(GeoNotifier* notifier) {
disconnected_geolocation_ = true;
return;
}
if (geolocation_) {
if (geolocation_.is_bound()) {
if (notifier)
notifier->StartTimer();
return;
......
......@@ -27,7 +27,6 @@
#ifndef 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 "third_party/blink/public/mojom/geolocation/geolocation_service.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
......@@ -43,6 +42,7 @@
#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/heap/handle.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
#include "third_party/blink/renderer/platform/timer.h"
namespace blink {
......@@ -221,8 +221,8 @@ class MODULES_EXPORT Geolocation final
HeapVector<Member<GeoNotifier>> watchers_being_invoked_;
Member<Geoposition> last_position_;
mojo::Remote<device::mojom::blink::Geolocation> geolocation_;
mojo::Remote<mojom::blink::GeolocationService> geolocation_service_;
HeapMojoRemote<device::mojom::blink::Geolocation> geolocation_;
HeapMojoRemote<mojom::blink::GeolocationService> geolocation_service_;
bool enable_high_accuracy_ = false;
// 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