Commit 73630d31 authored by Minoru Chikamune's avatar Minoru Chikamune Committed by Commit Bot

Migrate BarcodeDetectorStatics to use GC mojo wrappers.

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

Bug: 1049056
Change-Id: I3d893bdb737ec96f5f0cd3f998eb147388b0753d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132351Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756088}
parent f6120ea3
......@@ -29,7 +29,7 @@ BarcodeDetectorStatics* BarcodeDetectorStatics::From(
}
BarcodeDetectorStatics::BarcodeDetectorStatics(ExecutionContext& document)
: Supplement<ExecutionContext>(document) {}
: Supplement<ExecutionContext>(document), service_(&document) {}
BarcodeDetectorStatics::~BarcodeDetectorStatics() = default;
......@@ -55,11 +55,12 @@ ScriptPromise BarcodeDetectorStatics::EnumerateSupportedFormats(
void BarcodeDetectorStatics::Trace(Visitor* visitor) {
Supplement<ExecutionContext>::Trace(visitor);
visitor->Trace(service_);
visitor->Trace(get_supported_format_requests_);
}
void BarcodeDetectorStatics::EnsureServiceConnection() {
if (service_)
if (service_.is_bound())
return;
ExecutionContext* context = GetSupplementable();
......
......@@ -5,11 +5,12 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SHAPEDETECTION_BARCODE_DETECTOR_STATICS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SHAPEDETECTION_BARCODE_DETECTOR_STATICS_H_
#include "mojo/public/cpp/bindings/remote.h"
#include "services/shape_detection/public/mojom/barcodedetection_provider.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h"
#include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
......@@ -47,7 +48,8 @@ class BarcodeDetectorStatics final
const Vector<shape_detection::mojom::blink::BarcodeFormat>&);
void OnConnectionError();
mojo::Remote<shape_detection::mojom::blink::BarcodeDetectionProvider>
HeapMojoRemote<shape_detection::mojom::blink::BarcodeDetectionProvider,
HeapMojoWrapperMode::kWithoutContextObserver>
service_;
// Holds Promises returned by EnumerateSupportedFormats() so that they can be
......
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